/* =====================================================
   LAB MANAGEMENT SYSTEM — CORE STYLESHEET
   Theme: auto light/dark via prefers-color-scheme
   Override: data-theme="light|dark" on <html> takes priority
   ===================================================== */

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Light theme (default) */
  --bg-body: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f8f9fc;
  --bg-sidebar: #131a2c;
  --text-primary: #1c2333;
  --text-secondary: #667085;
  --text-inverse: #ffffff;
  --border-color: #e6e9f0;
  --border-strong: #d3d8e2;

  --brand-50: #eef4ff;
  --brand-100: #dbe6ff;
  --brand-500: #3a5ce8;
  --brand-600: #2f4bd0;
  --brand-700: #263ea8;

  --success: #17a673;
  --success-bg: #e6f8f1;
  --warning: #f0a83c;
  --warning-bg: #fdf3e2;
  --danger: #e5484d;
  --danger-bg: #fdeaea;
  --info: #3b9edb;
  --info-bg: #e7f4fc;

  --shadow-sm: 0 1px 2px rgba(20, 24, 40, 0.06);
  --shadow-md: 0 4px 14px rgba(20, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 24, 40, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --sidebar-width: 260px;
  --topbar-height: 64px;
}

/* Dark theme — auto via OS preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-body: #0e1220;
    --bg-surface: #161c2d;
    --bg-surface-alt: #1c2337;
    --bg-sidebar: #0b0f1a;
    --text-primary: #e7eaf3;
    --text-secondary: #9aa3b8;
    --text-inverse: #0e1220;
    --border-color: #262e45;
    --border-strong: #333d59;

    --brand-50: #1a2140;
    --brand-100: #212a4d;
    --brand-500: #5c7cf5;
    --brand-600: #7690f7;
    --brand-700: #93a8f9;

    --success-bg: #113328;
    --warning-bg: #35280f;
    --danger-bg: #3a1618;
    --info-bg: #10283a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

/* Manual override classes (set by theme toggle JS on <html>) */
[data-theme="dark"] {
  --bg-body: #0e1220;
  --bg-surface: #161c2d;
  --bg-surface-alt: #1c2337;
  --bg-sidebar: #0b0f1a;
  --text-primary: #e7eaf3;
  --text-secondary: #9aa3b8;
  --text-inverse: #0e1220;
  --border-color: #262e45;
  --border-strong: #333d59;
  --brand-50: #1a2140;
  --brand-100: #212a4d;
  --brand-500: #5c7cf5;
  --brand-600: #7690f7;
  --brand-700: #93a8f9;
  --success-bg: #113328;
  --warning-bg: #35280f;
  --danger-bg: #3a1618;
  --info-bg: #10283a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-body: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f8f9fc;
  --bg-sidebar: #131a2c;
  --text-primary: #1c2333;
  --text-secondary: #667085;
  --text-inverse: #ffffff;
  --border-color: #e6e9f0;
  --border-strong: #d3d8e2;
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.55;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: var(--brand-500); text-decoration: none; }
a:hover { color: var(--brand-600); }

h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; margin: 0 0 8px; }

.text-muted { color: var(--text-secondary); }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.app-content { padding: 24px; flex: 1; }

@media (max-width: 991px) {
  .app-main { margin-left: 0; }
}

/* ---------- Card ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-main);
  font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--brand-500); color: #fff; }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-surface-alt); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-surface-alt); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* ---------- Auth pages (login/register) ---------- */
.auth-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--bg-surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 40px 36px; position: relative;
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo img { height: 52px; }
.auth-logo h1 { font-size: 19px; margin-top: 10px; }
.auth-card .form-group { margin-bottom: 18px; }
.theme-toggle-fixed {
  position: fixed; top: 20px; right: 20px; z-index: 50;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-primary); }
.form-control, select.form-control, textarea.form-control {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-primary);
  font-size: 14px; font-family: var(--font-main);
}
.form-control:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.input-icon-wrap { position: relative; }
.input-icon-wrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }
.input-icon-wrap .form-control { padding-left: 36px; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border-color); }
table.data-table { width: 100%; border-collapse: collapse; background: var(--bg-surface); }
table.data-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-secondary); background: var(--bg-surface-alt);
  padding: 12px 16px; border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
table.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-color); font-size: 13.5px; }
table.data-table tbody tr:hover { background: var(--bg-surface-alt); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.alert-danger  { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: var(--info); }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-sm); }
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; }
.stat-card .stat-label { color: var(--text-secondary); font-size: 13px; }

/* ---------- Theme toggle switch ---------- */
.theme-switch { display: flex; align-items: center; gap: 8px; background: var(--bg-surface-alt); border: 1px solid var(--border-color); border-radius: 20px; padding: 4px; }
.theme-switch button {
  border: none; background: transparent; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary);
}
.theme-switch button.active { background: var(--brand-500); color: #fff; }

/* ---------- Utility ---------- */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
