/* ============================================================
   AI Smart BioLink — Minimal Override CSS
   Loads AFTER Tailwind. Only adds what Tailwind doesn't cover.
   Never uses wildcard (*) font rules — Tailwind handles that.
   ============================================================ */

/* ── Theme CSS Variables (dark default) ── */
:root,
[data-theme="dark"] {
  --primary:    #6366f1;
  --primary-dk: #4f46e5;
  --accent:     #f59e0b;
  --success:    #22c55e;
  --danger:     #ef4444;
  --bg:         #07070e;
  --surface:    #0f0f1a;
  --surface2:   #181828;
  --border:     #1e1e32;
  --text:       #e2e8f0;
  --muted:      #64748b;
}

[data-theme="light"] {
  --primary:    #6366f1;
  --primary-dk: #4f46e5;
  --accent:     #d97706;
  --success:    #16a34a;
  --danger:     #dc2626;
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --surface2:   #f1f5f9;
  --border:     #e2e8f0;
  --text:       #0f172a;
  --muted:      #64748b;
}

/* ── Base body background & color (theme-driven) ── */
html { scroll-behavior: smooth; }
body {
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 0.2s, color 0.2s;
  min-height: 100vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 2px; }

/* ── Mono utility (font already set via Tailwind config) ── */
.mono { font-family: 'JetBrains Mono', monospace !important; }

/* ── Sidebar (fixed position, NOT Tailwind grid) ── */
.sidebar {
  width: 240px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s ease;
  overflow-y: auto;
}
.main-content {
  margin-left: 240px;
  min-height: 100vh;
}

/* ── Sidebar nav link ── */
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  white-space: nowrap;
}
.nav-link i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}
.nav-link:hover,
.nav-link.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}
.nav-section {
  padding: 10px 12px 3px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.5;
}

/* ── Mobile topbar (hidden on desktop) ── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 199;
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 195;
  backdrop-filter: blur(2px);
}

/* ── Form inputs (themed, Tailwind doesn't theme by default) ── */
.form-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.form-input::placeholder { color: var(--muted); }

/* ── Badge (tiny status pill) ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 300px;
}
.toast {
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  animation: toastIn 0.3s ease;
}
@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  position: relative;
  margin: auto;
}

/* ── PIN input row ── */
.pin-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.pin-box {
  width: 44px;
  height: 52px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 10px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  transition: border-color 0.2s;
  caret-color: var(--primary);
}
.pin-box:focus, .pin-box.has-val { border-color: var(--primary); }

/* ── Toggle switch ── */
.toggle-switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border); border-radius: 11px;
  transition: background 0.2s; cursor: pointer;
}
.toggle-track::before {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--primary); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); }

/* ── Theme toggle button ── */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
  text-align: left;
}
.theme-toggle-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Data table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface2);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(99,102,241,0.03); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Responsive breakpoints ── */
@media (max-width: 1024px) {
  .sidebar      { transform: translateX(-240px); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .mobile-topbar { display: flex; }
  .main-content { margin-left: 0; padding-top: 56px; }
  .hide-mobile { display: none !important; }
}
@media (max-width: 768px) {
  .modal-box { padding: 20px; border-radius: 12px; margin: 0 auto; }
  .modal-backdrop { padding: 20px 12px; }
  .hide-sm { display: none !important; }
  .pin-box { width: 38px; height: 46px; font-size: 18px; }
  .pin-row { gap: 5px; }
  #toast-container { right: 10px; left: 10px; max-width: 100%; }
}
@media (max-width: 480px) {
  .data-table th:nth-child(n+5),
  .data-table td:nth-child(n+5) { display: none; }
}
