/*
 * Smartschool SmartExam — Licence & Update Server
 * Developer: Smart Creativity Digital Hub
 * Email:     Smartcreativitydigitalhub@gmail.com | Support@smartschool.sch.ng
 * Website:   https://smartschool.sch.ng
 *
 * File:    admin/assets/style.css
 * Purpose: Stylesheet for the Super Admin panel. Pure CSS, no build step.
 *          Theme: soft violet + pink "sweet" UI, rounded shapes.
 *          Desktop: gradient sidebar + light content area.
 *          Mobile: sticky top bar, fixed bottom navigation, and a
 *          slide-in drawer (opened from "More") holding the full menu.
 *
 * @license Proprietary – do not redistribute without permission.
 */

/* ---------- Variables ---------- */
:root {
    --bg:        #f6f4ff;
    --surface:   #ffffff;
    --surface-2: #faf8ff;
    --text:      #2b2a4c;
    --muted:     #8482a6;
    --border:    #ebe8fa;

    --primary:   #7c5cff;
    --primary-2: #6544f0;
    --primary-soft: #ede8ff;
    --accent:    #ff7eb6;
    --accent-soft: #ffe4f0;

    --success:   #22c58b;
    --warning:   #f5a524;
    --danger:    #f0476c;
    --info:      #38a9f5;

    --sidebar-from: #3b2a8f;
    --sidebar-to:   #6b46d9;

    --radius:    16px;
    --radius-sm: 12px;
    --shadow:    0 2px 4px rgba(90,70,190,.05), 0 8px 24px rgba(90,70,190,.08);
    --shadow-lg: 0 10px 40px rgba(90,70,190,.18);

    --topbar-h:  58px;
    --bottomnav-h: 58px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
    font-family: ui-rounded, "SF Pro Rounded", "Nunito", -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    background-image:
        radial-gradient(600px 300px at 100% 0%, rgba(255,126,182,.12), transparent 70%),
        radial-gradient(600px 300px at 0% 100%, rgba(124,92,255,.10), transparent 70%);
    background-attachment: fixed;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.55;
    overflow-x: hidden;
}
img, video { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid rgba(124,92,255,.45); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.25; }

/* Icons: always a fixed small size, never stretch. */
.ico { width: 20px; height: 20px; min-width: 20px; flex: 0 0 20px; display: block; }

/* ---------- Auth (login) layout ---------- */
.auth-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(160deg, #ede8ff 0%, #ffe4f0 100%);
}
.auth-card {
    background: var(--surface);
    padding: 36px 28px;
    width: 100%;
    max-width: 400px;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.auth-card h1 { margin: 0 0 6px 0; font-size: 24px; font-weight: 700; }
.auth-card .sub { color: var(--muted); margin: 0 0 24px 0; font-size: 14px; }
.auth-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-card .brand-mark {
    width: 46px; height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: grid; place-items: center;
    font-weight: 800; font-size: 20px;
    box-shadow: 0 6px 16px rgba(124,92,255,.35);
}

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
    background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to));
    color: #e4dcff;
    width: 250px;
    flex: 0 0 250px;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
}
.sidebar .brand {
    padding: 4px 8px 18px 8px;
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
}
.sidebar .brand-mark {
    width: 34px; height: 34px;
    border-radius: 11px;
    background: linear-gradient(135deg, #fff, #ffd3e8);
    color: var(--primary-2);
    display: grid; place-items: center;
    font-size: 16px; font-weight: 800;
}
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    margin-bottom: 2px;
    color: #e4dcff;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 12px;
    transition: background .15s, color .15s;
}
.sidebar nav a .ico { width: 20px; height: 20px; opacity: .9; }
.sidebar nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.sidebar nav a.active {
    background: #fff;
    color: var(--primary-2);
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(20,10,80,.25);
}
.sidebar nav .nav-section {
    padding: 18px 12px 6px 12px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .6px;
    color: #b7a8f5;
}
.sidebar .sidebar-foot {
    margin-top: auto;
    padding: 14px 12px 0 12px;
    border-top: 1px solid rgba(255,255,255,.18);
    font-size: 13px;
    color: #cfc3fa;
}
.sidebar .sidebar-foot .who { color: #fff; font-weight: 600; margin-bottom: 6px; word-break: break-all; }
.sidebar .sidebar-foot a { color: #ffd3e8; font-weight: 500; }
.sidebar-close { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,.82);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.topbar .title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .actions { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); flex: 0 0 auto; }

.content { padding: 24px; max-width: 1200px; width: 100%; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
    min-width: 0;
}
.card h2 { margin: 0 0 14px 0; font-size: 16px; font-weight: 700; }
.card h3 { margin: 0 0 10px 0; font-size: 14.5px; font-weight: 600; }

/* ---------- KPI grid ---------- */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
}
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.kpi .value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1; }
.kpi .delta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.accent-primary .value { color: var(--primary); }
.kpi.accent-success .value { color: var(--success); }
.kpi.accent-warning .value { color: var(--warning); }
.kpi.accent-danger  .value { color: var(--danger);  }
.kpi.accent-info    .value { color: var(--info);    }
.kpi.accent-success::before { background: var(--success); }
.kpi.accent-warning::before { background: var(--warning); }
.kpi.accent-danger::before  { background: var(--danger); }
.kpi.accent-info::before    { background: var(--info); }

/* ---------- Tables ---------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: left;
    padding: 11px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    font-size: 12.5px;
    white-space: nowrap;
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child  { border-top-right-radius: 10px; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
code, .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12.5px;
}
code {
    background: var(--primary-soft);
    color: var(--primary-2);
    padding: 2px 7px;
    border-radius: 8px;
    word-break: break-all;
}

/* ---------- Forms ---------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-row .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], input[type="search"],
input[type="tel"], input[type="url"], select, textarea {
    width: 100%;
    padding: 11px 14px;
    min-height: 44px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px; /* 16px stops iOS zooming on focus */
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124,92,255,.15);
}
textarea { min-height: 96px; resize: vertical; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 18px;
    min-height: 44px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    border: 1.5px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    font-family: inherit;
    transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #9a6bff);
    color: #fff;
    box-shadow: 0 6px 16px rgba(124,92,255,.35);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; }
.btn-secondary { background: #fff; color: var(--primary-2); border-color: var(--border); }
.btn-secondary:hover { background: var(--primary-soft); color: var(--primary-2); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #ff7a8f); color: #fff; box-shadow: 0 6px 16px rgba(240,71,108,.3); }
.btn-danger:hover { color: #fff; filter: brightness(.95); }
.btn-sm { padding: 7px 13px; min-height: 34px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 999px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}
.badge-success { background: #d9f7ea; color: #0c7a55; }
.badge-warning { background: #fff0d1; color: #9a6205; }
.badge-danger  { background: #ffe1e8; color: #b0243f; }
.badge-info    { background: #dff1ff; color: #14669f; }
.badge-muted   { background: #eeecf8; color: #5f5d85; }

/* ---------- Notices ---------- */
.notice {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid;
    word-break: break-word;
}
.notice-success { background: #e9fbf3; border-color: #b7efd6; color: #0c7a55; }
.notice-warning { background: #fff8e6; border-color: #ffe1a3; color: #9a6205; }
.notice-danger  { background: #fff0f3; border-color: #ffc6d2; color: #b0243f; }
.notice-info    { background: #eef7ff; border-color: #c4e4ff; color: #14669f; }

/* ---------- Empty state ---------- */
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* ---------- Utility ---------- */
.row      { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.row.gap-sm { gap: 8px; }
.grow     { flex: 1; min-width: 0; }
.muted    { color: var(--muted); }
.small    { font-size: 12.5px; }
.mt-0     { margin-top: 0; }
.mt-1     { margin-top: 8px; }
.mt-2     { margin-top: 16px; }
.mt-3     { margin-top: 24px; }
.mb-0     { margin-bottom: 0; }
.mb-1     { margin-bottom: 8px; }
.mb-2     { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap   { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---------- Mobile-only controls (hidden on desktop) ---------- */
.menu-toggle { display: none; }
.sidebar-backdrop { display: none; }
.bottom-nav { display: none; }

/* ---------- Tablet & phone (<= 900px) ---------- */
@media (max-width: 900px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }

    /* Sidebar becomes a slide-in drawer. */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        height: auto;
        width: min(300px, 84vw);
        flex: none;
        z-index: 120;
        transform: translateX(-100%);
        transition: transform .25s ease;
        padding-top: calc(20px + var(--safe-t));
        padding-bottom: calc(20px + var(--safe-b));
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close {
        display: grid; place-items: center;
        position: absolute; top: calc(12px + var(--safe-t)); right: 12px;
        width: 36px; height: 36px;
        border-radius: 50%;
        border: none; background: rgba(255,255,255,.16); color: #fff;
        font-size: 20px; line-height: 1; cursor: pointer;
    }
    .sidebar-backdrop {
        position: fixed; inset: 0;
        background: rgba(30,20,80,.45);
        -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
        z-index: 110;
        opacity: 0; pointer-events: none;
        transition: opacity .25s;
        display: block;
    }
    .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

    .menu-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 40px; height: 40px;
        border-radius: 12px;
        border: 1.5px solid var(--border);
        background: #fff;
        cursor: pointer; padding: 0; margin-right: 4px; flex: 0 0 auto;
    }
    .menu-toggle span,
    .menu-toggle span::before,
    .menu-toggle span::after {
        display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--primary-2);
    }
    .menu-toggle span { position: relative; }
    .menu-toggle span::before, .menu-toggle span::after { content: ""; position: absolute; left: 0; }
    .menu-toggle span::before { top: -6px; }
    .menu-toggle span::after  { top:  6px; }

    .topbar { padding: 8px 14px; padding-top: calc(8px + var(--safe-t)); }
    .topbar .title { font-size: 17px; }
    .content { padding: 16px; padding-bottom: calc(var(--bottomnav-h) + var(--safe-b) + 24px); }

    /* Bottom navigation */
    .bottom-nav {
        position: fixed;
        left: 12px; right: 12px;
        bottom: calc(8px + var(--safe-b));
        height: var(--bottomnav-h);
        z-index: 100;
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        background: rgba(255,255,255,.92);
        -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
        border: 1px solid var(--border);
        border-radius: 20px;
        box-shadow: var(--shadow-lg);
        padding: 5px;
    }
    .bottom-nav a, .bottom-nav button {
        flex: 1;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        border: none; background: none; font-family: inherit;
        color: var(--muted);
        font-size: 10.5px; font-weight: 600; line-height: 1.1;
        border-radius: 14px;
        text-decoration: none;
        cursor: pointer;
        padding: 0;
        transition: background .15s, color .15s;
    }
    .bottom-nav .ico { width: 20px; height: 20px; min-width: 20px; flex: 0 0 20px; margin: 0 auto; }
    .bottom-nav a.active, .bottom-nav button.active {
        color: var(--primary-2);
        background: var(--primary-soft);
    }
}

/* ---------- Phone (<= 640px) ---------- */
@media (max-width: 640px) {
    body { font-size: 15px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi { padding: 14px 14px 14px 18px; }
    .kpi .value { font-size: 22px; }

    .card { padding: 16px; border-radius: 14px; margin-bottom: 16px; }
    .auth-card { padding: 28px 20px; border-radius: 20px; }

    /* Stack action rows; buttons become full-width tap targets. */
    .row { gap: 10px; }
    form .row > .btn, .card > .btn:not(.btn-sm), form > .btn:not(.btn-sm) { width: 100%; }
    .topbar .actions .muted { display: none; }
    .truncate { max-width: 160px; }

    /* Opt-in: <table class="table-stack"> turns rows into cards. */
    table.table-stack, table.table-stack tbody, table.table-stack tr, table.table-stack td { display: block; width: 100%; }
    table.table-stack thead { display: none; }
    table.table-stack tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 6px 12px;
        margin-bottom: 12px;
        background: var(--surface);
    }
    table.table-stack td {
        display: flex; justify-content: space-between; gap: 14px;
        padding: 9px 0; text-align: right; word-break: break-word;
        border-bottom: 1px dashed var(--border);
    }
    table.table-stack td:last-child { border-bottom: none; }
    table.table-stack td::before {
        content: attr(data-label);
        font-weight: 600; color: var(--muted); text-align: left; flex: 0 0 38%;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .kpis { grid-template-columns: 1fr; }
    .bottom-nav a, .bottom-nav button { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}