/* ── KLTE Africa Academy — Global Styles ── */

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

:root {
    --primary:      #1a3a5c;
    --primary-dark: #122840;
    --accent:       #e85d04;
    --accent-dark:  #c44d03;
    --success:      #276749;
    --danger:       #c53030;
    --warning:      #b7791f;
    --bg:           #f0f4f8;
    --surface:      #ffffff;
    --border:       #d1dde8;
    --text:         #1a202c;
    --text-muted:   #5a7184;
    --sidebar-w:    240px;
    --header-h:     64px;
    --radius:       8px;
    --shadow:       0 2px 8px rgba(0,0,0,.10);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sidebar-logo img {
    height: 42px;
    width: auto;
    object-fit: contain;
}

.sidebar-logo-text {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.sidebar-user {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    font-size: 13px;
    color: rgba(255,255,255,.75);
}

.sidebar-user strong {
    display: block;
    color: #fff;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav { flex: 1; padding: 10px 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: rgba(255,255,255,.82);
    text-decoration: none;
    font-size: 14px;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: var(--accent);
}

.sidebar-nav .nav-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.45);
    padding: 14px 20px 4px;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.12);
}

.sidebar-footer form { margin: 0; }

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: var(--radius);
    color: rgba(255,255,255,.85);
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}

.btn-logout:hover { background: rgba(232,93,4,.35); color: #fff; }

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.page-content { padding: 28px; flex: 1; }

/* ── Cards & Panels ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2 { font-size: 16px; font-weight: 600; color: var(--primary); }
.card-body { padding: 20px; }

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity .15s, background .15s;
    white-space: nowrap;
}

.btn:hover { opacity: .88; }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-accent    { background: var(--accent);   color: #fff; }
.btn-success   { background: var(--success);  color: #fff; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-outline   { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-sm        { padding: 6px 12px; font-size: 13px; }
.btn-lg        { padding: 12px 28px; font-size: 16px; }
.btn-block     { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }

.form-control {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,58,92,.12);
}

.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: 12px; color: var(--danger); margin-top: 4px; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th {
    background: #f7fafd;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid #eef2f6;
    vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #f7fafd; }

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    border-left: 4px solid;
}

.alert-success { background: #f0faf4; border-color: var(--success); color: #1a4731; }
.alert-danger  { background: #fff5f5; border-color: var(--danger);  color: #742a2a; }
.alert-warning { background: #fffbeb; border-color: var(--warning); color: #744210; }
.alert-info    { background: #ebf8ff; border-color: #2b6cb0;        color: #1a365d; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-passed   { background: #d1fae5; color: #064e3b; }
.badge-failed   { background: #fee2e2; color: #7f1d1d; }
.badge-primary  { background: #dbeafe; color: #1e3a8a; }

/* ── Progress bar ── */
.progress {
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin: 6px 0;
}

.progress-bar {
    height: 100%;
    background: var(--success);
    border-radius: 999px;
    transition: width .4s ease;
}

/* ── Guest (login) layout ── */
.guest-page {
    min-height: 100vh;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.guest-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.guest-header {
    background: var(--primary-dark);
    padding: 28px 32px 24px;
    text-align: center;
}

.guest-header img { height: 56px; width: auto; object-fit: contain; margin-bottom: 10px; }

.guest-header h2 {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.guest-header p { color: rgba(255,255,255,.65); font-size: 13px; }

.guest-body { padding: 28px 32px 32px; }

/* ── Utilities ── */
.flex          { display: flex; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.gap-2         { gap: 8px; }
.gap-3         { gap: 12px; }
.mt-1          { margin-top: 4px; }
.mt-2          { margin-top: 8px; }
.mt-3          { margin-top: 16px; }
.mt-4          { margin-top: 24px; }
.mb-3          { margin-bottom: 16px; }
.mb-4          { margin-bottom: 24px; }
.text-muted    { color: var(--text-muted); font-size: 13px; }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.text-center   { text-align: center; }
.font-bold     { font-weight: 700; }
.w-full        { width: 100%; }
.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; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .page-content { padding: 16px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }

    .topbar {
        padding: 0 16px;
        justify-content: space-between;
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px; height: 36px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--primary);
        font-size: 20px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 99;
    }

    .sidebar-overlay.open { display: block; }
}

@media (min-width: 769px) {
    .menu-toggle,
    .sidebar-overlay { display: none; }
}
