/* ============================================================
   Serengeti Care LMS — Design System
   Style: Clean & professional (healthcare/training)
   ============================================================ */

:root {
    /* Brand palette — Serengeti Care sage green */
    --primary: #7a9d7e;          /* sage green (logo) */
    --primary-dark: #5c7d60;     /* deeper sage */
    --primary-light: #eef3ec;    /* pale sage */
    --accent: #9aba9d;           /* lighter sage accent */
    --success: #2f8a4e;
    --warning: #c98012;
    --danger: #c8463b;

    /* Neutrals */
    --ink-900: #0f1b22;
    --ink-700: #2a3a44;
    --ink-500: #56697a;
    --ink-300: #9aa9b6;
    --ink-100: #e6ecf1;
    --bg: #f5f8fa;
    --surface: #ffffff;
    --border: #dde6ec;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 27, 34, 0.06);
    --shadow: 0 4px 14px rgba(15, 27, 34, 0.08);
    --shadow-lg: 0 14px 40px rgba(15, 27, 34, 0.12);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink-900);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Layout shell ---------- */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--ink-900);
    color: #e6ecf1;
    padding: 22px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 17px;
    color: #fff;
    margin-bottom: 28px;
}
.brand .logo {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: grid; place-items: center;
    color: #fff; font-weight: 800;
}
.brand small { display: block; font-weight: 400; color: #9aa9b6; font-size: 11px; letter-spacing: .04em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #c8d3dc; font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .divider { height: 1px; background: rgba(255,255,255,.08); margin: 14px 0; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f8294; padding: 0 12px; margin-bottom: 6px; }

.main { padding: 0; }

/* ---------- Topbar ---------- */
.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky; top: 0; z-index: 10;
}
.topbar .crumbs { color: var(--ink-500); font-size: 13px; }
.topbar .crumbs strong { color: var(--ink-900); font-weight: 600; }
.topbar .user {
    display: flex; align-items: center; gap: 12px;
    font-size: 14px;
}
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c9d8f, #0f6e7e);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 600;
    font-size: 13px;
}

.content { padding: 28px 32px 60px; max-width: 1280px; }

/* ---------- Headings ---------- */
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 600; }
.subtitle { color: var(--ink-500); margin-top: 4px; }

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

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-900);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all .15s ease;
}
.btn:hover { border-color: var(--ink-300); }
.btn-primary {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; }
.btn-primary:disabled,
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---------- Badges / tags ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--ink-100);
    color: var(--ink-700);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: #e3f4e9; color: #1d6b37; }
.badge-warn { background: #fdf1dc; color: #8a5409; }
.badge-locked { background: #f0f2f4; color: var(--ink-500); }
.badge-progress { background: var(--primary-light); color: var(--primary-dark); }

/* ---------- Progress ---------- */
.progress {
    width: 100%;
    height: 8px;
    background: var(--ink-100);
    border-radius: 999px;
    overflow: hidden;
}
.progress > span {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: inherit;
    transition: width .3s ease;
}
.progress.lg { height: 12px; }

/* ---------- Notice / banner ---------- */
.notice {
    border-left: 4px solid var(--primary);
    background: var(--primary-light);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    color: var(--ink-700);
    font-size: 14px;
}
.notice.warn { border-color: var(--warning); background: #fdf6e7; }
.notice.danger { border-color: var(--danger); background: #fbe9e7; }
.notice.success { border-color: var(--success); background: #e3f4e9; }

/* ---------- Forms ---------- */
input[type="text"], input[type="email"], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: #fff;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,110,126,0.15);
}
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--ink-700); }
.helper { font-size: 12px; color: var(--ink-500); margin-top: 6px; }

/* ---------- Utility ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.muted { color: var(--ink-500); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.bold { font-weight: 600; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* Lock icon */
.lock::before { content: "🔒 "; }

/* ---------- User menu (header right) ---------- */
.user-menu { position: relative; }
.user-trigger {
    display: flex; align-items: center; gap: 12px;
    background: transparent; border: none; cursor: pointer;
    padding: 4px 6px; border-radius: var(--radius-sm);
}
.user-trigger:hover { background: var(--bg); }
.user-dropdown {
    display: none;
    position: absolute;
    top: 110%;
    right: 0;
    width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 100;
}
.user-dropdown.open { display: block; }
.user-dropdown .dd-head { display: flex; gap: 12px; align-items: center; padding: 8px 8px 12px; }
.user-dropdown .dd-item {
    display: block;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-700);
    font-size: 14px;
    text-decoration: none;
}
.user-dropdown .dd-item:hover { background: var(--bg); text-decoration: none; }
.user-dropdown .dd-item.danger { color: var(--danger); }
.user-dropdown .dd-divider { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- Login screen ---------- */
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.login-art {
    background: linear-gradient(135deg, #094f5b 0%, #0f6e7e 50%, #2c9d8f 100%);
    color: #fff;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.login-art .brand { color: #fff; font-size: 18px; }
.login-art .pitch h2 { font-size: 32px; letter-spacing: -0.01em; }
.login-art .pitch p { opacity: .9; margin-top: 12px; max-width: 480px; font-size: 16px; line-height: 1.55; }
.login-art .ftrs { display: flex; flex-direction: column; gap: 14px; margin-top: 32px; }
.login-art .ftr { display: flex; gap: 12px; align-items: flex-start; }
.login-art .ftr-i {
    width: 32px; height: 32px;
    background: rgba(255,255,255,.16);
    border-radius: 8px;
    display: grid; place-items: center;
    flex-shrink: 0;
    font-size: 16px;
}
.login-art .ftr p { margin: 0; opacity: .9; font-size: 14px; }
.login-art .ftr strong { color: #fff; font-size: 14px; }

.login-form {
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--surface);
}
.login-form h1 { font-size: 24px; }
.login-form .helper-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-top: 20px;
    font-size: 12px;
    color: var(--ink-500);
    border: 1px dashed var(--border);
}
.login-form .helper-card .demo-row {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    align-items: center;
    font-variant-numeric: tabular-nums;
}
.login-form .helper-card .demo-row.head { font-weight: 600; color: var(--ink-700); border-top: none; }
.login-form .helper-card .demo-row button {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 500;
}
.login-form .helper-card .demo-row button:hover { background: var(--primary); color: #fff; }

@media (max-width: 900px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-art { padding: 32px 24px; }
    .login-form { padding: 32px 24px; }
}

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 12px; }
.activity-feed .item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border);
}
.activity-feed .item:last-child { border-bottom: none; }
.activity-feed .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); margin-top: 7px; flex-shrink: 0;
}

/* Data table (admin / instructor) */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
    text-align: left; padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); font-weight: 600; background: var(--bg); }
.table tbody tr:hover { background: #f9fcfd; }
.table .who { display: flex; gap: 10px; align-items: center; }
.table .who .avatar { width: 32px; height: 32px; font-size: 12px; }
.table .progress { width: 120px; }
.table .stack { display: flex; flex-direction: column; }
.table .stack .text-xs { color: var(--ink-500); }

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; }
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.stat-tile .label { font-size: 12px; color: var(--ink-500); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-tile .value { font-size: 26px; font-weight: 700; color: var(--ink-900); margin-top: 4px; line-height: 1.1; }
.stat-tile .delta { font-size: 12px; color: var(--success); margin-top: 4px; }
.stat-tile .delta.neg { color: var(--danger); }

/* Hide legacy preview banner if still present */
.preview-banner {
    background: linear-gradient(90deg, #0f6e7e, #2c9d8f);
    color: #fff;
    padding: 8px 18px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.preview-banner a { color: #fff; text-decoration: underline; }

/* ============================================================
   RESPONSIVE BREAKPOINTS
   --------------------------------------------------------------
   1200px — large tablet / small desktop
    900px — tablet
    640px — phone
   ============================================================ */

/* Tablet & small desktop */
@media (max-width: 1200px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 24px 22px 60px; }
}

/* Mobile drawer trigger (hidden by default) */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-700);
}
.menu-toggle:hover { background: var(--bg); }

/* Backdrop when sidebar is open on mobile */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,27,34,.45);
    z-index: 89;
}
.sidebar-backdrop.open { display: block; }

/* Tablet */
@media (max-width: 1100px) {
    .app { grid-template-columns: 220px 1fr; }
    .content { padding: 20px 20px 60px; }
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }
    .topbar { padding: 0 18px; }

    /* Hero on dashboard collapses to single column */
    .hero { grid-template-columns: 1fr !important; gap: 16px !important; padding: 22px 24px !important; }
}

/* Tablet portrait — sidebar becomes a drawer */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        width: 240px;
        z-index: 90;
        transition: left .25s ease;
        overflow-y: auto;
    }
    .sidebar.open { left: 0; }
    .menu-toggle { display: inline-flex; align-items: center; gap: 4px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    .topbar { padding: 0 14px; }
    .topbar .crumbs { font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* User trigger collapses to avatar only */
    .user-trigger span { display: none; }

    /* Tables — give them a horizontal scroll container */
    .table { font-size: 13px; }
    .table th, .table td { padding: 10px 10px; }

    /* Modals occupy full width */
    .modal { max-width: calc(100vw - 24px) !important; margin: 12px; padding: 18px 18px; }
}

/* Phone */
@media (max-width: 640px) {
    h1 { font-size: 20px; }
    h2 { font-size: 17px; }
    .content { padding: 16px 14px 48px; }
    .topbar { height: 56px; padding: 0 12px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-tile { padding: 14px 14px; }
    .stat-tile .value { font-size: 22px; }
    .field-row, .field-row.thirds { grid-template-columns: 1fr !important; gap: 10px !important; }

    /* Buttons full-width by default on phone */
    .quiz-actions, .slide-nav { flex-direction: column; gap: 12px; align-items: stretch; }
    .quiz-actions > *, .slide-nav > * { width: 100%; }
    .quiz-actions .flex, .slide-nav .flex { width: 100%; justify-content: space-between; }

    /* Cards/panels compact padding */
    .card-pad, .panel { padding: 16px 16px !important; }

    /* User dropdown slimmer */
    .user-dropdown { width: 260px; right: -8px; }

    /* Sidebar fills width on small phone */
    .sidebar { width: 80%; max-width: 280px; }

    /* Hero buttons stack */
    .hero-left .cta-row .btn { width: 100%; justify-content: center; }
}

/* Make tables horizontally scrollable when wrapped in .table-scroll */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 600px; }

/* Visually-hidden helper for a11y */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0;
    margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}
