/* ============================================================
   GestIT — Feuille de style principale
   public/assets/css/app.css
   ============================================================ */

/* ── Variables globales ─────────────────────────────────────── */
:root {
    --primary:        #0d3b66;
    --primary-light:  #1a6ab1;
    --primary-hover:  #0a2f52;
    --sidebar-w:      240px;
    --sidebar-w-col:  64px;
    --topbar-h:       56px;
    --radius:         12px;
    --radius-sm:      8px;
    --shadow-sm:      0 1px 4px rgba(0,0,0,.08);
    --shadow-md:      0 4px 16px rgba(0,0,0,.10);
    --transition:     .25s ease;
    --bg-page:        #f0f2f8;
    --bg-card:        #ffffff;
    --border-color:   #e4e8f0;
    --text-muted:     #6c757d;
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-page);
    color: #212529;
    font-size: .9rem;
    overflow-x: hidden;
}

a { text-decoration: none; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary) 0%, #0a2947 100%);
    color: #fff;
    z-index: 1040;
    transition: width var(--transition);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0,0,0,.15);
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem 1.2rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .02em;
    border-bottom: 1px solid rgba(255,255,255,.1);
    white-space: nowrap;
    min-height: var(--topbar-h);
}

.sidebar-brand i {
    font-size: 1.4rem;
    color: #5db8ff;
    flex-shrink: 0;
}

/* Nav */
.sidebar-nav {
    list-style: none;
    padding: .6rem 0;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-nav .nav-label {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
    padding: .9rem 1.2rem .25rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: .58rem 1.2rem;
    color: rgba(255,255,255,.72);
    transition: background var(--transition), color var(--transition);
    font-size: .875rem;
    white-space: nowrap;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.sidebar-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sidebar-link.active {
    background: rgba(255,255,255,.13);
    color: #fff;
    font-weight: 600;
    border-left-color: #5db8ff;
}

/* Footer sidebar */
.sidebar-footer {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .8rem;
    white-space: nowrap;
    overflow: hidden;
}

.avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .82rem;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,.25);
}

/* ── Sidebar collapsed ──────────────────────────────────────── */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-col);
}

body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .sidebar-link span,
body.sidebar-collapsed .sidebar-nav .nav-label,
body.sidebar-collapsed .sidebar-footer .flex-grow-1,
body.sidebar-collapsed .sidebar-footer .btn {
    display: none;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: .65rem;
    border-left: none;
    border-radius: 0;
}

body.sidebar-collapsed .sidebar-link i { width: auto; }

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-w-col);
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 1rem .5rem;
}

/* Tooltip au survol en mode collapsed */
body.sidebar-collapsed .sidebar-link:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-w-col) + 8px);
    background: #222;
    color: #fff;
    padding: .25rem .6rem;
    border-radius: 6px;
    font-size: .78rem;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

/* ── LAYOUT PRINCIPAL ───────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left var(--transition);
    display: flex;
    flex-direction: column;
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: .75rem;
}

.topbar .breadcrumb { margin-bottom: 0; }
.topbar .breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* ── ZONE CONTENU ───────────────────────────────────────────── */
.content-area {
    flex: 1;
    padding: 1.5rem;
}

/* ── CARTES STATISTIQUES (dashboard) ────────────────────────── */
.stat-card {
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color) !important;
    transition: transform .2s, box-shadow .2s;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
    color: #1a1f36;
}

.stat-label {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ── CARTES GÉNÉRIQUES ──────────────────────────────────────── */
.card {
    border-radius: var(--radius) !important;
    border: 1px solid var(--border-color) !important;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
}

/* ── TABLEAUX ────────────────────────────────────────────────── */
.table { font-size: .85rem; }
.table thead th {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding: .75rem 1rem;
    white-space: nowrap;
}
.table td { padding: .7rem 1rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f7f9ff; }

/* DataTables overrides */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .3rem .6rem;
    font-size: .82rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length { font-size: .8rem; color: var(--text-muted); }

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    font-size: .8rem;
    padding: .25rem .55rem !important;
}

/* ── BADGES ──────────────────────────────────────────────────── */
.badge { font-weight: 600; letter-spacing: .02em; }

/* ── BOUTONS ─────────────────────────────────────────────────── */
.btn { border-radius: var(--radius-sm); font-size: .85rem; }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Bouton toggle sidebar */
#sidebarToggle {
    border: 1px solid var(--border-color);
    color: #555;
    background: #fff;
}
#sidebarToggle:hover { background: #f0f2f8; }

/* ── FORMULAIRES ─────────────────────────────────────────────── */
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(26,106,177,.12);
}

.form-label { font-size: .82rem; margin-bottom: .3rem; }
.input-group-text {
    background: #f8f9fc;
    border-color: var(--border-color);
    color: var(--text-muted);
}

/* ── MODALS ──────────────────────────────────────────────────── */
.modal-content {
    border-radius: var(--radius) !important;
    border: none !important;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: .75rem 1.25rem;
}

/* ── PAGE LOGIN ──────────────────────────────────────────────── */
.login-body {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    min-height: 100vh;
}

.login-card {
    border-radius: 18px !important;
    border: none !important;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    padding: 2rem;
}

.login-icon {
    width: 70px;
    height: 70px;
    border-radius: 18px;
    background: linear-gradient(135deg, #e8f0fe, #c5d9f8);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

/* ── ALERTS ──────────────────────────────────────────────────── */
.alert { border-radius: var(--radius-sm); font-size: .875rem; }
.alert-success { background: #edfaf2; border-color: #b6f0cd; color: #166534; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ── SCROLLBAR GLOBALE ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5ccd8; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #a0a8b8; }

/* ── CODE / MONOSPACE ────────────────────────────────────────── */
code {
    background: #f0f2f8;
    color: var(--primary);
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .82rem;
}

/* ── SPINNER ─────────────────────────────────────────────────── */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ── PRINT ───────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_paginate { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w);
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .main-content { margin-left: 0 !important; }

    /* Overlay sur mobile quand sidebar ouverte */
    body.sidebar-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 1039;
    }
}

@media (max-width: 575.98px) {
    .content-area { padding: 1rem; }
    .stat-value { font-size: 1.4rem; }
    .topbar { padding: 0 .75rem; }
}