/* ═══════════════════════════════════════════
   LinkLens — Stylesheet v4.0
   ═══════════════════════════════════════════ */

/* ── Light theme ── */
:root {
  --teal: #00B4C5;
  --teal-dark: #0096A8;
  --teal-light: #E0F7FA;
  --teal-mid: #B2EBF2;
  --navy: #1A2E3B;
  --accent: #00D4E8;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --bg: #F5FAFB;
  --card: #FFFFFF;
  --border: #D0EEF2;
  --text: #1A2E3B;
  --muted: #6B8A96;
  --row-hover: #F0FAFB;
  --row-alt: #F8FCFD;
  --table-head: #1A2E3B;
  --preview-bg: #F8FCFD;
  --preview-border: #D0EEF2;
  --input-bg: #FFFFFF;
  --input-border: #D0EEF2;
  --hero-start: #0F2535;
  --hero-end: #0E3040;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg: #0D1B24;
  --card: #132130;
  --border: #1E3648;
  --text: #E2EEF3;
  --muted: #5A8A9F;
  --row-hover: #1A2E3B;
  --row-alt: #152838;
  --table-head: #0A1825;
  --preview-bg: #132130;
  --preview-border: #1E3648;
  --input-bg: #132130;
  --input-border: #1E3648;
  --teal-light: #0D2A30;
  --teal-mid: #1A4A55;
  --hero-start: #070F16;
  --hero-end: #0A1825;
  --navy: #0A1825;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .3s, color .3s;
}

.mono { font-family: 'Space Mono', monospace; }

/* ── Hero ── */
.hero-bg {
  background: linear-gradient(160deg, var(--hero-start) 0%, #1A3D4E 55%, var(--hero-end) 100%);
  position: relative;
  overflow: hidden;
  transition: background .3s;
}
.hero-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 40%, rgba(0,180,197,.18) 0%, transparent 60%);
}
.hero-glow {
  position: absolute;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(0,212,232,.12), transparent 70%);
  border-radius: 50%;
  top: -60px; right: -60px;
  pointer-events: none;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 2px 16px rgba(0,180,197,.06);
  transition: background .3s, border .3s;
}
.stat-badge {
  background: var(--teal-light);
  border: 1px solid var(--teal-mid);
  border-radius: 12px;
  padding: 14px 16px;
}

/* ── Input mode tabs ── */
.mode-tab {
  padding: 10px 24px;
  border-radius: 12px 12px 0 0;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid var(--border);
  border-bottom: none;
  transition: all .2s;
  background: var(--bg);
  color: var(--muted);
}
.mode-tab.active {
  background: var(--card);
  color: var(--text);
}

/* ── Dropzone ── */
.dropzone {
  border: 2.5px dashed var(--teal);
  background: var(--teal-light);
  transition: all .25s;
  cursor: pointer;
  border-radius: 16px;
}
.dropzone.drag-over {
  border-color: var(--accent);
  transform: scale(1.01);
}
.dropzone.file-ready {
  border-color: var(--success);
  background: rgba(34,197,94,.08);
}

/* ── Toggle switch ── */
.toggle-track {
  width: 52px; height: 28px;
  background: #CBD5E1;
  border-radius: 9999px;
  position: relative;
  cursor: pointer;
  transition: background .2s;
}
.toggle-track.on { background: var(--teal); }
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  background: white;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle-track.on .toggle-thumb { transform: translateX(24px); }

/* ── Method button ── */
.method-btn {
  padding: 7px 18px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  border: 2px solid transparent;
}
.method-btn.active {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}
.method-btn:not(.active) {
  background: transparent;
  color: var(--teal);
  border-color: var(--teal);
}

/* ── Pills ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Space Mono', monospace;
  letter-spacing: .04em;
}
.pill-match   { background: #DCFCE7; color: #166534; }
.pill-nomatch { background: #F1F5F9; color: #475569; }
.pill-error   { background: #FEE2E2; color: #991B1B; }
.pill-high    { background: #FEE2E2; color: #991B1B; }
.pill-medium  { background: #FEF3C7; color: #92400E; }
.pill-low     { background: #DCFCE7; color: #065F46; }
.pill-file-a  { background: #EDE9FE; color: #4C1D95; }
.pill-file-b  { background: #FEE2E2; color: #7F1D1D; }

/* ── Similarity bar ── */
.sim-bar {
  height: 6px;
  border-radius: 9999px;
  background: var(--border);
  overflow: hidden;
}
.sim-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ── Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--teal-mid);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-sm { width: 20px; height: 20px; border-width: 2px; }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp .45s ease both; }

/* ── Filter / section tabs ── */
.filter-tab, .section-tab {
  padding: 5px 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  border: 1.5px solid var(--border);
  color: var(--muted);
}
.section-tab { padding: 8px 20px; font-size: 13px; }
.filter-tab.active, .section-tab.active { background: var(--navy); color: white; border-color: var(--navy); }
.filter-tab:hover:not(.active), .section-tab:hover:not(.active) { border-color: var(--teal); color: var(--teal); }

/* ── Cross diagram ── */
.vs-badge {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  font-family: 'Space Mono', monospace;
  flex-shrink: 0;
}
.cross-line {
  height: 2px;
  background: linear-gradient(90deg, #6C3FD4, var(--teal));
  border-radius: 2px;
}

/* ── Dark mode toggle ── */
.dark-toggle {
  width: 40px; height: 22px;
  border-radius: 9999px;
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all .2s;
}
.dark-toggle:hover { background: rgba(255,255,255,.25); }

/* ── Results table ── */
.results-table { border-collapse: collapse; width: 100%; }
.results-table th {
  background: var(--table-head);
  color: white;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  font-family: 'Space Mono', monospace;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.results-table th:first-child { border-radius: 10px 0 0 0; }
.results-table th:last-child  { border-radius: 0 10px 0 0; }
.results-table th:hover { background: rgba(0,180,197,.25); }
.results-table th .sort-icon { display: inline-block; margin-left: 4px; opacity: .5; font-size: 10px; }
.results-table th.sort-asc  .sort-icon::after { content: '▲'; }
.results-table th.sort-desc .sort-icon::after { content: '▼'; }
.results-table th:not(.sort-asc):not(.sort-desc) .sort-icon::after { content: '⇅'; }
.results-table td {
  padding: 9px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.results-table tr:hover td { background: var(--row-hover); }
.results-table tr:nth-child(even) td { background: var(--row-alt); }
.results-table tr:nth-child(even):hover td { background: var(--row-hover); }
.results-table tr:last-child td { border-bottom: none; }
.url-cell { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── CSV Preview ── */
.preview-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.preview-table th {
  background: var(--navy);
  color: white;
  padding: 6px 10px;
  text-align: left;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: .06em;
}
.preview-table td { padding: 5px 10px; border-bottom: 1px solid var(--preview-border); color: var(--text); }
.preview-table tr:last-child td { border-bottom: none; }
.preview-table tr:hover td { background: var(--row-hover); }
.preview-wrap {
  background: var(--preview-bg);
  border: 1px solid var(--preview-border);
  border-radius: 10px;
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
}

/* ── Diff modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-body { overflow-y: auto; flex: 1; padding: 20px 24px; }
.modal-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  color: var(--text);
}
.modal-close:hover { background: var(--muted); }

/* ── Diff blocks ── */
.diff-col { flex: 1; min-width: 0; }
.diff-block {
  padding: 6px 10px;
  border-radius: 6px;
  margin: 3px 0;
  font-size: 12.5px;
  line-height: 1.6;
  word-wrap: break-word;
}
.diff-equal     { color: var(--muted); }
.diff-delete    { background: #FEE2E2; color: #991B1B; border-left: 3px solid #EF4444; }
.diff-insert    { background: #DCFCE7; color: #065F46; border-left: 3px solid #22C55E; }
.diff-replace-a { background: #FEF3C7; color: #92400E; border-left: 3px solid #F59E0B; }
.diff-replace-b { background: #DBEAFE; color: #1E40AF; border-left: 3px solid #3B82F6; }
.kw-pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; margin: 2px; font-family: 'Space Mono', monospace; }
.kw-a { background: #EDE9FE; color: #4C1D95; }
.kw-b { background: #DBEAFE; color: #1E40AF; }

/* ── Heatmap ── */
.hm-table { border-collapse: collapse; }
.hm-table td, .hm-table th {
  width: 38px; height: 38px;
  text-align: center;
  font-size: 9px;
  font-family: 'Space Mono', monospace;
  border: 1px solid rgba(128,128,128,.15);
  cursor: pointer;
  transition: opacity .15s;
}
.hm-table th {
  background: var(--table-head);
  color: rgba(255,255,255,.7);
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  height: 90px; width: 38px;
  padding: 4px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hm-table th.row-label {
  writing-mode: horizontal-tb;
  transform: none;
  height: 38px; width: 100px;
  text-align: right;
  padding-right: 8px;
  font-size: 10px;
}
.hm-table td:hover { opacity: .75; outline: 2px solid white; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--teal-mid); border-radius: 4px; }
