/* ============================================================
   SAS Comptabilité Matière - Mairies du Bénin
   Styles personnalisés - Bootstrap 5.3
   ============================================================ */

:root {
    --color-primary:   #1a5276;
    --color-primary-dark: #154360;
    --color-primary-light: #2e86c1;
    --color-secondary: #2e4057;
    --color-accent:    #f39c12;
    --sidebar-width:   260px;
    --sidebar-bg:      #1a3c5e;
    --topbar-height:   60px;
    --border-radius:   8px;
    --shadow-sm:       0 2px 8px rgba(0,0,0,.08);
    --shadow-md:       0 4px 16px rgba(0,0,0,.12);
    --transition:      all .2s ease;
}

/* ============================================================
   LAYOUT
   ============================================================ */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f0f4f8;
    color: #2c3e50;
    font-size: .9rem;
}

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform .3s ease;
    overflow: hidden;
}

.sidebar-header {
    background: rgba(0,0,0,.2);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    background: var(--color-accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding-bottom: 1rem;
}

.sidebar-section {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.4);
    padding: .75rem 1rem .25rem;
    margin-top: .25rem;
}

.sidebar-link {
    color: rgba(255,255,255,.75) !important;
    border-radius: 6px;
    padding: .55rem .75rem;
    display: flex;
    align-items: center;
    gap: .625rem;
    font-size: .85rem;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link:hover {
    color: #fff !important;
    background: rgba(255,255,255,.12);
}

.sidebar-link.active {
    color: #fff !important;
    background: var(--color-primary-light);
    font-weight: 600;
}

.sidebar-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .3s ease;
}

.content-area {
    flex: 1;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e8ecf0;
    box-shadow: var(--shadow-sm);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 900;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: .75rem;
}

.notif-badge {
    font-size: .65rem;
    padding: 2px 5px;
    min-width: 18px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    font-size: .8rem;
}

/* ============================================================
   CARDS KPI DASHBOARD
   ============================================================ */
.kpi-card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* ============================================================
   TABLES
   ============================================================ */
.table > :not(caption) > * > * {
    vertical-align: middle;
}

.table th {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c757d;
    white-space: nowrap;
}

.table td {
    font-size: .875rem;
}

/* ============================================================
   BADGES STATUT
   ============================================================ */
.badge {
    font-size: .72rem;
    font-weight: 600;
    padding: .3em .65em;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
    font-size: .85rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: .35rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 .2rem rgba(26,82,118,.15);
}

/* ============================================================
   BOUTONS
   ============================================================ */
.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* ============================================================
   CARDS GÉNÉRIQUES
   ============================================================ */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    padding: .875rem 1.25rem;
    font-weight: 600;
}

/* ============================================================
   TIMELINE WORKFLOW
   ============================================================ */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: .75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dee2e6;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -1.875rem;
    top: .25rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #dee2e6;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6rem;
}

.timeline-dot.done {
    background: #198754;
    border-color: #198754;
    color: #fff;
}

.timeline-dot.active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
    animation: pulse 1.5s infinite;
}

.timeline-dot.rejected {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13,110,253,.3); }
    50%       { box-shadow: 0 0 0 6px rgba(13,110,253,0); }
}

/* ============================================================
   ALERTES STOCK
   ============================================================ */
.stock-alert-row td {
    background-color: #fff5f5 !important;
}

.stock-low {
    color: #dc3545;
    font-weight: 700;
}

/* ============================================================
   SELECT2 OVERRIDES
   ============================================================ */
.select2-container--bootstrap-5 .select2-selection {
    font-size: .875rem;
}

/* ============================================================
   SIDEBAR COLLAPSED (responsive)
   ============================================================ */
.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.sidebar-collapsed .main-content {
    margin-left: 0;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar.show {
        transform: translateX(0);
    }
}

/* ============================================================
   PRINT - BON DE SORTIE, FICHES
   ============================================================ */
@media print {
    .sidebar,
    .topbar,
    .footer,
    .btn,
    .alert,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    body {
        background: #fff;
        font-size: 11pt;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }

    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 1.5rem;
    }

    table {
        font-size: 10pt;
    }

    .table td, .table th {
        border-color: #ccc !important;
    }
}

.print-header {
    display: none;
}

/* ============================================================
   MISCELLANEOUS
   ============================================================ */
.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-primary);
    border-left: 4px solid var(--color-accent);
    padding-left: .75rem;
    margin-bottom: 1.5rem;
}

.text-fcfa::after {
    content: ' FCFA';
    font-size: .8em;
    color: #6c757d;
}

.cursor-pointer {
    cursor: pointer;
}

.overflow-hidden {
    overflow: hidden;
}

.fw-600 {
    font-weight: 600;
}

.fs-sm {
    font-size: .8rem;
}

/* DataTables search/length position fix */
div.dataTables_wrapper div.dataTables_filter {
    text-align: right;
}

div.dataTables_wrapper div.dataTables_info {
    font-size: .8rem;
    color: #6c757d;
}
