/* styles.css · visualizador-referencias-excel · 1000HW
 * Cache-bust: ?v=1 · 2026-07-07
 *
 * Vanilla CSS (NO Tailwind, NO framework). Custom properties for the 14+ tokens
 * that drive light / dark / auto themes. Grid 5×5 in DOM <table>. Result table
 * with 4 categories of badges (WCAG AA contrast verified vs bg/light and bg/dark).
 */

:root {
  --color-bg:           #f7f8fa;
  --color-surface:      #ffffff;
  --color-surface-alt:  #f1f3f7;
  --color-text:         #0f172a;
  --color-text-soft:    #475569;
  --color-text-muted:   #5e6b7e;
  --color-border:       #d8dee9;
  --color-border-strong:#94a3b8;
  --color-accent:       #1e3a8a;
  --color-accent-soft:  #dbeafe;
  --color-link:         #1e3a8a;
  --color-link-hover:   #1e40af;
  --color-focus-ring:   #2563eb;
  --color-success-bg:   #ecfdf5;
  --color-success-fg:   #065f46;
  --color-warn-bg:      #fffbeb;
  --color-warn-fg:      #92400e;
  --color-danger-bg:    #fef2f2;
  --color-danger-fg:    #991b1b;
  /* Categories */
  --color-cat-absolute:    #1e40af; /* blue    - both locked */
  --color-cat-mixed-col:   #047857; /* green   - col locked   */
  --color-cat-mixed-row:   #b45309; /* amber   - row locked   */
  --color-cat-relative:    #475569; /* slate   - both shift   */
  --color-cat-absolute-bg: #dbeafe;
  --color-cat-mixed-col-bg:#d1fae5;
  --color-cat-mixed-row-bg:#fef3c7;
  --color-cat-relative-bg: #e2e8f0;
  --color-origin-bg:    #fff7ed; /* amber-50 */
  --color-origin-border:#f59e0b;
  --color-dest-bg:      #ecfdf5; /* green-50 */
  --color-dest-border:  #10b981;
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow:    0 4px 14px rgba(15, 23, 42, 0.08);
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --max-content: 1200px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg:           #0b1020;
    --color-surface:      #111827;
    --color-surface-alt:  #1f2937;
    --color-text:         #f1f5f9;
    --color-text-soft:    #cbd5e1;
    --color-text-muted:   #94a3b8;
    --color-border:       #334155;
    --color-border-strong:#64748b;
    --color-accent:       #93c5fd;
    --color-accent-soft:  #1e3a8a;
    --color-link:         #93c5fd;
    --color-link-hover:   #bfdbfe;
    --color-focus-ring:   #60a5fa;
    --color-success-bg:   #052e2b;
    --color-success-fg:   #6ee7b7;
    --color-warn-bg:      #432616;
    --color-warn-fg:      #fde68a;
    --color-danger-bg:    #4c1d1d;
    --color-danger-fg:    #fca5a5;
    --color-cat-absolute:    #93c5fd;
    --color-cat-mixed-col:   #6ee7b7;
    --color-cat-mixed-row:   #fde68a;
    --color-cat-relative:    #cbd5e1;
    --color-cat-absolute-bg: #1e3a8a;
    --color-cat-mixed-col-bg:#064e3b;
    --color-cat-mixed-row-bg:#78350f;
    --color-cat-relative-bg: #334155;
    --color-origin-bg:    #422006;
    --color-origin-border:#fbbf24;
    --color-dest-bg:      #052e2b;
    --color-dest-border:  #34d399;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:    0 6px 20px rgba(0, 0, 0, 0.5);
  }
}

[data-theme="dark"] {
  --color-bg:           #0b1020;
  --color-surface:      #111827;
  --color-surface-alt:  #1f2937;
  --color-text:         #f1f5f9;
  --color-text-soft:    #cbd5e1;
  --color-text-muted:   #94a3b8;
  --color-border:       #334155;
  --color-border-strong:#64748b;
  --color-accent:       #93c5fd;
  --color-accent-soft:  #1e3a8a;
  --color-link:         #93c5fd;
  --color-link-hover:   #bfdbfe;
  --color-focus-ring:   #60a5fa;
  --color-success-bg:   #052e2b;
  --color-success-fg:   #6ee7b7;
  --color-warn-bg:      #432616;
  --color-warn-fg:      #fde68a;
  --color-danger-bg:    #4c1d1d;
  --color-danger-fg:    #fca5a5;
  --color-cat-absolute:    #93c5fd;
  --color-cat-mixed-col:   #6ee7b7;
  --color-cat-mixed-row:   #fde68a;
  --color-cat-relative:    #cbd5e1;
  --color-cat-absolute-bg: #1e3a8a;
  --color-cat-mixed-col-bg:#064e3b;
  --color-cat-mixed-row-bg:#78350f;
  --color-cat-relative-bg: #334155;
  --color-origin-bg:    #422006;
  --color-origin-border:#fbbf24;
  --color-dest-bg:      #052e2b;
  --color-dest-border:  #34d399;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 6px 20px rgba(0, 0, 0, 0.5);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============================================================================
   Reset & base
   ============================================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover, a:focus { color: var(--color-link-hover); }

:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 8px 14px;
  background: var(--color-accent);
  color: #ffffff;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

.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;
}

/* ============================================================================
   Layout
   ============================================================================ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--color-text);
}
.site-header .brand svg { width: 32px; height: 32px; flex-shrink: 0; }
.site-header .actions {
  display: flex; align-items: center; gap: 8px;
}
.site-header button.toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
}
.site-header button.toggle:hover { background: var(--color-surface-alt); }

main {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 24px;
}

.site-footer {
  max-width: var(--max-content);
  margin: 40px auto 0;
  padding: 24px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  text-align: center;
  font-size: 0.875rem;
}
.site-footer .footer-actions {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px;
}

/* ============================================================================
   Hero
   ============================================================================ */

.hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 32px 28px;
  box-shadow: var(--shadow-sm);
}
.hero h1 {
  margin: 0 0 12px;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 800;
}
.hero p {
  margin: 0 0 8px;
  color: var(--color-text-soft);
  max-width: 70ch;
}
.hero .privacy-inline {
  margin-top: 14px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* ============================================================================
   Sections
   ============================================================================ */

.section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.section h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 700;
}
.section .help {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin: 8px 0 14px;
}

/* ============================================================================
   Form controls
   ============================================================================ */

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-soft);
}

input[type="text"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.95rem;
}
input[type="text"]:focus, select:focus, textarea:focus {
  border-color: var(--color-focus-ring);
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 1px;
}

textarea {
  min-height: 70px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  resize: vertical;
}

.input-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

button.primary, button.secondary {
  border: 0;
  cursor: pointer;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius);
  transition: background-color 0.15s;
}
button.primary {
  background: var(--color-accent);
  color: #ffffff;
}
button.primary:hover { background: var(--color-link-hover); }
button.secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
button.secondary:hover { background: var(--color-border); }

[aria-pressed="true"] {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}

/* ============================================================================
   Mini-grid (5x5)
   ============================================================================ */

.mini-grid-container {
  overflow-x: auto;
  padding-bottom: 4px;
}
table.mini-grid-table {
  border-collapse: collapse;
  margin: 0 auto;
  background: var(--color-surface);
  border: 2px solid var(--color-border-strong);
}
table.mini-grid-table th,
table.mini-grid-table td {
  border: 1px solid var(--color-border);
  font-size: 0.75rem;
  text-align: center;
  vertical-align: middle;
}
table.mini-grid-table thead th {
  background: var(--color-surface-alt);
  color: var(--color-text-soft);
  font-weight: 600;
  padding: 4px 10px;
}
table.mini-grid-table tbody th {
  background: var(--color-surface-alt);
  color: var(--color-text-soft);
  font-weight: 600;
  padding: 4px 10px;
}
table.mini-grid-table td.mini-cell {
  width: 120px;
  height: 60px;
  padding: 4px;
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text);
  position: relative;
}
table.mini-grid-table td.mini-cell:hover {
  background: var(--color-accent-soft);
}
td.mini-cell-origin {
  background: var(--color-origin-bg) !important;
  outline: 3px solid var(--color-origin-border);
  outline-offset: -3px;
}
td.mini-cell-dest {
  background: var(--color-dest-bg) !important;
  outline: 3px solid var(--color-dest-border);
  outline-offset: -3px;
}
td.mini-cell .mini-origin-label,
td.mini-cell .mini-dest-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.mini-cell-origin .mini-origin-label {
  color: var(--color-warn-fg);
  font-weight: 700;
}
td.mini-cell-dest .mini-dest-label {
  color: var(--color-success-fg);
  font-weight: 700;
}
td.mini-cell .mini-empty {
  display: block;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.grid-mode-toggle {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 12px;
}
.grid-mode-toggle button {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

/* ============================================================================
   Actions / sliders
   ============================================================================ */

input[type="range"] {
  width: 100%;
  accent-color: var(--color-accent);
  margin: 8px 0;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.range-row input[type="range"] { flex: 1; }
.range-row output {
  font-weight: 700;
  color: var(--color-text);
  min-width: 24px;
  text-align: center;
}

/* ============================================================================
   Result table
   ============================================================================ */

.result-table {
  margin-top: 12px;
  overflow-x: auto;
}
table.result-data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
table.result-data th,
table.result-data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}
table.result-data thead th {
  background: var(--color-surface-alt);
  font-weight: 600;
  color: var(--color-text-soft);
  font-size: 0.875rem;
}
table.result-data tbody tr:hover {
  background: var(--color-surface-alt);
}
table.result-data code {
  font-family: var(--font-mono);
  background: var(--color-surface-alt);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
table.result-data small {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-absolute {
  background: var(--color-cat-absolute-bg);
  color: var(--color-cat-absolute);
}
.badge-mixed_col {
  background: var(--color-cat-mixed-col-bg);
  color: var(--color-cat-mixed-col);
}
.badge-mixed_row {
  background: var(--color-cat-mixed-row-bg);
  color: var(--color-cat-mixed-row);
}
.badge-relative {
  background: var(--color-cat-relative-bg);
  color: var(--color-cat-relative);
}

.result-warning,
.result-empty {
  color: var(--color-danger-fg);
  background: var(--color-danger-bg);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

/* ============================================================================
   Examples
   ============================================================================ */

ul.examples-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}
li.example-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
li.example-item .example-meta {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0; flex: 1;
}
li.example-item .example-meta strong {
  font-weight: 700;
  color: var(--color-text);
}
li.example-item .example-meta .example-desc {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  word-break: break-all;
}

/* ============================================================================
   F4 toggle
   ============================================================================ */

#f4-button {
  font-family: var(--font-mono);
}

/* ============================================================================
   Honesty / details
   ============================================================================ */

details.honesty {
  margin-top: 12px;
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
}
details.honesty summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 4px 0;
}
details.honesty ol {
  margin: 12px 0 0;
  padding-left: 20px;
}
details.honesty ol li {
  margin-bottom: 12px;
  color: var(--color-text-soft);
}
details.honesty ol li strong {
  display: block;
  color: var(--color-text);
  margin-bottom: 4px;
}

/* ============================================================================
   Privacy modal & donation toast
   ============================================================================ */

#privacy-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
#privacy-modal .modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 480px;
  box-shadow: var(--shadow);
  border: 1px solid var(--color-border);
}
#privacy-modal h3 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}
#privacy-modal p {
  margin: 0 0 16px;
  color: var(--color-text-soft);
}

#donation-toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 90;
  max-width: 320px;
  font-size: 0.875rem;
  color: var(--color-text-soft);
}
#donation-toast .toast-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 720px) {
  .hero { padding: 24px 18px; }
  .hero h1 { font-size: 1.5rem; }
  main { padding: 16px; gap: 16px; }
  .section { padding: 18px; }
  table.mini-grid-table td.mini-cell { width: 100px; height: 56px; }
  .site-header { padding: 10px 14px; }
  .site-header .brand { font-size: 0.95rem; }
  td.mini-cell .mini-origin-label,
  td.mini-cell .mini-dest-label { font-size: 0.6875rem; }
}
