/* =====================================================================
   ALLIANCE FRANÇAISE ACCRA — DESIGN SYSTEM
   Mobile-first. Tokens → Base → Layout → Components → Utilities.
   ===================================================================== */

/* ---------------------------------------------------------------
   1. DESIGN TOKENS
   --------------------------------------------------------------- */
:root {
    /* Brand */
    --af-red:         #C82032;
    --af-red-hover:   #B01B2C;
    --af-red-soft:    #FBE9EB;

    /* Neutrals */
    --white:          #FFFFFF;
    --bg-soft:        #F7F7F8;
    --bg-elevated:    #FFFFFF;
    --ink:            #171717;
    --ink-muted:      #737373;
    --border:         #E8E8EB;
    --border-strong:  #D4D4D8;

    /* Status */
    --success:        #16845B;
    --success-soft:   #E7F5EE;
    --warning:        #D28B25;
    --warning-soft:   #FBF3E2;
    --danger:         #B91C1C;
    --danger-soft:    #FBEAEA;
    --info:           #0369A1;
    --info-soft:      #E5F2FA;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;

    --fs-xs: 0.75rem;   /* 12 */
    --fs-sm: 0.8125rem; /* 13 */
    --fs-base: 0.9375rem; /* 15 */
    --fs-md: 1rem;      /* 16 */
    --fs-lg: 1.125rem;  /* 18 */
    --fs-xl: 1.375rem;  /* 22 */
    --fs-2xl: 1.75rem;  /* 28 */
    --fs-3xl: 2.25rem;  /* 36 */

    --lh-tight: 1.25;
    --lh-base: 1.5;

    /* Spacing scale (4px base) */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;
    --sp-16: 4rem;

    /* Radius */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --r-full: 999px;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(15, 15, 20, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 15, 20, 0.08);
    --shadow-lg: 0 10px 30px rgba(15, 15, 20, 0.12);

    /* Motion */
    --t-fast: 120ms ease;
    --t-base: 200ms ease;

    /* Layout */
    --sidebar-w: 248px;
    --topbar-h: 60px;
    --container-max: 1240px;
}

/* ---------------------------------------------------------------
   2. RESET / BASE
   --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--ink);
    background: var(--bg-soft);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 600;
    line-height: var(--lh-tight);
    color: var(--ink);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--sp-4); }

a { color: var(--af-red); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--af-red-hover); }

img { max-width: 100%; display: block; }

button { font-family: inherit; }

.serif { font-family: var(--font-serif); }

/* ---------------------------------------------------------------
   3. LAYOUT SHELL
   --------------------------------------------------------------- */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    background: var(--bg-soft);
}

@media (min-width: 1024px) {
    .app-shell {
        grid-template-columns: var(--sidebar-w) 1fr;
    }
}

/* Sidebar */
.sidebar {
    display: none;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: var(--sp-6) 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
@media (min-width: 1024px) {
    .sidebar { display: block; }
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-6) var(--sp-6);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-4);
}
.sidebar__brand img {
    width: 36px; height: 36px; object-fit: contain;
    border-radius: var(--r-sm);
}
.sidebar__brand-text {
    display: flex; flex-direction: column; line-height: 1.15;
}
.sidebar__brand-title { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.sidebar__brand-sub { font-size: var(--fs-xs); color: var(--ink-muted); letter-spacing: 0.02em; }

.sidebar__group { padding: var(--sp-2) 0; }
.sidebar__label {
    padding: 0 var(--sp-6) var(--sp-2);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-6);
    color: var(--ink-muted);
    font-size: var(--fs-base);
    border-left: 3px solid transparent;
    transition: all var(--t-fast);
}
.sidebar__link:hover {
    background: var(--bg-soft);
    color: var(--ink);
}
.sidebar__link.is-active {
    color: var(--af-red);
    background: var(--af-red-soft);
    border-left-color: var(--af-red);
    font-weight: 600;
}
.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Main content area */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    height: var(--topbar-h);
    padding: 0 var(--sp-4);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}
@media (min-width: 1024px) {
    .topbar { padding: 0 var(--sp-8); }
}

.topbar__left, .topbar__right {
    display: flex; align-items: center; gap: var(--sp-3);
}
.topbar__title { font-size: var(--fs-md); font-weight: 600; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--r-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-muted);
    cursor: pointer;
    transition: all var(--t-fast);
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid var(--af-red); outline-offset: 2px; }

/* Avatar */
.avatar {
    width: 36px; height: 36px; border-radius: var(--r-full);
    background: var(--af-red-soft);
    color: var(--af-red);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: var(--fs-sm);
    flex-shrink: 0;
}

/* Page container */
.page {
    padding: var(--sp-4);
    max-width: var(--container-max);
    width: 100%;
    margin: 0 auto;
    flex: 1;
}
@media (min-width: 768px) {
    .page { padding: var(--sp-6) var(--sp-8); }
}
@media (min-width: 1024px) {
    .page { padding: var(--sp-8); }
}

.page__header {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
}
@media (min-width: 640px) {
    .page__header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}
.page__title { font-size: var(--fs-2xl); font-weight: 600; }
.page__subtitle { color: var(--ink-muted); font-size: var(--fs-base); margin-top: var(--sp-1); }

/* Mobile nav overlay */
.mobile-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 15, 20, 0.45);
    z-index: 40;
}
.mobile-overlay.is-open { display: block; }

.drawer {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 82vw);
    background: var(--white);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    display: flex; flex-direction: column;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.drawer.is-open { transform: translateX(0); }

.drawer__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-4) var(--sp-6);
    border-bottom: 1px solid var(--border);
}
@media (min-width: 1024px) {
    .drawer, .mobile-overlay { display: none !important; }
}

/* ---------------------------------------------------------------
   4. BUTTONS
   --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    height: 42px;
    padding: 0 var(--sp-4);
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-size: var(--fs-base);
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: all var(--t-fast);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    touch-action: manipulation;
}
.btn:focus-visible { outline: 2px solid var(--af-red); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn svg { width: 16px; height: 16px; }

.btn--primary {
    background: var(--af-red);
    color: var(--white);
    border-color: var(--af-red);
}
.btn--primary:hover { background: var(--af-red-hover); border-color: var(--af-red-hover); color: var(--white); }

.btn--secondary {
    background: var(--white);
    color: var(--ink);
    border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--bg-soft); }

.btn--ghost {
    background: transparent;
    color: var(--ink-muted);
    border-color: transparent;
}
.btn--ghost:hover { background: var(--bg-soft); color: var(--ink); }

.btn--danger {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}
.btn--danger:hover { background: #9f1414; border-color: #9f1414; }

.btn--sm { height: 34px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { height: 48px; padding: 0 var(--sp-6); font-size: var(--fs-md); }
.btn--block { width: 100%; }

/* ---------------------------------------------------------------
   5. FORMS
   --------------------------------------------------------------- */
.field { margin-bottom: var(--sp-4); }
.field__label {
    display: block;
    margin-bottom: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--ink);
}
.field__label .req { color: var(--af-red); }
.field__hint { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--ink-muted); }
.field__error { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--danger); }

.input,
.select,
.textarea {
    width: 100%;
    min-height: 42px;
    padding: 0 var(--sp-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--white);
    color: var(--ink);
    font-family: inherit;
    font-size: var(--fs-md); /* prevents iOS zoom */
    line-height: 1.4;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { padding: var(--sp-3); min-height: 100px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--af-red);
    box-shadow: 0 0 0 3px var(--af-red-soft);
}
.input:disabled, .select:disabled, .textarea:disabled {
    background: var(--bg-soft); cursor: not-allowed;
}
.input--error { border-color: var(--danger); }

.checkbox-row {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    padding: var(--sp-3) 0;
}
.checkbox-row input[type="checkbox"] {
    width: 20px; height: 20px; margin-top: 1px; flex-shrink: 0;
    accent-color: var(--af-red);
}
.checkbox-row label { font-size: var(--fs-base); }

/* ---------------------------------------------------------------
   6. CARDS
   --------------------------------------------------------------- */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-4);
    box-shadow: var(--shadow-sm);
}
@media (min-width: 768px) {
    .card { padding: var(--sp-6); }
}
.card--flat { box-shadow: none; }
.card__head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.card__title { font-size: var(--fs-md); font-weight: 600; }
.card__subtitle { font-size: var(--fs-sm); color: var(--ink-muted); margin-top: 2px; }

/* Stat card */
.stat-grid {
    display: grid;
    gap: var(--sp-3);
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-4);
}
.stat__label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-muted);
    margin-bottom: var(--sp-2);
}
.stat__value {
    font-size: var(--fs-2xl);
    font-weight: 600;
    color: var(--ink);
    line-height: 1;
}
.stat__change {
    font-size: var(--fs-xs);
    color: var(--ink-muted);
    margin-top: var(--sp-2);
}
.stat__change.is-up { color: var(--success); }
.stat__change.is-down { color: var(--danger); }

/* ---------------------------------------------------------------
   7. BADGES
   --------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: var(--fs-xs);
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}
.badge--neutral { background: var(--bg-soft); color: var(--ink-muted); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); }
.badge--info    { background: var(--info-soft); color: var(--info); }
.badge--brand   { background: var(--af-red-soft); color: var(--af-red); }

/* ---------------------------------------------------------------
   8. TABLES
   --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
}
.table th {
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}
.table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-soft); }

/* Mobile card-style table (transform rows to cards under 640px) */
@media (max-width: 640px) {
    .table--responsive thead { display: none; }
    .table--responsive, .table--responsive tbody, .table--responsive tr, .table--responsive td {
        display: block; width: 100%;
    }
    .table--responsive tr {
        background: var(--white);
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        margin-bottom: var(--sp-3);
        padding: var(--sp-3);
    }
    .table--responsive td {
        border: none; padding: var(--sp-1) 0;
        display: flex; justify-content: space-between; gap: var(--sp-3);
    }
    .table--responsive td::before {
        content: attr(data-label);
        font-size: var(--fs-xs);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--ink-muted);
        font-weight: 500;
    }
}

/* ---------------------------------------------------------------
   9. EMPTY STATE
   --------------------------------------------------------------- */
.empty-state {
    padding: var(--sp-10) var(--sp-4);
    text-align: center;
}
.empty-state__icon {
    width: 56px; height: 56px;
    margin: 0 auto var(--sp-4);
    border-radius: var(--r-full);
    background: var(--bg-soft);
    display: flex; align-items: center; justify-content: center;
    color: var(--ink-muted);
}
.empty-state__title { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--sp-2); }
.empty-state__text { color: var(--ink-muted); margin-bottom: var(--sp-4); max-width: 40ch; margin-left: auto; margin-right: auto; }

/* ---------------------------------------------------------------
   10. ALERTS & FLASH
   --------------------------------------------------------------- */
.flash-stack {
    position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: 100;
    display: flex; flex-direction: column; gap: var(--sp-2);
    max-width: 380px; width: calc(100% - 2 * var(--sp-4));
}
.flash {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--white);
    border-radius: var(--r-md);
    border-left: 4px solid var(--ink-muted);
    box-shadow: var(--shadow-md);
    font-size: var(--fs-sm);
    animation: flash-in var(--t-base);
}
.flash--success { border-left-color: var(--success); }
.flash--warning { border-left-color: var(--warning); }
.flash--danger  { border-left-color: var(--danger); }
.flash--info    { border-left-color: var(--info); }

@keyframes flash-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------
   11. MODAL
   --------------------------------------------------------------- */
.modal {
    position: fixed; inset: 0; z-index: 200;
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: rgba(15, 15, 20, 0.45);
    padding: var(--sp-4);
}
.modal.is-open { display: flex; }
@media (min-width: 640px) {
    .modal { align-items: center; }
}

.modal__panel {
    background: var(--white);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modal-in var(--t-base);
}
@media (min-width: 640px) {
    .modal__panel { border-radius: var(--r-lg); }
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-4) var(--sp-6);
    border-bottom: 1px solid var(--border);
}
.modal__body { padding: var(--sp-6); overflow-y: auto; flex: 1; }
.modal__foot {
    display: flex; justify-content: flex-end; gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------
   12. AUTH LAYOUT
   --------------------------------------------------------------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    background: var(--bg-soft);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(200, 32, 50, 0.04), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(200, 32, 50, 0.03), transparent 40%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: var(--r-xl);
    padding: var(--sp-8) var(--sp-6);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
@media (min-width: 480px) {
    .auth-card { padding: var(--sp-10) var(--sp-8); }
}

.auth-brand {
    text-align: center;
    margin-bottom: var(--sp-8);
}
.auth-brand__logo {
    width: 56px; height: 56px; margin: 0 auto var(--sp-3);
    border-radius: var(--r-md);
    object-fit: contain;
}
.auth-brand__title {
    font-family: var(--font-serif);
    font-size: var(--fs-xl);
    color: var(--ink);
    margin-bottom: var(--sp-1);
}
.auth-brand__sub {
    font-size: var(--fs-sm);
    color: var(--ink-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-links {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: var(--sp-4);
    font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------
   13. UTILITIES
   --------------------------------------------------------------- */
.u-text-muted { color: var(--ink-muted); }
.u-text-sm { font-size: var(--fs-sm); }
.u-text-xs { font-size: var(--fs-xs); }
.u-text-center { text-align: center; }
.u-text-right { text-align: right; }
.u-mt-0 { margin-top: 0; }
.u-mt-2 { margin-top: var(--sp-2); }
.u-mt-4 { margin-top: var(--sp-4); }
.u-mt-6 { margin-top: var(--sp-6); }
.u-mb-0 { margin-bottom: 0; }
.u-mb-2 { margin-bottom: var(--sp-2); }
.u-mb-4 { margin-bottom: var(--sp-4); }
.u-mb-6 { margin-bottom: var(--sp-6); }
.u-flex { display: flex; }
.u-flex-col { flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-2 { gap: var(--sp-2); }
.u-gap-3 { gap: var(--sp-3); }
.u-gap-4 { gap: var(--sp-4); }
.u-hidden { display: none !important; }
.u-w-full { width: 100%; }

@media (min-width: 640px) {
    .sm\:u-flex { display: flex; }
    .sm\:u-hidden { display: none !important; }
}

/* Print */
@media print {
    .sidebar, .topbar, .drawer, .mobile-overlay, .flash-stack, .btn { display: none !important; }
    .app-shell { display: block; }
    .page { padding: 0; max-width: none; }
}

/* ---------------------------------------------------------------
   14. EVENT SUB-NAVIGATION
   --------------------------------------------------------------- */
.event-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    margin: 0 0 var(--sp-6);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.event-nav::-webkit-scrollbar { display: none; }

.event-nav__link {
    padding: 10px 14px;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--ink-muted);
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--t-fast), border-color var(--t-fast);
}
.event-nav__link:hover { color: var(--ink); }
.event-nav__link.is-active {
    color: var(--af-red);
    border-bottom-color: var(--af-red);
    font-weight: 600;
}

/* ---------------------------------------------------------------
   15. RESPONSIVE VISIBILITY
   --------------------------------------------------------------- */
.icon-btn--mobile-only {
    display: inline-flex;
}
@media (min-width: 1024px) {
    .icon-btn--mobile-only {
        display: none !important;
    }
}

/* Ensure the drawer nav renders even though .sidebar is display:none on mobile */
.drawer nav .sidebar__link {
    color: var(--ink-muted);
}
.drawer nav .sidebar__link.is-active {
    color: var(--af-red);
    background: var(--af-red-soft);
    border-left-color: var(--af-red);
}