/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
    --km-primary: #1a5fa8;
    --km-primary-dark: #154d8c;
    --km-success: #198754;
    --km-light: #f8f9fa;
    --km-border: #dee2e6;
}

/* ─── Général ────────────────────────────────────────────────────────────── */
body {
    background-color: #f0f4f8;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.navbar.bg-primary {
    background-color: var(--km-primary) !important;
}

.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
}

/* ─── Page de login ──────────────────────────────────────────────────────── */
.login-body {
    background: linear-gradient(135deg, #1a5fa8 0%, #0d3a66 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-card {
    border-radius: 14px !important;
}

/* ─── Tableaux ───────────────────────────────────────────────────────────── */
.table > thead > tr > th {
    background-color: var(--km-primary);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

.table-km-footer td {
    background-color: #e8f0f8;
    font-weight: 700;
    border-top: 2px solid var(--km-primary);
}

/* ─── Badges de statut ───────────────────────────────────────────────────── */
.badge-valide {
    background-color: var(--km-success);
    color: #fff;
    padding: .35em .65em;
    border-radius: .375rem;
    font-size: .8em;
    font-weight: 600;
}

.badge-ouvert {
    background-color: #6c757d;
    color: #fff;
    padding: .35em .65em;
    border-radius: .375rem;
    font-size: .8em;
    font-weight: 600;
}

.badge-verrouille {
    background-color: #dc3545;
    color: #fff;
    padding: .35em .65em;
    border-radius: .375rem;
    font-size: .8em;
    font-weight: 600;
}

/* ─── Résumé financier ───────────────────────────────────────────────────── */
.recap-card {
    background: linear-gradient(135deg, #1a5fa8, #2980b9) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 12px !important;
}

.recap-card .card-body {
    padding: 1.5rem;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
}

.recap-card .recap-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
}

.recap-card .recap-label {
    font-size: .85rem;
    opacity: .85;
    color: #fff;
}

/* ─── Cartes hub (dashboard) ─────────────────────────────────────────────── */
.hub-card {
    border: 2px solid transparent;
    transition: border-color .2s, box-shadow .2s;
}

.hub-card:hover {
    border-color: var(--km-primary);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.hub-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.footer {
    margin-top: auto;
}

/* ─── Bouton imprimer ────────────────────────────────────────────────────── */
.btn-print {
    background-color: #6c757d;
    color: #fff;
    border: none;
}

.btn-print:hover {
    background-color: #5a6268;
    color: #fff;
}

/* ─── Impression ─────────────────────────────────────────────────────────── */
@media print {
    .no-print,
    .navbar,
    .footer,
    .btn,
    .alert,
    nav,
    .breadcrumb {
        display: none !important;
    }

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

    .container {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

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

    .table > thead > tr > th {
        background-color: #333 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table-km-footer td {
        background-color: #eee !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .recap-card {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #ccc !important;
        border-radius: 4px !important;
        height: 100% !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .recap-card .card-body {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .recap-card .recap-value {
        font-size: 1.25rem !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        color: #000 !important;
        opacity: 1 !important;
    }

    .recap-card .recap-label {
        font-size: .8rem !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        color: #444 !important;
        opacity: 1 !important;
    }

    /* Forcer même hauteur sur la ligne du récap */
    .recap-row { align-items: stretch !important; }
    .recap-row > [class*="col-"] { display: flex !important; }
    .recap-row .card,
    .recap-row .recap-card { width: 100% !important; }

    /* Cases récap km (parcourus / remboursables / montant) */
    .row.g-3.mb-4 .card-body {
        padding: .4rem .6rem !important;
    }

    .row.g-3.mb-4 .fs-2,
    .row.g-3.mb-4 .fs-3 {
        font-size: .95rem !important;
        font-weight: 700 !important;
    }

    .row.g-3.mb-4 .recap-card .recap-value {
        font-size: 1.5rem !important;
    }

    .row.g-3.mb-4 .recap-card .recap-label {
        font-size: .85rem !important;
    }

    .row.g-3.mb-4 .text-muted.small {
        font-size: .65rem !important;
    }

    /* Cases intervenant / statut */
    .row.g-3.mb-4 .card-body h6 {
        font-size: .7rem !important;
        margin-bottom: .2rem !important;
    }

    .row.g-3.mb-4 .card-body p {
        font-size: .7rem !important;
        margin-bottom: .1rem !important;
    }

    h1, h2, h3, h4 {
        page-break-after: avoid;
    }

    table {
        page-break-inside: avoid;
    }

    .print-header {
        display: flex !important;
    }
}

/* ─── En-tête pour impression uniquement ────────────────────────────────── */
.print-header {
    display: none;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem;
    border-bottom: 2px solid #333;
    padding-bottom: .4rem;
}

.print-header-left {
    text-align: left;
}

.print-header-left h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.print-header-left p {
    font-size: .8rem;
    margin: 0;
    color: #444;
}

.print-header-right {
    text-align: right;
    font-size: .8rem;
}

.print-header-right p {
    margin: 0;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 576px) {
    .recap-card .recap-value {
        font-size: 1.5rem;
    }

    .table-responsive {
        font-size: .85rem;
    }
}
