/* ============================================================
   AI Smart BioLink — Global CSS (works WITH Tailwind CDN)
   ============================================================ */

/* Theme variables */
:root,
[data-theme="dark"] {
  --primary: #6366f1;
  --primary-dk: #4f46e5;
  --bg: #07070e;
  --surface: #0f0f1a;
  --surface2: #181828;
  --border: #1e1e32;
  --text: #e2e8f0;
  --muted: #64748b;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
}
[data-theme="light"] {
  --primary: #6366f1;
  --primary-dk: #4f46e5;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

* { font-family: 'Sora', sans-serif; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); min-height: 100vh; transition: background 0.2s, color 0.2s; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

.mono { font-family: 'JetBrains Mono', monospace !important; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }

/* Form controls */
.form-input {
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 10px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  font-size: 14px;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--primary) !important; }
.form-input::placeholder { color: var(--muted); }

/* Buttons */
.btn-primary-custom {
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  font-size: 14px;
  text-decoration: none;
}
.btn-primary-custom:hover { background: var(--primary-dk); transform: translateY(-1px); }

/* Sidebar */
.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 links */
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.nav-link:hover, .nav-link.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}
.nav-link i { width: 16px; text-align: center; }
.nav-section {
  padding: 12px 14px 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.5;
}

/* Mobile topbar */
.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;
  backdrop-filter: blur(10px);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 195;
  backdrop-filter: blur(2px);
}

/* Badge */
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  max-width: 300px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.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;
  max-height: 90vh;
  overflow-y: auto;
}

/* PIN inputs */
.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;
}
.pin-box:focus, .pin-box.has-val { border-color: var(--primary); }

/* Toggle switch */
.toggle-switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 11px;
  transition: 0.2s;
  cursor: pointer;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: 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: 7px;
  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;
  transition: all 0.15s;
  width: 100%;
  font-family: 'Sora', sans-serif;
}
.theme-toggle-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 11px 16px;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  background: var(--surface2);
  white-space: nowrap;
}
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: rgba(99,102,241,0.03); }
.data-table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ======================= RESPONSIVE ======================= */
@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; }
  .data-table th:nth-child(n+5), .data-table td:nth-child(n+5) { display: none; }
  .hide-sm { display: none !important; }
  .pin-box { width: 38px; height: 46px; font-size: 18px; }
  .pin-row { gap: 5px; }
}
@media (max-width: 480px) {
  .data-table th:nth-child(n+4), .data-table td:nth-child(n+4) { display: none; }
  #toast-container { right: 10px; left: 10px; }
  .toast { max-width: 100%; }
}
