/* ─── CSS Variables & Reset ── Pro Terminal Theme ─────── */

/* ═══ DARK THEME (default) ═══════════════════════════════ */
:root, [data-theme="dark"] {
  --bg0: #0f0f0f;
  --bg1: #181818;
  --bg2: #212121;
  --bg3: #272727;
  --bg4: #303030;
  --line: #272727;
  --line2: #303030;
  --accent: #f0b429;
  --a2: #3ea6ff;
  --green: #2ba640;
  --red: #ff4e45;
  --orange: #f59e0b;
  --purple: #c084fc;
  --teal: #2dd4bf;
  --pink: #f472b6;
  --text: #f1f1f1;
  --text2: #aaaaaa;
  --text3: #717171;
  /* Inter: best-in-class UI font for legibility at small sizes (the app
     uses 8-10px mono in many places). Designed specifically for screens.
     JetBrains Mono: friendlier than DM Mono — wider character spacing,
     softer corners, easier on the eye for the dense mono text in pills,
     status badges, table data, etc. */
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', 'Consolas', monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow: 0 1px 3px rgba(0,0,0,.18), 0 4px 14px rgba(0,0,0,.18);
  --transition: all .16s cubic-bezier(.2,.6,.2,1);
  --nav-bg: #0f0f0f;
  --sidebar-bg: #0f0f0f;
  --card-bg: #181818;
}

/* ═══ BLACK THEME (pure terminal) ══════════════════════════ */
[data-theme="black"] {
  --bg0: #000000;
  --bg1: #080808;
  --bg2: #101010;
  --bg3: #181818;
  --bg4: #202020;
  --line: #151515;
  --line2: #222222;
  --text: #cccccc;
  --text2: #777777;
  --text3: #444444;
  --radius: 2px;
  --radius-lg: 2px;
  --nav-bg: #050505;
  --sidebar-bg: #050505;
  --card-bg: #080808;
}

/* ═══ BLUE THEME ═════════════════════════════════════════ */
[data-theme="blue"] {
  --bg0: #0a1628;
  --bg1: #0f1d32;
  --bg2: #152540;
  --bg3: #1c2f50;
  --bg4: #233860;
  --line: #1a2a48;
  --line2: #243658;
  --accent: #f0b429;
  --a2: #60a5fa;
  --green: #34d399;
  --red: #f87171;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #475569;
  --radius: 8px;
  --radius-lg: 12px;
  --nav-bg: #0c1a2e;
  --sidebar-bg: #0c1a2e;
  --card-bg: #0f1d32;
}

/* ═══ GOLDEN THEME ══════════════════════════════════════ */
[data-theme="golden"] {
  --bg0: #0f0d08;
  --bg1: #171410;
  --bg2: #1f1b14;
  --bg3: #28231a;
  --bg4: #312b20;
  --line: #231f16;
  --line2: #302920;
  --accent: #f0b429;
  --a2: #d4a020;
  --green: #22c55e;
  --red: #ef4444;
  --text: #e8e0d0;
  --text2: #a09880;
  --text3: #5a5040;
  --radius: 8px;
  --radius-lg: 12px;
  --nav-bg: #120f0a;
  --sidebar-bg: #120f0a;
  --card-bg: #171410;
}

/* ═══ LIGHT THEME ═══════════════════════════════════════ */
[data-theme="light"] {
  --bg0: #f0f1f5;
  --bg1: #ffffff;
  --bg2: #f5f6f8;
  --bg3: #e8eaef;
  --bg4: #dcdfe6;
  --line: #e0e2e8;
  --line2: #d0d3db;
  --accent: #c88a00;
  --a2: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #d97706;
  --purple: #9333ea;
  --teal: #0d9488;
  --pink: #db2777;
  --text: #1a1a2e;
  --text2: #555770;
  --text3: #8b8da0;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --nav-bg: #ffffff;
  --sidebar-bg: #fafbfc;
  --card-bg: #ffffff;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { background: var(--bg0); color: var(--text); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; letter-spacing: -.005em; line-height: 1.45; font-feature-settings: 'cv11', 'ss01', 'ss03'; }

/* Scrollbars */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg0); }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Selection */
::selection { background: rgba(232,168,0,.14); color: var(--text); }

/* Focus ring */
*:focus-visible { outline: 1.5px solid rgba(59,130,246,.35); outline-offset: 1px; }

/* Typography */
a { color: var(--a2); text-decoration: none; }
a:hover { text-decoration: none; opacity: .85; }

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* Utility classes */
.mono { font-family: var(--mono); font-size: 9px; color: var(--text2); }
.mono.hi { color: var(--text); }
.fade-in { animation: fadeIn .15s ease; }

/* ─── ICO SLOTS · sistema SVG único ──────────────────────────
   Cualquier <span class="ico-slot" data-ico="name"></span> en el DOM se
   hidrata automáticamente con el SVG correspondiente de icons.js (vía
   MutationObserver). Tamaño + color heredados del padre (currentColor)
   para que el icono respete el contexto del botón/link. */
.ico-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  vertical-align: -2px;
  color: currentColor;
}
.ico-slot svg { width: 100%; height: 100%; display: block; }
.ico-slot + span { margin-left: 6px; }
/* Older `.r-ico` wrapper (used by ICO() helper) — same baseline */
.r-ico { display: inline-flex; align-items: center; justify-content: center; }
.r-ico svg { width: 100%; height: 100%; display: block; }

/* Spin loader */
.spin {
  width: 10px; height: 10px;
  border: 1.5px solid rgba(232,168,0,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .5s linear infinite;
  display: inline-block;
}

/* Theme switcher button */
.theme-btn {
  font-family: var(--mono); font-size: 9px;
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 4px 8px;
  color: var(--text2); cursor: pointer;
  transition: var(--transition); display: flex; align-items: center; gap: 4px;
}
.theme-btn:hover { background: var(--bg2); color: var(--text); border-color: var(--text3); }
.theme-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; z-index: 999; min-width: 130px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.theme-menu.open { display: block; }
.theme-opt {
  padding: 7px 14px; font-size: 10px; font-family: var(--mono); color: var(--text2);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: var(--transition);
}
.theme-opt:hover { background: var(--bg3); color: var(--text); }
.theme-opt .tdot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line2); }
.theme-opt.active { color: var(--accent); }
.theme-opt.active .tdot { border-color: var(--accent); }

/* Settings Tabs */
.sett-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--line);
  padding: 0 20px; background: transparent;
}
.sett-tab {
  font-family: var(--sans); font-size: 11px; padding: 10px 16px;
  cursor: pointer; color: var(--text3); border-bottom: 2px solid transparent;
  transition: var(--transition); white-space: nowrap; font-weight: 500;
}
.sett-tab:hover { color: var(--text2); }
.sett-tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.sett-pane { }

/* Settings Modal */
.settings-section {
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.settings-section:last-child { border-bottom: none; }
.settings-title {
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
/* Configuration status pill next to each Settings section title.
   Populated by loadSettingsValues() based on whether the key(s)
   for that section have been saved by THIS user (per-user DB). */
.settings-status {
  display: inline-block; font-family: var(--mono); font-size: 9px;
  font-weight: 600; padding: 2px 8px; border-radius: 10px;
  margin-left: 8px; vertical-align: 2px; text-transform: uppercase;
  letter-spacing: .5px; border: 1px solid transparent;
}
.settings-status.ok { background: rgba(34,197,94,.12); color: var(--green); border-color: rgba(34,197,94,.3); }
.settings-status.warn { background: rgba(239,68,68,.1); color: #fca5a5; border-color: rgba(239,68,68,.35); }
.settings-status.partial { background: rgba(232,168,0,.12); color: var(--accent); border-color: rgba(232,168,0,.3); }
.settings-desc {
  font-family: var(--mono); font-size: 9px; color: var(--text3);
  margin-bottom: 10px; line-height: 1.5;
}
.settings-field {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.settings-label {
  font-family: var(--mono); font-size: 9px; color: var(--text2);
  min-width: 90px; flex-shrink: 0;
}
.settings-input {
  flex: 1; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 10px;
  color: var(--text); font-family: var(--mono); font-size: 10px;
  outline: none; transition: border-color .18s;
}
.settings-input:focus { border-color: var(--accent); background: var(--bg3); }
.settings-save-btn {
  font-family: var(--mono); font-size: 9px; padding: 4px 10px;
  border-radius: var(--radius); border: 1px solid rgba(34,197,94,.25);
  background: rgba(34,197,94,.06); color: var(--green);
  cursor: pointer; white-space: nowrap; transition: var(--transition);
}
.settings-save-btn:hover { background: rgba(34,197,94,.12); }
.settings-connect-btn {
  font-family: var(--mono); font-size: 10px; padding: 6px 14px;
  border-radius: var(--radius); border: 1px solid rgba(59,130,246,.25);
  background: rgba(59,130,246,.06); color: var(--a2);
  cursor: pointer; margin-top: 6px; transition: var(--transition);
}
.settings-connect-btn:hover { background: rgba(59,130,246,.12); }
.settings-tutorial {
  margin-top: 8px; font-family: var(--mono); font-size: 9px;
}
.settings-tutorial summary {
  cursor: pointer; color: var(--a2); padding: 4px 0;
  user-select: none;
}
.settings-tutorial summary:hover { color: var(--accent); }
.settings-tutorial ol {
  padding-left: 18px; margin-top: 6px; color: var(--text2);
  line-height: 1.8;
}
.settings-tutorial ol a { color: var(--a2); }
.settings-tutorial ol b { color: var(--text); }
.settings-tutorial ol code {
  background: var(--bg3); padding: 1px 4px; border-radius: 3px;
  font-size: 9px; color: var(--accent);
}
.settings-note {
  margin-top: 6px; padding: 6px 8px; border-radius: var(--radius);
  background: rgba(232,168,0,.06); border: 1px solid rgba(232,168,0,.15);
  color: var(--accent); font-size: 9px; line-height: 1.5;
}
