/* ============================================================
   Gilbert Moving & Storage — Training Platform
   Dark-mode-friendly, responsive, accessible base styles.
   ============================================================ */

:root {
    --brand: #c8461e;
    --brand-ink: #ffffff;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f0f1f4;
    --text: #1a1a2e;
    --muted: #5c6472;
    --border: #e3e6ec;
    --ring: #c8461e55;
    --ok: #1f9d55;
    --ok-bg: #e6f6ec;
    --err: #c0392b;
    --err-bg: #fbeae8;
    --info-bg: #eaf1fb;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(20, 22, 40, 0.08);
    --maxw: 1040px;
}

:root[data-theme="dark"],
html[data-theme="dark"] {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1e222d;
    --text: #eef0f5;
    --muted: #9aa3b2;
    --border: #2a2f3b;
    --ok-bg: #12321f;
    --err-bg: #3a1a17;
    --info-bg: #16233a;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1117;
        --surface: #171a23;
        --surface-2: #1e222d;
        --text: #eef0f5;
        --muted: #9aa3b2;
        --border: #2a2f3b;
        --ok-bg: #12321f;
        --err-bg: #3a1a17;
        --info-bg: #16233a;
        --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--brand); }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand);
    color: #fff;
    padding: 10px 16px;
    border-radius: 0 0 8px 0;
    z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---- Top bar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand__logo {
    height: 40px;
    width: auto;
    max-width: 200px;
    display: block;
    border-radius: 4px;
}
.brand__name { font-weight: 700; font-size: 15px; }
@media (max-width: 560px) { .brand__name { display: none; } }

.theme-toggle {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    width: 40px; height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition: transform .15s ease, background .2s ease;
}
.theme-toggle:hover { transform: rotate(-12deg); }
.theme-toggle:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* ---- Layout ---- */
.main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 28px 20px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }

.page { display: block; }
.page--center { display: grid; place-items: center; min-height: 60vh; }
.page__title { font-size: clamp(22px, 4vw, 30px); margin: 0 0 12px; }
.muted { color: var(--muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.card--narrow { max-width: 460px; text-align: center; }

/* ---- Auth ---- */
.auth { display: grid; place-items: center; min-height: 66vh; }
.auth__card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 34px 30px;
    animation: rise .4s ease both;
}
.auth__title { margin: 0 0 4px; font-size: 24px; }
.auth__sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.auth__links { margin-top: 18px; text-align: center; font-size: 14px; }

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .auth__card, .flash { animation: none; }
}

/* ---- Forms ---- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field__wrap { position: relative; display: flex; align-items: center; }
.field__input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field__input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--ring);
}
.field__reveal {
    position: absolute;
    right: 6px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 8px;
}
.field__reveal:hover { color: var(--brand); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: transform .12s ease, filter .2s ease, background .2s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn--block { width: 100%; }

/* ---- Notices & flash ---- */
.notice { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.notice--error { background: var(--err-bg); color: var(--err); }

.flash {
    max-width: var(--maxw);
    margin: 16px auto 0;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: var(--shadow);
    animation: rise .3s ease both;
    transition: opacity .5s ease, transform .5s ease;
}
.flash--out { opacity: 0; transform: translateY(-8px); }
.flash--success { background: var(--ok-bg); color: var(--ok); }
.flash--error   { background: var(--err-bg); color: var(--err); }
.flash--info    { background: var(--info-bg); color: var(--text); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
}
.badge--admin { background: var(--info-bg); color: var(--text); }

/* ---- Top nav ---- */
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.topnav a:hover { color: var(--brand); }
.topnav__logout { margin: 0; }
.linkbtn {
    border: none; background: none; cursor: pointer;
    color: var(--muted); font-size: 14px; font-weight: 600; padding: 0; font-family: inherit;
}
.linkbtn:hover { color: var(--brand); }

/* ---- Profile ---- */
.profile-grid {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 760px) {
    .profile-grid { grid-template-columns: 1fr; }
}
.stack { display: grid; gap: 20px; }
.card__title { margin: 0 0 14px; font-size: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-name { font-weight: 700; font-size: 17px; }

.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; object-fit: cover; background: var(--surface-2);
    border: 2px solid var(--border);
}
.avatar--lg { width: 96px; height: 96px; }
.avatar--initials { font-weight: 800; font-size: 30px; color: var(--brand); }

.facts { display: grid; gap: 8px; margin: 22px 0 12px; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.facts dt { color: var(--muted); margin: 0; }
.facts dd { margin: 0; font-weight: 600; }

.notice--pending { background: var(--info-bg); color: var(--text); }

/* ---- Course dashboard / roadmap ---- */
.course-card { margin-bottom: 22px; }
.course-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.course-card__title { margin: 0 0 4px; font-size: 20px; }
.course-card__meta { font-size: 13px; margin: 6px 0 16px; }

.progressbar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 14px; }
.progressbar__fill { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #e2703a); border-radius: 999px; transition: width .5s ease; }

.roadmap { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 10px; }
.roadmap__item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface-2); transition: transform .15s ease, border-color .2s ease;
}
.roadmap__item--unlocked:hover { transform: translateX(3px); border-color: var(--brand); }
.roadmap__item--locked { opacity: .6; }
.roadmap__item--passed { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.roadmap__badge {
    flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 800; font-size: 14px;
    background: var(--surface); border: 1px solid var(--border);
}
.roadmap__item--passed .roadmap__badge { background: var(--ok); color: #fff; border-color: var(--ok); }
.roadmap__body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.roadmap__title { font-weight: 600; }
.roadmap__status { font-size: 13px; color: var(--muted); }
.roadmap__go { font-weight: 600; text-decoration: none; white-space: nowrap; }

/* ---- Day page ---- */
.backlink { display: inline-block; margin-bottom: 10px; font-size: 14px; text-decoration: none; color: var(--muted); }
.backlink:hover { color: var(--brand); }
.card + .card, .card + .lesson, .lesson + .card { margin-top: 20px; }

.banner { padding: 14px 18px; border-radius: 12px; margin-bottom: 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner--ok { background: var(--ok-bg); color: var(--ok); }
.btn--sm { padding: 8px 14px; font-size: 14px; }

.video-wrap { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; background: #000; }
.video-wrap > div, .video-wrap iframe, .video-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.materials { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.materials a { text-decoration: none; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); display: block; }
.materials a:hover { border-color: var(--brand); }
.video-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

.lesson__body { line-height: 1.7; }
.lesson__body h3 { margin: 22px 0 8px; font-size: 17px; }
.lesson__body ul { padding-left: 20px; }
.lesson__body li { margin: 4px 0; }

.quiz-cta { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.center { text-align: center; }

/* ---- Quiz ---- */
.page--quiz { max-width: 760px; }
.quiz { display: grid; gap: 18px; margin-top: 18px; }
.quiz-q { border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin: 0; background: var(--surface); }
.quiz-q__prompt { font-weight: 600; padding: 0; margin-bottom: 12px; }
.quiz-q__num { color: var(--brand); font-weight: 800; }
.quiz-opt {
    display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px;
    border: 1px solid var(--border); margin-top: 8px; cursor: pointer; transition: border-color .15s, background .15s;
}
.quiz-opt:hover { border-color: var(--brand); }
.quiz-opt:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.quiz-opt input { accent-color: var(--brand); width: 18px; height: 18px; }
.quiz-opt__letter { font-weight: 800; color: var(--muted); width: 18px; }
.quiz-submit { display: flex; gap: 10px; margin-top: 6px; }

/* ---- Results ---- */
.result-hero {
    display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
    padding: 26px; border-radius: 16px; margin-bottom: 22px; border: 1px solid var(--border);
    animation: rise .4s ease both;
}
.result-hero--pass { background: var(--ok-bg); }
.result-hero--fail { background: var(--err-bg); }
.result-score { text-align: center; min-width: 120px; }
.result-score__num { display: block; font-size: 44px; font-weight: 800; line-height: 1; }
.result-hero--pass .result-score__num { color: var(--ok); }
.result-hero--fail .result-score__num { color: var(--err); }
.result-score__meta { color: var(--muted); font-size: 14px; }
.result-title { margin: 0 0 4px; font-size: 22px; }

.review-item { border-top: 1px solid var(--border); padding: 16px 0; }
.review-item:first-of-type { border-top: none; }
.review-item__q { font-weight: 600; margin: 0 0 6px; }
.review-item__wrong { color: var(--err); margin: 2px 0; font-size: 14px; }
.review-item__right { color: var(--ok); margin: 2px 0; font-size: 14px; }
.review-item__why { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

/* ---- Admin ---- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-inline .field__input { flex: 1; min-width: 220px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

textarea.field__input { resize: vertical; font: inherit; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table__actions { text-align: right; white-space: nowrap; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.pill--on { background: var(--ok-bg); color: var(--ok); }
.pill--off { background: var(--surface-2); color: var(--muted); }
.pill--blocked { background: var(--err-bg); color: var(--err); }

.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.admin-list__item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.admin-list__badge { flex: 0 0 auto; font-weight: 700; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; }
.admin-list__body { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.opt-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.opt-row input[type=radio] { accent-color: var(--brand); width: 18px; height: 18px; flex: 0 0 auto; }
.opt-row .field__input { flex: 1; }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 4px 0; }
.check input { accent-color: var(--brand); width: 18px; height: 18px; }

.card--danger { border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.btn--danger { background: var(--err); color: #fff; }
.btn--danger:hover { filter: brightness(1.05); }

/* ---- Analytics: stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.stat__num { display: block; font-size: 30px; font-weight: 800; line-height: 1; }
.stat__label { color: var(--muted); font-size: 13px; }

/* ---- Analytics: charts ---- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 820px) { .chart-grid { grid-template-columns: 1fr; } }
.bars { display: grid; gap: 10px; margin-top: 14px; }
.bar-row { display: grid; grid-template-columns: 84px 1fr 44px; align-items: center; gap: 10px; }
.bar-row__label { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row__label--wide { grid-column: auto; }
.bar-row__track { height: 16px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-row__fill { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .5s ease; min-width: 2px; }
.bar-row__value { font-size: 13px; font-weight: 700; text-align: right; }

/* ---- Analytics: fleet table ---- */
.fleet-controls { display: flex; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; }
.fleet-controls .field__input { max-width: 260px; }
.table--sortable th[data-sort]:hover { color: var(--brand); }
.mini-progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; max-width: 140px; margin-bottom: 3px; }
.mini-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #e2703a); border-radius: 999px; }

/* ---- Activity timeline ---- */
.timeline { list-style: none; margin: 14px 0 0; padding: 0; }
.timeline__item { display: flex; gap: 12px; padding: 0 0 14px; position: relative; }
.timeline__item::before {
    content: ""; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--border);
}
.timeline__item:last-child::before { display: none; }
.timeline__dot { flex: 0 0 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); margin-top: 3px; position: relative; z-index: 1; }
.timeline__body { display: flex; flex-direction: column; gap: 1px; }
.timeline__label { font-size: 14px; }
.timeline__when { font-size: 12px; color: var(--muted); }

/* ---- Certificate ---- */
.cert {
    width: 100%;
    max-width: 780px;
    background: #fffef9;
    color: #1a1a2e;
    border: 2px solid #c8461e;
    border-radius: 8px;
    padding: 10px;
    box-shadow: var(--shadow);
}
.cert__inner {
    border: 1px solid #d8b98a;
    border-radius: 6px;
    padding: 44px 40px 36px;
    text-align: center;
    position: relative;
    background:
        radial-gradient(circle at 12% 12%, rgba(200,70,30,.05), transparent 40%),
        radial-gradient(circle at 88% 88%, rgba(200,70,30,.05), transparent 40%);
}
.cert__logo { height: 56px; width: auto; display: block; margin: 0 auto 12px; }
.cert__brand { font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #c8461e; font-size: 14px; }
.cert__kicker { margin-top: 6px; font-size: 13px; letter-spacing: .28em; text-transform: uppercase; color: #8a7a5c; }
.cert__pre { margin: 30px 0 6px; color: #55503f; }
.cert__name {
    font-size: clamp(28px, 6vw, 44px);
    margin: 0 0 14px;
    font-family: Georgia, "Times New Roman", serif;
    color: #1a1a2e;
    border-bottom: 2px solid #e6d3ad;
    display: inline-block;
    padding: 0 20px 8px;
}
.cert__body { max-width: 520px; margin: 8px auto 0; color: #3a3728; line-height: 1.6; }
.cert__meta { display: flex; justify-content: center; gap: 48px; margin: 34px 0 10px; flex-wrap: wrap; }
.cert__meta-block { display: flex; flex-direction: column; gap: 4px; }
.cert__meta-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #8a7a5c; }
.cert__meta-value { font-weight: 700; }
.cert__seal {
    margin: 18px auto 0; width: 62px; height: 62px; border-radius: 50%;
    background: #c8461e; color: #fff; display: grid; place-items: center;
    font-weight: 800; letter-spacing: .04em;
    box-shadow: 0 0 0 5px rgba(200,70,30,.18);
}
.cert__id { margin-top: 14px; font-size: 12px; color: #8a7a5c; }

/* Print: show only the certificate */
@media print {
    .topbar, .footer, .flash, .no-print, .backlink { display: none !important; }
    body { background: #fff; }
    .main { padding: 0; }
    .cert { border: none; box-shadow: none; max-width: 100%; }
}
