/* Calculadora de VRAM, cuantización GGUF y velocidad para IA local */
:root,
[data-theme="dark"] {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #0b0f17;
  --bg-surface: #131b2e;
  --bg-surface-2: #192338;
  --bg-input: #0f1626;
  --border-color: #26334d;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --purple: #a78bfa;
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --purple: #7c3aed;
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

[data-theme="dark"] .app-header { background: #131b2e !important; border-bottom: 1px solid #1e293b !important; }
[data-theme="dark"] .brand-title { color: #f8fafc !important; }
[data-theme="light"] .app-header { background: #ffffff !important; border-bottom: 1px solid #cbd5e1 !important; }
[data-theme="light"] .brand-title { color: #0f172a !important; }

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6, .brand-title, .section-title, .hero-title { font-family: var(--font-heading); }
.mono, code, pre { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.tool-layout { max-width: 1200px; width: 100%; margin: 1.5rem auto 3rem; padding: 0 1rem; flex: 1 0 auto; }
.tool-with-sidebar { display: flex; gap: 2rem; align-items: flex-start; width: 100%; }
.tool-main-content { flex: 1 1 0%; min-width: 0; width: 100%; }

.vram-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}

.hero-top { display: flex; flex-direction: column; gap: 1rem; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.65rem; }
.hero-pill {
  padding: 0.3rem 0.72rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(56, 189, 248, 0.3);
}
.hero-title { margin: 0 0 0.5rem; font-size: 1.4rem; font-weight: 700; line-height: 1.28; }
.hero-desc { margin: 0; font-size: 0.94rem; line-height: 1.55; color: var(--text-muted); max-width: 78ch; }

.preset-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-btn {
  min-height: 40px; padding: 0.45rem 0.9rem; border-radius: 10px;
  border: 1px solid var(--border-color); background: var(--bg-surface-2);
  color: var(--text-main); font-size: 0.84rem; font-weight: 600;
  cursor: pointer; font-family: var(--font-main); transition: border-color 0.15s, background 0.15s;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn.active { background: var(--accent-strong); border-color: var(--accent-strong); color: #ffffff; }

.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.section-title { margin: 0; font-size: 1.18rem; font-weight: 700; }
.section-sub { margin: 0.25rem 0 0; font-size: 0.88rem; color: var(--text-muted); }

.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.9rem; margin-bottom: 0.9rem; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; margin-bottom: 0.9rem; }
.form-grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.8rem; margin-top: 0.85rem; }

.field-group { min-width: 0; }
.field-group label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.35rem; }
.field-group input,
.field-group select {
  width: 100%; max-width: 100%; min-width: 0; min-height: 42px;
  padding: 0.5rem 0.75rem; border-radius: 10px;
  border: 1px solid var(--border-color); background-color: var(--bg-input); color: var(--text-main);
  font-size: 0.88rem; font-family: var(--font-main);
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.field-group select {
  appearance: none;
  padding-right: 40px;
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
}
[data-theme="dark"] .field-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
[data-theme="light"] .field-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.field-group select option,
.field-group select optgroup {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.advanced-panel {
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 0.8rem 1rem; margin-top: 0.4rem;
}
.advanced-panel summary { cursor: pointer; font-weight: 600; font-size: 0.86rem; color: var(--accent); }

.status-badge {
  padding: 0.42rem 0.9rem; border-radius: 999px; font-size: 0.82rem; font-weight: 700;
  white-space: nowrap;
}
.status-badge.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(16, 185, 129, 0.35); }
.status-badge.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(245, 158, 11, 0.35); }
.status-badge.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.35); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; margin-bottom: 1.2rem; }
.kpi-box {
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 0.95rem 1rem; display: flex; flex-direction: column; gap: 0.25rem;
}
.kpi-box.highlight { border-color: var(--accent); background: var(--accent-soft); }
.kpi-lbl { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.kpi-val { font-size: 1.4rem; font-weight: 800; line-height: 1.15; }
.kpi-sub { font-size: 0.78rem; color: var(--text-muted); }

.vram-bar-box {
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 1rem; margin-bottom: 1.1rem;
}
.vram-bar-head { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.55rem; }
.vram-stacked-track {
  position: relative; height: 26px; border-radius: 999px;
  background: var(--bg-input); border: 1px solid var(--border-color);
  display: flex; overflow: hidden;
}
.seg { height: 100%; transition: width 0.25s ease; }
.seg-weights { background: #0284c7; }
.seg-kv { background: #a855f7; }
.seg-overhead { background: #f59e0b; }
.vram-limit-line {
  position: absolute; top: 0; bottom: 0; width: 3px;
  background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.8); z-index: 2;
}
.vram-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.65rem; font-size: 0.8rem; color: var(--text-muted); }
.vram-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-weights { background: #0284c7; }
.dot-kv { background: #a855f7; }
.dot-overhead { background: #f59e0b; }
.dot-limit { background: #ef4444; }

.offload-box {
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 1rem 1.1rem; margin-bottom: 1.1rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.sub-title { margin: 0 0 0.25rem; font-size: 0.96rem; font-weight: 700; }
.sub-desc { margin: 0; font-size: 0.84rem; color: var(--text-muted); max-width: 58ch; }
.offload-metrics { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.offload-metrics div { display: flex; flex-direction: column; gap: 0.15rem; }
.offload-metrics span { font-size: 0.74rem; color: var(--text-muted); }
.offload-metrics strong { font-size: 1rem; }

.commands-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
.cmd-card {
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 0.85rem; min-width: 0;
}
.cmd-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.cmd-card pre {
  margin: 0; font-size: 0.78rem; line-height: 1.45; white-space: pre-wrap; word-break: break-all;
  color: var(--text-main);
}
.btn-copy {
  min-height: 32px; padding: 0.25rem 0.7rem; border-radius: 8px;
  border: 1px solid var(--border-color); background: var(--bg-surface-2);
  color: var(--text-main); font-size: 0.76rem; font-weight: 600; cursor: pointer;
}
.btn-copy:hover { border-color: var(--accent); color: var(--accent); }

.tabs-inline { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.tab-btn {
  min-height: 40px; padding: 0.45rem 0.9rem; border-radius: 10px;
  border: 1px solid var(--border-color); background: var(--bg-surface-2);
  color: var(--text-muted); font-weight: 600; font-size: 0.84rem; cursor: pointer;
}
.tab-btn.active { background: var(--accent-strong); border-color: var(--accent-strong); color: #ffffff; }

.table-responsive { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .data-table td {
  padding: 0.68rem 0.75rem; border-bottom: 1px solid var(--border-color); text-align: left;
}
.data-table th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.data-table th.num, .data-table td.num { text-align: right; font-family: var(--font-mono); }
.data-table tr.active-row { background: var(--accent-soft); }

.pill-fit {
  display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; white-space: nowrap;
}
.pill-fit.ok { background: var(--ok-soft); color: var(--ok); }
.pill-fit.warn { background: var(--warn-soft); color: var(--warn); }
.pill-fit.danger { background: var(--danger-soft); color: var(--danger); }

.faq-list { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.85rem; }
.faq-item {
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 0.85rem 1rem;
}
.faq-item summary { cursor: pointer; font-weight: 700; font-size: 0.94rem; }
.faq-item p { margin: 0.65rem 0 0; font-size: 0.88rem; line-height: 1.55; color: var(--text-muted); }

@media (max-width: 900px) {
  .form-grid-3, .form-grid-4, .form-grid-5, .kpi-grid, .commands-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .vram-card { padding: 1.05rem; }
  .form-grid-3, .form-grid-4, .form-grid-5, .kpi-grid, .commands-grid {
    grid-template-columns: 1fr;
  }
  .chip-btn, .tab-btn, .btn-copy { min-height: 42px; }
  .preset-chips .chip-btn { flex: 1 1 calc(50% - 0.5rem); }
}
