/* =====================================================
   Email Header Tag Converter — Styles
   Dark, developer-tool aesthetic.
===================================================== */

:root {
  --bg: #111111;
  --panel: #1d1d1d;
  --panel-alt: #191919;
  --border: #2a2a2a;
  --border-soft: #232323;
  --text: #e8e8e8;
  --text-dim: #9a9a9a;
  --text-faint: #5f5f5f;

  --accent: #4f8dff;
  --accent-soft: rgba(79, 141, 255, 0.12);
  --accent-strong: #6ea1ff;

  --static: #4f8dff;
  --random: #37c97f;
  --unique: #d9a441;
  --unknown: #e05a5a;
  --real: #b98af7;

  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(79, 141, 255, 0.06), transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(55, 201, 127, 0.05), transparent 40%);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ================= HEADER ================= */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-glyph {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(79, 141, 255, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  line-height: 1;
}

.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.subtitle code {
  font-family: var(--mono);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-static  { background: var(--static); }
.dot-random  { background: var(--random); }
.dot-unique  { background: var(--unique); }
.dot-unknown { background: var(--unknown); }
.dot-real    { background: var(--real); }

/* ================= CONVERTER GRID ================= */

.converter {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: border-color var(--transition);
}

.panel:focus-within {
  border-color: rgba(79, 141, 255, 0.45);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.panel-head label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.char-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

textarea {
  flex: 1;
  min-height: 320px;
  resize: vertical;
  background: var(--panel-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  padding: 14px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

textarea:focus {
  border-color: var(--accent);
  background: #161616;
}

textarea::placeholder {
  color: var(--text-faint);
}

textarea[readonly] {
  cursor: text;
}

/* ================= CONTROLS ================= */

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 4px;
}

.controls .toggle {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  width: 148px;
}

/* Custom checkbox toggle switch */
.toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  position: relative;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform var(--transition), background var(--transition);
}

.toggle input:checked + .toggle-track {
  background: rgba(185, 138, 247, 0.18);
  border-color: var(--real);
}

.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(17px);
  background: var(--real);
}

.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle-label {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.35;
}

.btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  width: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
  background: var(--panel);
  color: var(--text);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
  font-size: 14.5px;
  padding: 13px 16px;
  box-shadow: 0 6px 20px rgba(79, 141, 255, 0.25);
}

.btn-primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 8px 24px rgba(79, 141, 255, 0.35);
}

.btn-arrow {
  font-size: 15px;
  line-height: 1;
}

.btn-ghost {
  background: transparent;
}

.btn-ghost:hover {
  background: var(--panel-alt);
  border-color: #3a3a3a;
}

.btn-danger {
  background: transparent;
  color: #d98080;
  border-color: rgba(224, 90, 90, 0.25);
}

.btn-danger:hover {
  background: rgba(224, 90, 90, 0.08);
  border-color: rgba(224, 90, 90, 0.45);
}

.btn.copied {
  background: var(--random);
  border-color: var(--random);
  color: #0b1220;
}

/* ================= BOTTOM PANEL ================= */

.bottom-panel {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
}

.stats-card,
.unknown-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.stats-card h2,
.unknown-card h2 {
  margin: 0 0 14px;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left: 2px solid var(--border);
  padding-left: 12px;
  transition: border-color var(--transition);
}

.stat:nth-child(1) { border-left-color: var(--static); }
.stat:nth-child(2) { border-left-color: var(--random); }
.stat:nth-child(3) { border-left-color: var(--unique); }
.stat:nth-child(4) { border-left-color: var(--unknown); }
.stat:nth-child(5) { border-left-color: var(--real); }

.stat-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  transition: color var(--transition);
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-dim);
}

.unknown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.unknown-list li {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(224, 90, 90, 0.08);
  border: 1px solid rgba(224, 90, 90, 0.2);
  color: #eaa9a9;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.unknown-empty {
  font-family: var(--sans) !important;
  background: transparent !important;
  border: 1px dashed var(--border) !important;
  color: var(--text-faint) !important;
}

/* ================= FOOTER ================= */

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  font-size: 12px;
  color: var(--text-faint);
}

#statusMsg {
  color: var(--text-dim);
  font-family: var(--mono);
}

/* ================= RESPONSIVE ================= */

@media (max-width: 860px) {
  .converter {
    grid-template-columns: 1fr;
  }

  .controls {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .btn {
    width: auto;
    flex: 1 1 45%;
  }

  .controls .toggle {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
    width: auto;
    flex-direction: row;
    flex: 1 1 100%;
    justify-content: center;
  }

  .toggle-label {
    text-align: left;
  }

  .bottom-panel {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .app {
    padding: 18px 14px 28px;
  }

  .legend {
    gap: 10px;
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
