/* =============================================================================
   GESTION-CAISSE OUCAMI — Feuille de styles principale
   Esthétique : Industriel/Raffiné — Noir profond + Or chaud
   Polices : Syne (titres) + DM Sans (corps)
============================================================================= */

/* ─── Variables globales ─────────────────────────────────────────────────── */
:root {
    --c-bg:          #0d0f0e;
    --c-surface:     #151918;
    --c-surface-2:   #1e2422;
    --c-border:      #2a302e;
    --c-gold:        #c9a84c;
    --c-gold-light:  #e2c97e;
    --c-text:        #e8ede8;
    --c-text-muted:  #7a8c84;
    --c-recettes:    #2e7d52;
    --c-recettes-bg: #0d2a1c;
    --c-depenses:    #a83232;
    --c-depenses-bg: #2a0d0d;
    --c-warning:     #c97a2c;
    --c-info:        #2c6ac9;

    --font-display: 'Syne', sans-serif;
    --font-body:    'DM Sans', sans-serif;

    --sidebar-w:  260px;
    --topbar-h:   64px;
    --radius:     6px;
    --radius-lg:  12px;

    --shadow-sm:   0 1px 3px rgba(0,0,0,.4);
    --shadow-md:   0 4px 16px rgba(0,0,0,.5);
    --shadow-gold: 0 0 20px rgba(201,168,76,.15);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--c-bg);
    color: var(--c-text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--c-gold); text-decoration: none; transition: color .2s; }
a:hover { color: var(--c-gold-light); }

/* ─── PAGE LOGIN ─────────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    background: var(--c-bg);
    background-image: repeating-linear-gradient(
        45deg,
        transparent, transparent 40px,
        rgba(201,168,76,.03) 40px,
        rgba(201,168,76,.03) 41px
    );
}

.login-box {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-md);
}

.login-box__logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-box__logo .logo-icon {
    display: block;
    font-size: 44px;
    margin-bottom: 12px;
    color: var(--c-gold);
    font-family: var(--font-display);
    font-weight: 800;
}

.login-box__logo .brand {
    display: block;
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    color: var(--c-gold);
    letter-spacing: .15em;
}

.login-box__logo .tagline {
    display: block;
    font-size: 11px;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .2em;
    margin-top: 6px;
}

/* ─── LAYOUT PRINCIPAL (pages avec sidebar) ──────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--c-border);
}

.sidebar__logo {
    font-size: 26px;
    color: var(--c-gold);
    font-family: var(--font-display);
    font-weight: 800;
    line-height: 1;
}

.sidebar__name {
    display: block;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    color: var(--c-gold);
    letter-spacing: .08em;
}

.sidebar__sub {
    display: block;
    font-size: 10px;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .14em;
}

/* Soldes sidebar */
.sidebar__caisses {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--c-border);
}

.sidebar__caisse {
    padding: 10px 14px;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__caisse--recettes {
    background: var(--c-recettes-bg);
    border: 1px solid var(--c-recettes);
}

.sidebar__caisse--depenses {
    background: var(--c-depenses-bg);
    border: 1px solid var(--c-depenses);
}

.sidebar__caisse-label {
    font-size: 10px;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .12em;
}

.sidebar__caisse-montant {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--c-text);
}

/* Navigation */
.sidebar__nav {
    padding: 14px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--c-text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
    position: relative;
}

.sidebar__link:hover,
.sidebar__link.active {
    background: var(--c-surface-2);
    color: var(--c-gold);
}

.sidebar__link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px;
    background: var(--c-gold);
    border-radius: 0 3px 3px 0;
}

.sidebar__icon {
    width: 18px;
    text-align: center;
    font-style: normal;
    flex-shrink: 0;
}

.sidebar__badge {
    margin-left: auto;
    background: var(--c-depenses);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

/* Utilisateur bas de sidebar */
.sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--c-border);
    margin-top: auto;
}

.sidebar__avatar {
    width: 36px; height: 36px;
    background: var(--c-gold);
    color: var(--c-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar__user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__user-role {
    display: block;
    font-size: 11px;
    color: var(--c-text-muted);
    text-transform: capitalize;
}

.sidebar__logout {
    margin-left: auto;
    color: var(--c-text-muted);
    font-size: 18px;
    transition: color .2s;
    line-height: 1;
}
.sidebar__logout:hover { color: var(--c-depenses); }

/* ─── CONTENU PRINCIPAL ──────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-w));
}

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

.topbar__burger {
    display: none;
    background: none;
    border: none;
    color: var(--c-text);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.topbar__title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--c-text);
    flex: 1;
}

.topbar__actions { display: flex; align-items: center; gap: 12px; }

.topbar__notif {
    position: relative;
    font-size: 20px;
    color: var(--c-text-muted);
    transition: color .2s;
    line-height: 1;
}
.topbar__notif:hover { color: var(--c-gold); }

.topbar__notif-badge {
    position: absolute;
    top: -4px; right: -6px;
    background: var(--c-depenses);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* ─── CARTES ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card__header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card__title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--c-gold);
    text-transform: uppercase;
    letter-spacing: .1em;
}

.card__body { padding: 24px; }

/* ─── STAT CARDS (Dashboard) ─────────────────────────────────────────────── */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
}

.stat-card:hover {
    border-color: var(--c-gold);
    box-shadow: var(--shadow-gold);
}

.stat-card__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--c-text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card__label-icon {
    font-size: 14px;
}

.stat-card__value {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    color: var(--c-text);
    line-height: 1.1;
    margin-bottom: 6px;
    word-break: break-all;
}

.stat-card__sub {
    font-size: 12px;
    color: var(--c-text-muted);
}

.stat-card--recettes { border-top: 3px solid var(--c-recettes); }
.stat-card--depenses { border-top: 3px solid var(--c-depenses); }
.stat-card--warning  { border-top: 3px solid var(--c-warning); }
.stat-card--gold     { border-top: 3px solid var(--c-gold); }

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

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

thead th {
    background: var(--c-surface-2);
    color: var(--c-text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--c-border);
}

tbody tr {
    border-bottom: 1px solid var(--c-border);
    transition: background .15s;
}
tbody tr:hover { background: var(--c-surface-2); }

tbody td {
    padding: 12px 16px;
    vertical-align: middle;
}

/* ─── FORMULAIRES ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--c-text-muted);
    margin-bottom: 7px;
}

.form-control {
    width: 100%;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    color: var(--c-text);
    padding: 11px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--c-gold);
    box-shadow: 0 0 0 3px rgba(201,168,76,.15);
}

.form-control::placeholder { color: var(--c-text-muted); opacity: .7; }
select.form-control { cursor: pointer; appearance: auto; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ─── BOUTONS ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn--primary  { background: var(--c-gold); color: #0d0f0e; }
.btn--primary:hover { background: var(--c-gold-light); color: #0d0f0e; transform: translateY(-1px); }

.btn--outline  { background: transparent; color: var(--c-gold); border: 1px solid var(--c-gold); }
.btn--outline:hover { background: rgba(201,168,76,.1); color: var(--c-gold); }

.btn--success  { background: var(--c-recettes); color: #fff; }
.btn--success:hover { background: #37926b; color: #fff; }

.btn--danger   { background: var(--c-depenses); color: #fff; }
.btn--danger:hover { background: #c03333; color: #fff; }

.btn--ghost    { background: var(--c-surface-2); color: var(--c-text-muted); border: 1px solid var(--c-border); }
.btn--ghost:hover { color: var(--c-text); border-color: var(--c-text-muted); }

.btn--sm  { padding: 6px 14px; font-size: 12px; }
.btn--lg  { padding: 14px 28px; font-size: 15px; }
.btn--full { width: 100%; }

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #fff;
}

/* ─── ALERTES FLASH ──────────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.alert__icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

.alert--success { background: rgba(46,125,82,.18);  border: 1px solid var(--c-recettes); color: #7fd4a8; }
.alert--error   { background: rgba(168,50,50,.18);  border: 1px solid var(--c-depenses); color: #e08080; }
.alert--warning { background: rgba(201,122,44,.18); border: 1px solid var(--c-warning);  color: #e0a86a; }
.alert--info    { background: rgba(44,106,201,.18); border: 1px solid var(--c-info);     color: #7aaee0; }

/* ─── UPLOAD ─────────────────────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--c-border);
    border-radius: var(--radius-lg);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    color: var(--c-text-muted);
}

.upload-zone:hover {
    border-color: var(--c-gold);
    background: rgba(201,168,76,.04);
    color: var(--c-gold);
}

.upload-zone input[type="file"] { display: none; }

/* ─── BARRE DE PROGRESSION ───────────────────────────────────────────────── */
.progress-bar {
    height: 8px;
    background: var(--c-border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar__fill {
    height: 100%;
    border-radius: 4px;
    transition: width .4s ease;
}

.progress-bar__fill--ok      { background: var(--c-recettes); }
.progress-bar__fill--warning { background: var(--c-warning); }
.progress-bar__fill--danger  { background: var(--c-depenses); }

/* ─── CODE PROJET (chip) ─────────────────────────────────────────────────── */
.code-chip {
    display: inline-block;
    background: rgba(201,168,76,.1);
    border: 1px solid rgba(201,168,76,.4);
    color: var(--c-gold);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 4px;
    letter-spacing: .06em;
}

/* ─── EN-TÊTE DE PAGE ────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: var(--c-text);
}

.page-subtitle {
    font-size: 13px;
    color: var(--c-text-muted);
    margin-top: 2px;
}

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ─── FOOTER ─────────────────────────────────────────────────────────────── */
.app-footer {
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    padding: 12px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-left: var(--sidebar-w);
}

/* ─── MENU MOBILE — CSS Checkbox Hack ───────────────────────────────────── */
.menu-toggle-input { display: none; }

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

.menu-toggle-input:checked ~ .sidebar-overlay { display: block; }
.menu-toggle-input:checked ~ .sidebar         { transform: translateX(0); }

/* ─── UTILITAIRES ────────────────────────────────────────────────────────── */
.flex          { display: flex; }
.flex-between  { display: flex; justify-content: space-between; align-items: center; }
.flex-center   { display: flex; align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.mb-8          { margin-bottom: 8px; }
.mb-16         { margin-bottom: 16px; }
.mb-24         { margin-bottom: 24px; }
.mt-16         { margin-top: 16px; }
.text-muted    { color: var(--c-text-muted); font-size: 13px; }
.text-gold     { color: var(--c-gold); }
.text-danger   { color: var(--c-depenses); }
.text-success  { color: var(--c-recettes); }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.font-mono     { font-family: 'Courier New', monospace; }
.fw-bold       { font-weight: 700; }
.w-100         { width: 100%; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ─── SECTION VIDE ───────────────────────────────────────────────────────── */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--c-text-muted);
}

.empty-state p { margin-top: 8px; font-size: 14px; }

/* ─── FILTRE BAR ─────────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .grid-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .app-footer {
        margin-left: 0;
    }

    .topbar__burger {
        display: block;
    }

    .content-area {
        padding: 16px;
    }

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .grid-stats {
        grid-template-columns: 1fr 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .grid-stats {
        grid-template-columns: 1fr;
    }

    .login-box {
        padding: 32px 24px;
        margin: 16px;
    }
}
