/* ===== CSS Custom Properties ===== */
:root {
  /* Dark Gruvbox palette */
  --bg: #282828;
  --bg0_h: #1d2021;
  --bg1: #3c3836;
  --bg2: #504945;
  --bg3: #665c54;
  --bg4: #7c6f64;
  
  --fg: #ebdbb2;
  --fg0: #fbf1c7;
  --fg1: #ebdbb2;
  --fg2: #d5c4a1;
  --fg3: #bdae93;
  --fg4: #a89984;
  
  --red: #cc241d;
  --red-bright: #fb4934;
  --green: #98971a;
  --green-bright: #b8bb26;
  --yellow: #d79921;
  --yellow-bright: #fabd2f;
  --blue: #458588;
  --blue-bright: #83a598;
  --purple: #b16286;
  --purple-bright: #d3869b;
  --aqua: #689d6a;
  --aqua-bright: #8ec07c;
  --orange: #d65d0e;
  --orange-bright: #fe8019;
  
  --gray: #928374;
  --gray-bright: #a89984;
  
  /* Semantic mappings */
  --surface: var(--bg0_h);
  --surface-2: var(--bg1);
  --surface-3: var(--bg2);
  --border: var(--bg3);
  --border-focus: var(--blue);
  --text: var(--fg);
  --text-muted: var(--gray);
  --text-dim: var(--gray-bright);
  --accent: var(--blue);
  --accent-hover: var(--blue-bright);
  --accent-dim: rgba(69, 133, 136, 0.15);
  --success: var(--green);
  --danger: var(--red);
  --warning: var(--yellow);
  --link-color: var(--blue-bright);
  
  --header-h: 56px;
  --footer-h: 52px;
  --pane-header-h: 40px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  
  /* Modern font stacks */
  --font-sans: Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  
  --transition: 150ms ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* General link styling */
a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

a:visited {
  color: var(--purple-bright);
}

a:visited:hover {
  color: var(--purple);
}

button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ===== Scrollbars ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
  outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 2px var(--border-focus); }
.btn i { width: 15px; height: 15px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-dim); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.1); }

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding: 6px;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon i { width: 18px; height: 18px; }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-sm i { width: 13px; height: 13px; }

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  font-size: inherit;
  padding: 0;
}
.link-btn:hover { color: var(--accent-hover); }

/* ===== App Header ===== */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  gap: 12px;
}

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

.brand-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Settings gear - show just one SVG */
#btn-settings svg:last-child { display: none; }

/* ===== Main Workspace ===== */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ===== Panes ===== */
.pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 240px;
}

.pane-input {
  flex: 0 0 380px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.pane-preview {
  flex: 1;
  background: var(--bg);
}

.pane-header {
  height: var(--pane-header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 8px;
}

.pane-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== Resize Handle ===== */
.resize-handle {
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background var(--transition);
  position: relative;
}
.resize-handle:hover,
.resize-handle.dragging { background: var(--accent); }
.resize-handle:focus-visible { outline: 2px solid var(--border-focus); }

/* ===== Drop Zone ===== */
.drop-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 24px;
  margin: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.drop-zone.drag-over .drop-icon { color: var(--accent); transform: scale(1.1); }

.drop-icon {
  width: 40px;
  height: 40px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), color var(--transition);
}

.drop-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.drop-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.drop-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* ===== File List ===== */
.file-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
}

.file-item:hover { background: var(--surface-2); }
.file-item.active {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.file-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.file-item-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.file-item-size {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.file-item-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 2px;
  border-radius: 3px;
  display: flex;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
}
.file-item:hover .file-item-remove { opacity: 1; }
.file-item-remove:hover { color: var(--danger); }
.file-item-remove svg { width: 13px; height: 13px; }

/* ===== Paste Section ===== */
.paste-section {
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
}

.paste-area-wrap {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paste-textarea {
  width: 100%;
  height: 160px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
  line-height: 1.5;
}
.paste-textarea:focus { border-color: var(--border-focus); }

.paste-actions {
  display: flex;
  gap: 6px;
}

/* ===== View Toggle ===== */
.view-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.view-btn:hover { color: var(--text); background: var(--surface-3); }
.view-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ===== Preview Stats ===== */
.preview-stats {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ===== App Footer ===== */
.app-footer {
  height: var(--footer-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  gap: 12px;
}

.footer-left {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-attribution {
  font-size: 11px;
  color: var(--text-dim);
}

.footer-attribution a {
  color: var(--aqua-bright);
  text-decoration: none;
}

.footer-attribution a:hover {
  color: var(--aqua);
  text-decoration: underline;
}

.footer-credits {
  font-size: 11px;
  color: var(--text-dim);
}

.footer-credits a {
  color: var(--aqua-bright);
  text-decoration: none;
}

.footer-credits a:hover {
  color: var(--aqua);
  text-decoration: underline;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Settings Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.settings-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-group legend {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 6px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.setting-label {
  font-size: 13px;
  color: var(--text);
}

.setting-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  min-width: 140px;
}
.setting-select:focus { border-color: var(--border-focus); }

.setting-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.setting-input-num {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 12px;
  width: 70px;
  outline: none;
  text-align: right;
}
.setting-input-num:focus { border-color: var(--border-focus); }

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 68px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  pointer-events: auto;
  animation: toast-in 200ms ease forwards;
  max-width: 320px;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-info    { border-left: 3px solid var(--accent); }

.toast.toast-out { animation: toast-out 200ms ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.toast-success svg { color: var(--success); }
.toast.toast-error   svg { color: var(--danger); }
.toast.toast-warning svg { color: var(--warning); }
.toast.toast-info    svg { color: var(--accent); }

/* ===== Progress Bar ===== */
.progress-bar-wrap {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  height: 2px;
  background: var(--surface-2);
  z-index: 50;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 100ms ease;
}

/* ===== Utility ===== */
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
