/* Campus Vehicle Monitoring — Salient-inspired design system.
   Lexend (display) + Inter (body), blue-600 primary, slate neutrals,
   rounded-full buttons, soft rounded cards. Zero build, self-hosted. */

@import url("../fonts.css");

:root {
    --font-display: "Lexend", ui-sans-serif, system-ui, sans-serif;
    --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;

    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;

    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --emerald-50: #ecfdf5;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --amber-50: #fffbeb;
    --amber-500: #f59e0b;
    --amber-700: #b45309;
    --red-50: #fef2f2;
    --red-600: #dc2626;
    --red-700: #b91c1c;

    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.25rem;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 20px -8px rgba(15, 23, 42, 0.12), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
    --ring: 0 0 0 1px var(--slate-200);

    /* Semantic surface (card/nav/input background). Flips in dark mode. */
    --surface: #ffffff;
    color-scheme: light;
}

/* ---- dark theme -------------------------------------------------------------
   Token-level theming: the component rules below reference the palette vars, so
   redefining the vars here flips the whole UI. The dark token set is applied
   both from the OS preference (unless the user forced light) and under an
   explicit data-theme="dark". The two blocks are kept identical. */
:root[data-theme="dark"] {
    --blue-50:  #16233d;
    --blue-100: #1e3a5f;
    --blue-500: #60a5fa;
    --blue-600: #3b82f6;
    --blue-700: #93c5fd;

    --slate-50:  #0e1729;
    --slate-100: #1b2740;
    --slate-200: #2a3854;
    --slate-300: #3a4a68;
    --slate-400: #6b7890;
    --slate-500: #93a0b6;
    --slate-600: #aeb9cc;
    --slate-700: #c7d0de;
    --slate-800: #dde3ec;
    --slate-900: #f1f5f9;

    --emerald-50:  rgba(16, 185, 129, 0.14);
    --emerald-600: #34d399;
    --emerald-700: #6ee7b7;
    --amber-50:  rgba(245, 158, 11, 0.15);
    --amber-500: #fbbf24;
    --amber-700: #fcd34d;
    --red-50:  rgba(239, 68, 68, 0.15);
    --red-600: #f87171;
    --red-700: #fca5a5;

    --surface: #16223c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 14px 28px -10px rgba(0, 0, 0, 0.6), 0 4px 10px -4px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --blue-50:  #16233d;
        --blue-100: #1e3a5f;
        --blue-500: #60a5fa;
        --blue-600: #3b82f6;
        --blue-700: #93c5fd;

        --slate-50:  #0e1729;
        --slate-100: #1b2740;
        --slate-200: #2a3854;
        --slate-300: #3a4a68;
        --slate-400: #6b7890;
        --slate-500: #93a0b6;
        --slate-600: #aeb9cc;
        --slate-700: #c7d0de;
        --slate-800: #dde3ec;
        --slate-900: #f1f5f9;

        --emerald-50:  rgba(16, 185, 129, 0.14);
        --emerald-600: #34d399;
        --emerald-700: #6ee7b7;
        --amber-50:  rgba(245, 158, 11, 0.15);
        --amber-500: #fbbf24;
        --amber-700: #fcd34d;
        --red-50:  rgba(239, 68, 68, 0.15);
        --red-600: #f87171;
        --red-700: #fca5a5;

        --surface: #16223c;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 14px 28px -10px rgba(0, 0, 0, 0.6), 0 4px 10px -4px rgba(0, 0, 0, 0.4);
        color-scheme: dark;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    color: var(--slate-700);
    background: var(--slate-50);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    color: var(--slate-900);
    line-height: 1.15;
    letter-spacing: -0.015em;
    margin: 0 0 0.5rem;
}

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }

a {
    color: var(--blue-600);
    text-decoration: none;
}
a:hover { color: var(--blue-700); text-decoration: underline; }

/* ---- layout ---- */
.container {
    width: 100%;
    max-width: 76rem;
    margin: 0 auto;
    padding: 0 1.25rem;
}
.container-narrow { max-width: 44rem; }

main { padding: 2rem 0 3.5rem; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.page-head .subtitle { color: var(--slate-500); margin: 0; }

/* ---- top nav ---- */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--slate-200);
    position: sticky;
    top: 0;
    z-index: 40;
}
.nav-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 4rem;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--slate-900);
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--slate-900); }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    background: var(--blue-600);
    color: #fff;
    font-size: 1rem;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}
.nav-links a {
    color: var(--slate-600);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.45rem 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
}
.nav-links a:hover { color: var(--slate-900); background: var(--slate-100); text-decoration: none; }
.nav-links a.active { color: var(--blue-700); background: var(--blue-50); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.nav-user { color: var(--slate-500); font-size: 0.85rem; white-space: nowrap; }
.nav-toggle { display: none; }

/* theme toggle */
.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    border: 1px solid var(--slate-300);
    background: var(--surface);
    color: var(--slate-600);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: background-color .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--slate-900); border-color: var(--slate-400); }
.theme-toggle:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: inline; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .ico-sun { display: inline; }
    :root:not([data-theme="light"]) .theme-toggle .ico-moon { display: none; }
}

/* ---- buttons (rounded-full, Salient) ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1;
    padding: 0.6rem 1.1rem;
    border-radius: 9999px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color .15s, color .15s, box-shadow .15s, border-color .15s;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); color: #fff; }
.btn-dark { background: #0f172a; color: #fff; }
.btn-dark:hover { background: #1e293b; color: #fff; }
.btn-outline { background: var(--surface); color: var(--slate-700); border-color: var(--slate-300); box-shadow: var(--shadow-sm); }
.btn-outline:hover { background: var(--slate-50); color: var(--slate-900); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: var(--red-700); color: #fff; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---- cards ---- */
.card {
    background: var(--surface);
    border-radius: var(--radius-2xl);
    box-shadow: var(--ring), var(--shadow);
    padding: 1.5rem;
}
.card + .card { margin-top: 1.25rem; }
.card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    color: var(--slate-900);
    margin: 0 0 1rem;
}

/* ---- stat tiles (dashboard) ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--ring), var(--shadow);
    padding: 1.25rem 1.35rem;
    position: relative;
    overflow: hidden;
}
.stat .label { color: var(--slate-500); font-size: 0.8rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--slate-900); margin-top: 0.25rem; line-height: 1; }
.stat .accent { position: absolute; inset: 0 auto 0 0; width: 4px; }
.stat.stat-total .accent { background: var(--blue-600); }
.stat.stat-active .accent { background: var(--emerald-600); }
.stat.stat-expiring .accent { background: var(--amber-500); }
.stat.stat-expired .accent { background: var(--red-600); }

/* ---- badges (pills) ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    line-height: 1.3;
    white-space: nowrap;
}
.badge-success { background: var(--emerald-50); color: var(--emerald-700); }
.badge-warning { background: var(--amber-50); color: var(--amber-700); }
.badge-danger { background: var(--red-50); color: var(--red-700); }
.badge-muted { background: var(--slate-100); color: var(--slate-600); }
.badge-role { background: var(--blue-50); color: var(--blue-700); text-transform: capitalize; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-xl); box-shadow: var(--ring); background: var(--surface); }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
table.data th {
    text-align: left;
    font-weight: 600;
    color: var(--slate-500);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--slate-200);
    background: var(--slate-50);
    white-space: nowrap;
}
table.data td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--slate-50); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
.code-pill { font-family: ui-monospace, Menlo, monospace; font-weight: 600; color: var(--slate-900); background: var(--slate-100); padding: 0.15rem 0.5rem; border-radius: 0.4rem; font-size: 0.8rem; }

/* ---- forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.1rem 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--slate-700); }
.form-label .req { color: var(--red-600); }
.form-hint { font-size: 0.78rem; color: var(--slate-500); }
.form-input, .form-select, .form-textarea {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--slate-900);
    background: var(--surface);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-lg);
    padding: 0.55rem 0.75rem;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px var(--blue-100);
}
.form-textarea { min-height: 5rem; resize: vertical; }
input[type="file"].form-input { padding: 0.4rem 0.55rem; }
input[type="file"]::file-selector-button {
    font-family: var(--font-sans); font-weight: 600; font-size: 0.8rem;
    border: 1px solid var(--slate-300); background: var(--surface); color: var(--slate-700);
    border-radius: 9999px; padding: 0.35rem 0.75rem; margin-right: 0.75rem; cursor: pointer;
}
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* ---- flash / alerts ---- */
.alert { border-radius: var(--radius-lg); padding: 0.8rem 1rem; font-size: 0.88rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--emerald-50); color: var(--emerald-700); border-color: color-mix(in srgb, var(--emerald-600) 32%, transparent); }
.alert-danger { background: var(--red-50); color: var(--red-700); border-color: color-mix(in srgb, var(--red-600) 32%, transparent); }
.alert-info { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-100); }
.alert-warning { background: var(--amber-50); color: var(--amber-700); border-color: color-mix(in srgb, var(--amber-500) 32%, transparent); }

/* ---- login ---- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1.25rem; background:
    radial-gradient(60rem 30rem at 50% -10rem, var(--blue-50), transparent),
    var(--slate-50); }
.auth-card { width: 100%; max-width: 24rem; background: var(--surface); border-radius: var(--radius-2xl); box-shadow: var(--ring), var(--shadow-md); padding: 2rem; }
.auth-brand { display: flex; align-items: center; gap: 0.6rem; justify-content: center; margin-bottom: 1.25rem; }
.auth-brand .brand-mark { width: 2.4rem; height: 2.4rem; font-size: 1.2rem; }

/* ---- detail / definition lists ---- */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.5rem; }
.detail-item .dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate-500); font-weight: 600; }
.detail-item .dd { color: var(--slate-800); margin-top: 0.15rem; }
.detail-item.full { grid-column: 1 / -1; }

/* ---- file thumbnails ---- */
.thumbs { display: flex; flex-wrap: wrap; gap: 1rem; }
.thumb { width: 9rem; }
.thumb img { width: 100%; height: 7rem; object-fit: cover; border-radius: var(--radius-lg); box-shadow: var(--ring); background: var(--slate-100); }
.thumb .cap { font-size: 0.75rem; color: var(--slate-500); margin-top: 0.35rem; display: flex; justify-content: space-between; gap: 0.5rem; }
.doc-link { display: inline-flex; align-items: center; gap: 0.4rem; }

/* ---- toolbar (search/filter) ---- */
.toolbar { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.toolbar form { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.toolbar .form-input, .toolbar .form-select { width: auto; }
.toolbar .search { min-width: 16rem; }
.spacer { flex: 1; }

/* ---- pagination ---- */
.pager { display: flex; gap: 0.4rem; justify-content: center; margin-top: 1.5rem; align-items: center; }
.pager a, .pager span { padding: 0.4rem 0.75rem; border-radius: 0.5rem; font-size: 0.85rem; color: var(--slate-600); }
.pager a:hover { background: var(--slate-100); text-decoration: none; }
.pager .current { background: var(--blue-600); color: #fff; }
.pager .disabled { color: var(--slate-300); }

.muted { color: var(--slate-500); }
.text-danger { color: var(--red-700); }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.inline-form { display: inline; }

/* ---- gate pass ---- */
.gatepass {
    max-width: 22rem;
    margin: 1.5rem auto;
    border-radius: var(--radius-2xl);
    overflow: hidden;
    box-shadow: var(--ring), var(--shadow-md);
    background: var(--surface);
}
.gatepass .gp-head { background: #0f172a; color: #fff; padding: 1rem 1.25rem; display: flex; align-items: center; gap: 0.6rem; }
.gatepass .gp-head .brand-mark { background: var(--blue-600); }
.gatepass .gp-head .t { font-family: var(--font-display); font-weight: 700; line-height: 1.1; }
.gatepass .gp-body { padding: 1.25rem; }
.gatepass .gp-code { font-family: var(--font-display); font-weight: 800; font-size: 2rem; letter-spacing: 0.02em; color: var(--slate-900); text-align: center; }
.gatepass .gp-rows { margin-top: 1rem; display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; font-size: 0.9rem; }
.gatepass .gp-rows dt { color: var(--slate-500); font-weight: 600; }
.gatepass .gp-rows dd { margin: 0; color: var(--slate-900); text-align: right; }
.gatepass .gp-foot { text-align: center; padding: 0.75rem; border-top: 1px dashed var(--slate-300); font-size: 0.8rem; }

/* ---- responsive ---- */
@media (max-width: 860px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .nav-links, .nav-user { display: none; }
    .nav-inner.open { height: auto; flex-wrap: wrap; padding-bottom: 1rem; }
    .nav-inner.open .nav-links { display: flex; flex-direction: column; align-items: stretch; width: 100%; order: 3; gap: 0.15rem; }
    .nav-inner.open .nav-user { display: block; }
    .nav-toggle { display: inline-grid; place-items: center; margin-left: auto; width: 2.4rem; height: 2.4rem; border: 1px solid var(--slate-300); border-radius: 0.5rem; background: var(--surface); cursor: pointer; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---- print (gate pass) ---- */
@media print {
    .nav, .form-actions, .no-print { display: none !important; }
    body { background: #fff; }
    main { padding: 0; }
    .gatepass { box-shadow: none; border: 1px solid var(--slate-300); margin: 0; }
}
