/* ============================================================
   Remove Spaces — ADH Brand Style Sheet
   Color system: apex / molten / carbide / titanium / silver
   Typography: Manrope (UI) + JetBrains Mono (code/data)
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ADH Brand Tokens */
  --apex:          #0038A8;
  --apex-dark:     #001F5E;
  --molten:        #FF5000;
  --carbide:       #1B1F24;
  --carbide-dark:  #2A3038;
  --titanium:      #8D99AE;
  --silver:        #F0F2F5;
  --silver-text:   #E1E4E8;

  /* Semantic mappings */
  --bg:            var(--silver);
  --bg-card:       #ffffff;
  --bg-input:      #ffffff;
  --bg-hover:      #E8EBF0;
  --border:        #D5D9E2;
  --border-focus:  var(--apex);
  --text:          var(--carbide);
  --text-dim:      #4A5568;
  --text-muted:    var(--titanium);
  --accent:        var(--apex);
  --accent-soft:   rgba(0,56,168,.06);
  --accent-glow:   rgba(0,56,168,.12);
  --cta:           var(--molten);
  --stat-hl-bg:    rgba(255,80,0,.07);
  --stat-hl-tx:    #D44400;

  /* Shadows (subtle blue tint for depth) */
  --shadow-sm:     0 1px 3px rgba(0,56,168,.04);
  --shadow-md:     0 4px 16px rgba(0,56,168,.06);
  --shadow-lg:     0 8px 32px rgba(0,56,168,.08);
  --shadow-glass:  0 20px 50px rgba(8,112,184,.07);

  /* Layout */
  --radius:        8px;
  --radius-lg:     12px;

  /* Typography */
  --font-sans:     'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  /* Motion */
  --transition:    .2s ease;
  --ease-swift:    cubic-bezier(.4,0,.2,1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header (Glassmorphism) --- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.80);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--apex);
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--apex);
}

.header-badge {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--titanium);
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 100px;
}

/* --- Main Content --- */
.main {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Options Section --- */
.options-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition);
  position: relative;
}
.option-card:hover {
  border-color: var(--apex);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: translateY(-1px);
}
.option-card:active {
  transform: scale(.98);
}
.option-card:has(input:checked) {
  border-color: var(--apex);
  background: var(--accent-soft);
}
.option-card input[type="checkbox"] {
  display: none;
}

/* Checkbox indicator */
.option-card::before {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 5px;
  flex-shrink: 0;
  transition: all var(--transition);
  background: var(--bg-card);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
}
.option-card:has(input:checked)::before {
  background-color: var(--apex);
  border-color: var(--apex);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7l3 3 5-6' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.option-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.option-icon svg {
  width: 18px;
  height: 18px;
}

/* Brand-derived icon colors */
.option-icon--leading  { background: rgba(0,56,168,.08);  color: var(--apex); }
.option-icon--trailing { background: rgba(0,31,94,.08);   color: var(--apex-dark); }
.option-icon--blank    { background: rgba(141,153,174,.1); color: #5A6577; }
.option-icon--dedup    { background: rgba(255,80,0,.07);   color: var(--molten); }

.option-card:has(input:not(:checked)) .option-icon { opacity: .4; }

.option-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.option-title {
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--carbide);
}
.option-desc {
  font-size: .68rem;
  color: var(--titanium);
  line-height: 1.3;
}

/* Trim Mode Select */
.trim-mode-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.trim-mode-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--titanium);
  white-space: nowrap;
  flex-shrink: 0;
}
.select-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.select-wrap select {
  width: 100%;
  appearance: none;
  padding: 8px 14px;
  padding-right: 36px;
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.select-wrap select:hover { border-color: var(--apex); }
.select-wrap select:focus {
  outline: none;
  border-color: var(--apex);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.select-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--titanium);
  pointer-events: none;
}

/* --- Editor Area --- */
.editor-area {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  min-height: 360px;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.editor-pane:focus-within {
  border-color: var(--apex);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md);
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--silver);
}
.pane-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--titanium);
}
.char-count {
  font-size: .7rem;
  font-family: var(--font-mono);
  color: var(--titanium);
}

.textarea-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-input);
  border: none;
  resize: none;
  outline: none;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.editor-textarea::placeholder {
  color: var(--titanium);
  font-style: italic;
}
.editor-pane--output .editor-textarea {
  background: var(--silver);
}

/* Drop overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--accent-soft);
  border: 2px dashed var(--apex);
  border-radius: var(--radius-lg);
  z-index: 10;
  pointer-events: none;
}
.drop-overlay svg {
  width: 48px;
  height: 48px;
  color: var(--apex);
}
.drop-overlay span {
  font-size: .9rem;
  font-weight: 700;
  color: var(--apex);
}
.drop-overlay.active {
  display: flex;
}

/* Divider / Swap button */
.editor-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
}
.btn-swap {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-swap svg { width: 18px; height: 18px; color: var(--titanium); }
.btn-swap:hover {
  background: var(--accent-soft);
  border-color: var(--apex);
  transform: rotate(180deg);
  box-shadow: var(--shadow-md);
}
.btn-swap:active { transform: rotate(180deg) scale(.92); }

/* --- Stats Bar --- */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 100px;
  transition: all var(--transition);
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--carbide);
  line-height: 1.3;
  transition: color var(--transition);
}
.stat-label {
  font-size: .65rem;
  color: var(--titanium);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.stat-item--highlight {
  background: var(--stat-hl-bg);
  border-color: rgba(255,80,0,.12);
}
.stat-item--highlight .stat-value { color: var(--stat-hl-tx); }

.stat-value.changed {
  color: var(--apex);
}

/* --- Action Buttons --- */
.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.btn:active { transform: scale(.97); }

.btn--primary {
  background: var(--apex);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn--primary:hover {
  background: var(--apex-dark);
  box-shadow: 0 4px 20px rgba(0,56,168,.18);
  transform: translateY(-1px);
}

.btn--secondary {
  background: var(--bg-card);
  color: var(--carbide);
  border-color: var(--border);
}
.btn--secondary:hover {
  border-color: var(--apex);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--titanium);
  border-color: transparent;
}
.btn--ghost:hover {
  background: var(--bg-hover);
  color: var(--carbide);
}

/* --- Shortcuts Hint --- */
.shortcuts-hint {
  text-align: center;
  font-size: .7rem;
  color: var(--titanium);
}
.shortcuts-hint kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: .65rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--border);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  padding: 10px 20px;
  background: var(--carbide);
  color: var(--silver-text);
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 600;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform .3s var(--ease-swift), opacity .3s;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 24px;
  font-size: .72rem;
  color: var(--titanium);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .option-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .main { padding: 16px; gap: 16px; }

  .option-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .trim-mode-wrap {
    flex-direction: column;
    align-items: stretch;
  }
  .select-wrap {
    max-width: none;
  }

  .editor-area {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
    min-height: auto;
  }
  .editor-pane { min-height: 200px; }

  .editor-divider {
    width: 100%;
    height: 48px;
  }
  .btn-swap:hover { transform: rotate(90deg); }

  .stats-bar { gap: 6px; }
  .stat-item { min-width: 80px; padding: 6px 10px; }
  .stat-value { font-size: 1rem; }
}

@media (max-width: 480px) {
  .header-inner { padding: 8px 16px; }
  .logo-text { font-size: 1rem; }
  .header-badge { display: none; }
  .option-cards { grid-template-columns: 1fr; }
  .option-card { padding: 8px 10px; }
  .btn { padding: 8px 16px; font-size: .8rem; }
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.options-section,
.editor-area,
.stats-bar,
.actions-bar {
  animation: fadeIn .4s var(--ease-swift) both;
}
.editor-area  { animation-delay: .05s; }
.stats-bar    { animation-delay: .1s; }
.actions-bar  { animation-delay: .15s; }
