/* DMC - Style minimaliste base sur Bootstrap */

:root {
    --primary-color: #2B2D7B;
    --primary-dark: #1a1b4a;
    --primary-light: #eaebf5;
    --secondary-color: #E8611A;
}

/* Police Inter */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

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

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Liens */
a { color: var(--primary-color); }
a:hover { color: var(--primary-dark); }

/* Nav links actifs */
.nav-link.active,
.navbar-nav .nav-link.active {
    color: var(--primary-color) !important;
}

/* Focus states */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(43, 45, 123, 0.25);
}

/* Badges et backgrounds */
.bg-primary { background-color: var(--primary-color) !important; }
.text-primary { color: var(--primary-color) !important; }
.border-primary { border-color: var(--primary-color) !important; }

/* Tables - en-tete colore (tous les tableaux) */
.table thead th {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-dark);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 12px;
}
.table thead th a,
.table thead th .sort-header span { color: #fff; }

/* Sort buttons in table headers */
.sort-header {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sort-btn-group {
    display: inline-flex;
    flex-direction: column;
    gap: 0;
    line-height: 1;
}
.sort-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.45);
    padding: 0;
    font-size: 0.6rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s;
}
.sort-btn:hover { color: rgba(255,255,255,0.9); }
.sort-btn.active { color: #fff; }

/* Badges status - couleurs vives */
.badge.bg-success { background-color: #059669 !important; }
.badge.bg-warning { background-color: #d97706 !important; color: #fff !important; }
.badge.bg-danger { background-color: #dc2626 !important; }
.badge.bg-info { background-color: #0891b2 !important; color: #fff !important; }
.badge.bg-secondary { background-color: #64748b !important; }

/* Cards */
.card {
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.375rem;
}

/* Stat cards - border left colored */
.card.border-left-primary { border-left: 4px solid var(--primary-color) !important; }
.card.border-left-success { border-left: 4px solid #059669 !important; }
.card.border-left-warning { border-left: 4px solid #d97706 !important; }
.card.border-left-danger { border-left: 4px solid #dc2626 !important; }
.card.border-left-info { border-left: 4px solid #0891b2 !important; }

/* Stat card text styles */
.text-xs { font-size: 0.7rem; }
.font-weight-bold { font-weight: 700 !important; }
.text-gray-800 { color: #1e293b !important; }
.text-gray-300 { color: #cbd5e1 !important; }

/* Filtres - compact row */
.row.mb-4 .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}
.row.mb-4 .form-control,
.row.mb-4 .form-select {
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 6px;
}

/* Pagination */
.page-link { color: var(--primary-color); }
.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Dropdown */
.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--primary-color);
}

/* Progress bars */
.progress-bar { background-color: var(--primary-color); }

/* List group */
.list-group-item.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ===== MOBILE: Tables → Cards ===== */
@media (max-width: 768px) {
    /* Hide table header on mobile */
    .table-responsive .table thead {
        display: none;
    }

    .table-responsive .table,
    .table-responsive .table tbody,
    .table-responsive .table tr,
    .table-responsive .table td {
        display: block;
        width: 100%;
    }

    .table-responsive .table tr {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-left: 4px solid var(--primary-color);
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 12px 14px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
        position: relative;
    }

    .table-responsive .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 7px 0;
        border: none;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.85rem;
    }

    .table-responsive .table td:last-child {
        border-bottom: none;
        padding-top: 10px;
        justify-content: flex-start;
        gap: 6px;
        flex-wrap: wrap;
    }

    /* Labels from headers */
    .table-responsive .table td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.7rem;
        color: var(--primary-color);
        text-transform: uppercase;
        letter-spacing: 0.4px;
        flex-shrink: 0;
        margin-right: 8px;
    }

    /* Values: bold */
    .table-responsive .table td {
        font-weight: 500;
        color: #1e293b;
    }

    /* Action buttons */
    .table-responsive .table td .btn-group,
    .table-responsive .table td .d-flex {
        flex-wrap: wrap;
        gap: 4px;
    }
    .table-responsive .table td .btn-sm {
        padding: 6px 10px;
        font-size: 0.75rem;
        border-radius: 6px;
    }
    .table-responsive .table td[data-label="Actions"]::before {
        display: none;
    }

    /* Disable horizontal scroll */
    .table-responsive {
        overflow-x: visible !important;
    }

    /* ── Badges mobile: plus gros et colores ── */
    .badge {
        font-size: 0.7rem !important;
        padding: 4px 10px !important;
        border-radius: 6px !important;
    }
    .badge.bg-success { background-color: #059669 !important; color: #fff !important; }
    .badge.bg-warning { background-color: #d97706 !important; color: #fff !important; }
    .badge.bg-danger { background-color: #dc2626 !important; color: #fff !important; }
    .badge.bg-info { background-color: #0891b2 !important; color: #fff !important; }
    .badge.bg-primary { background-color: var(--primary-color) !important; color: #fff !important; }

    /* ── Montants en gras colore ── */
    .table-responsive .table td strong,
    .table-responsive .table td .fw-bold {
        color: var(--primary-color);
        font-weight: 700;
    }

    /* ── Stat cards: couleurs pleines mobile ── */
    .card.border-left-primary { border-left: 4px solid var(--primary-color) !important; background: linear-gradient(135deg, var(--primary-light), #fff); }
    .card.border-left-success { border-left: 4px solid #059669 !important; background: linear-gradient(135deg, #ecfdf5, #fff); }
    .card.border-left-warning { border-left: 4px solid #d97706 !important; background: linear-gradient(135deg, #fef3c7, #fff); }
    .card.border-left-danger { border-left: 4px solid #dc2626 !important; background: linear-gradient(135deg, #fef2f2, #fff); }
    .card.border-left-info { border-left: 4px solid #0891b2 !important; background: linear-gradient(135deg, #ecfeff, #fff); }

    .text-primary { color: var(--primary-color) !important; }
    .text-success { color: #059669 !important; }
    .text-warning { color: #d97706 !important; }
    .text-danger { color: #dc2626 !important; }
    .text-info { color: #0891b2 !important; }

    /* ── Boutons: couleurs vives ── */
    .btn-primary { background-color: var(--primary-color) !important; border-color: var(--primary-color) !important; }
    .btn-success { background-color: #059669 !important; border-color: #059669 !important; }
    .btn-warning { background-color: #d97706 !important; border-color: #d97706 !important; color: #fff !important; }
    .btn-danger { background-color: #dc2626 !important; border-color: #dc2626 !important; }
    .btn-info { background-color: #0891b2 !important; border-color: #0891b2 !important; color: #fff !important; }

    .btn-outline-primary { color: var(--primary-color) !important; border-color: var(--primary-color) !important; }
    .btn-outline-success { color: #059669 !important; border-color: #059669 !important; }
    .btn-outline-danger { color: #dc2626 !important; border-color: #dc2626 !important; }
    .btn-outline-warning { color: #d97706 !important; border-color: #d97706 !important; }
    .btn-outline-info { color: #0891b2 !important; border-color: #0891b2 !important; }

    /* ── Modals: plein ecran sur mobile ── */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        min-height: 100vh;
    }
    .modal-content {
        border-radius: 0 !important;
        min-height: 100vh;
        border: none !important;
    }
    .modal-body {
        padding: 12px !important;
    }

    /* ── Modal footer: boutons empiles ── */
    .modal-footer {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 10px 12px !important;
        justify-content: center !important;
    }
    .modal-footer .btn {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.8rem;
        padding: 8px 10px;
        white-space: nowrap;
    }

    /* ── Boutons d'action (btn-group dans detail modals) ── */
    .btn-group {
        flex-wrap: wrap !important;
        gap: 4px;
    }
    .btn-group .btn {
        flex: 0 0 auto;
    }

    /* ── Boutons d'action flottants en bas des details ── */
    .d-flex.gap-2,
    .d-flex.gap-3 {
        flex-wrap: wrap !important;
    }

    /* ── Page headers: titre + bouton empiles ── */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }

    /* ── Cards stat en haut des pages ── */
    .row.mb-4 > .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
        padding: 4px;
    }
    .row.mb-4 > .col-md-3 .card {
        margin-bottom: 0;
    }
    .row.mb-4 > .col-md-3 .h5 {
        font-size: 1rem;
    }

    /* ── Filtres: empiles ── */
    .card.shadow-sm .row.g-3 > [class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* ── Detail facture: infos empilees ── */
    .row.g-3 > .col-md-6,
    .row.g-3 > .col-md-4,
    .row.g-3 > .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* ── Texte tronque ── */
    .text-truncate {
        max-width: 180px;
    }

    /* ── Hide less important columns on small screens ── */
    .table-responsive .table td[data-label="Actions"]::before {
        display: none;
    }
}
