/* =========================================================================
   LabTrack LIMS — stylesheet
   Uses only system fonts so the app renders identically online or fully
   offline (no CDN / Google Fonts dependency).
   ========================================================================= */

:root {
    --color-primary: #0B6E6E;
    --color-primary-dark: #084F4F;
    --color-primary-light: #E4F2F1;
    --color-bg: #F5F7F7;
    --color-surface: #FFFFFF;
    --color-border: #E2E8E8;
    --color-text: #1F2937;
    --color-text-muted: #6B7280;
    --color-amber: #B45309;
    --color-amber-bg: #FEF3E2;
    --color-green: #15803D;
    --color-green-bg: #E7F6EC;
    --color-red: #B91C1C;
    --color-red-bg: #FCEAEA;
    --color-blue: #1D4ED8;
    --color-blue-bg: #E8EEFC;
    --color-gray-bg: #EEF1F1;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "Courier New", monospace;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 42, 42, 0.06);
    --shadow-md: 0 4px 14px rgba(15, 42, 42, 0.08);
    --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }

.mono { font-family: var(--font-mono); }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-primary-dark);
    color: #E4F2F1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #62D6C0;
    box-shadow: 0 0 0 3px rgba(98,214,192,0.25);
}

.sidebar nav { padding: 12px 10px; flex: 1; overflow-y: auto; }

.sidebar .nav-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8FC3BC;
    padding: 14px 10px 6px;
}

.sidebar a.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: #D7ECE9;
    font-size: 13.5px;
    margin-bottom: 2px;
}

.sidebar a.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.9; }
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.sidebar a.nav-link.active { background: var(--color-primary); color: #fff; font-weight: 600; }

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 12.5px;
}
.sidebar-user .name { color: #fff; font-weight: 600; display: block; }
.sidebar-user .role { color: #8FC3BC; }
.sidebar-user a { color: #B9E4DC; font-size: 12px; }

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar .page-title { font-size: 19px; font-weight: 650; }
.topbar .page-subtitle { color: var(--color-text-muted); font-size: 12.5px; margin-top: 2px; }

.scan-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--color-gray-bg);
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 7px 14px;
    transition: border-color 0.15s;
}
.scan-box:focus-within { border-color: var(--color-primary); background: #fff; }
.scan-box svg { width: 15px; height: 15px; color: var(--color-text-muted); flex-shrink: 0; }
.scan-box input {
    border: none; background: transparent; padding: 0; width: 190px;
    font-size: 13px; color: var(--color-text);
}
.scan-box input:focus { outline: none; box-shadow: none; }

.content { padding: 24px; flex: 1; }

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { color: var(--color-text-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--color-primary-dark); }
.stat-card .stat-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

.stat-card-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}
.stat-card-icon svg { width: 20px; height: 20px; }
.stat-icon-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }
.stat-icon-blue { background: var(--color-blue-bg); color: var(--color-blue); }
.stat-icon-amber { background: var(--color-amber-bg); color: var(--color-amber); }
.stat-icon-red { background: var(--color-red-bg); color: var(--color-red); }
.stat-icon-green { background: var(--color-green-bg); color: var(--color-green); }

.welcome-banner {
    position: relative;
    overflow: hidden;
    display: flex; align-items: center; justify-content: space-between;
    background:
        radial-gradient(rgba(255,255,255,0.09) 1.5px, transparent 1.5px) 0 0 / 20px 20px,
        linear-gradient(120deg, var(--color-primary-dark), var(--color-primary) 55%, var(--color-primary-dark));
    color: #fff; border-radius: var(--radius); padding: 26px 30px; margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}
.welcome-banner::before {
    content: ''; position: absolute; top: -70px; right: -50px;
    width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,0.07);
}
.welcome-banner::after {
    content: ''; position: absolute; bottom: -90px; right: 140px;
    width: 170px; height: 170px; border-radius: 50%; background: rgba(255,255,255,0.05);
}
.welcome-banner-content, .welcome-banner-actions { position: relative; z-index: 1; }
.welcome-banner-content { display: flex; align-items: center; gap: 14px; }
.welcome-banner h2 { color: #fff; font-size: 21px; margin: 0 0 4px; }
.welcome-banner p { color: rgba(255,255,255,0.85); margin: 0; font-size: 13px; }
.welcome-banner img { height: 42px; width: 42px; object-fit: contain; background: #fff; border-radius: 9px; padding: 5px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.dashboard-footer {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px;
    margin-top: 8px; padding: 20px 4px 4px;
    border-top: 1px solid var(--color-border);
}
.dashboard-footer-brand { display: flex; align-items: center; gap: 10px; }
.dashboard-footer-brand img { height: 26px; width: 26px; object-fit: contain; border-radius: 6px; border: 1px solid var(--color-border); padding: 2px; background: #fff; }
.dashboard-footer-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-primary); display: inline-block; }
.dashboard-footer-meta { font-size: 12px; color: var(--color-text-muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dashboard-footer-meta .divider-dot { opacity: 0.5; }

.priority-mix { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin: 10px 0 6px; background: var(--color-gray-bg); }
.priority-mix span { height: 100%; }
.priority-legend { display: flex; gap: 14px; font-size: 12px; color: var(--color-text-muted); flex-wrap: wrap; }
.priority-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: 13.5px; vertical-align: middle; }
th { color: var(--color-text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; background: #FAFBFB; }
tbody tr:hover { background: #FAFDFD; }
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius); }
.table-wrap table { border: none; }
.table-wrap .table-wrap { border: none; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=datetime-local], input[type=tel], input[type=search],
select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #D7DEDE;
    border-radius: 6px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
textarea { resize: vertical; min-height: 70px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    background: var(--color-gray-bg);
    color: var(--color-text);
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger { background: var(--color-red-bg); color: var(--color-red); }
.btn-outline { background: transparent; border-color: #D7DEDE; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 650;
    white-space: nowrap;
}
.badge-gray  { background: var(--color-gray-bg); color: #4B5563; }
.badge-blue  { background: var(--color-blue-bg); color: var(--color-blue); }
.badge-amber { background: var(--color-amber-bg); color: var(--color-amber); }
.badge-green { background: var(--color-green-bg); color: var(--color-green); }
.badge-red   { background: var(--color-red-bg); color: var(--color-red); }

/* ---------- Alerts / flash messages ---------- */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.alert-success { background: var(--color-green-bg); color: var(--color-green); border-color: #BFE6CC; }
.alert-error   { background: var(--color-red-bg); color: var(--color-red); border-color: #F3C6C6; }
.alert-info    { background: var(--color-blue-bg); color: var(--color-blue); border-color: #C6D6F5; }

/* ---------- Page load progress bar ---------- */
#page-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0%;
    background: var(--color-primary); z-index: 9999; opacity: 0;
    transition: width 0.4s ease, opacity 0.2s ease;
}
#page-progress.active { opacity: 1; width: 80%; }

/* ---------- Toast notifications ---------- */
.toast-container {
    position: fixed; top: 18px; right: 18px; z-index: 9998;
    display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
    box-shadow: var(--shadow-md);
    animation: toast-in 0.25s ease;
    padding-right: 34px; position: relative;
}
.toast-close {
    position: absolute; top: 8px; right: 10px; background: none; border: none;
    font-size: 16px; line-height: 1; cursor: pointer; color: inherit; opacity: 0.6;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Button loading spinner ---------- */
.spinner {
    display: inline-block; width: 13px; height: 13px;
    border: 2px solid rgba(0,0,0,0.15); border-top-color: currentColor;
    border-radius: 50%; animation: spin 0.6s linear infinite;
    vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Field-level validation ---------- */
.field-invalid { border-color: var(--color-red) !important; box-shadow: 0 0 0 3px var(--color-red-bg) !important; }
.field-error-msg { color: var(--color-red); font-size: 12px; margin-top: 4px; }

/* ---------- Mobile hamburger + sidebar drawer ---------- */
.hamburger {
    display: none; background: none; border: none; padding: 4px; cursor: pointer; color: var(--color-text);
}
.hamburger svg { width: 22px; height: 22px; }
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(8,20,20,0.45); z-index: 39;
}
/* ---------- Misc ---------- */
.text-muted { color: var(--color-text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }
.empty-state svg { opacity: 0.4; margin-bottom: 10px; }

.login-screen, .denied-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--color-primary-dark), var(--color-primary) 60%, #0E8080);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 36px;
    width: 100%;
    max-width: 380px;
}
.login-card .brand { display:flex; align-items:center; gap:10px; margin-bottom: 22px; }
.login-card .brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--color-primary); }
.login-card .brand span { font-size: 19px; font-weight: 700; color: var(--color-primary-dark); }

.denied-screen { color: #fff; text-align: center; flex-direction: column; }
.denied-screen .btn { margin-top: 14px; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

.pill-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pill-nav a { padding: 6px 14px; border-radius: 20px; background: var(--color-gray-bg); color: var(--color-text); font-size: 13px; font-weight: 600; }
.pill-nav a.active { background: var(--color-primary); color: #fff; }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

.divider { height: 1px; background: var(--color-border); margin: 18px 0; border: none; }

.low-stock-row { background: var(--color-red-bg) !important; }

/* Printable lab report */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .content { padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border: none; }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; z-index: 40;
        transform: translateX(-100%); transition: transform 0.25s ease;
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-overlay { display: block; }
    .hamburger { display: inline-flex; }
    .no-mobile { display: none; }
    .scan-box input { width: 120px; }
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .form-row { grid-template-columns: 1fr; }
    .toast-container { left: 12px; right: 12px; max-width: none; top: 12px; }
}
