/* ============================================
   RÈGLES RESPONSIVES MOBILE GLOBALES
   ============================================ */

/* Breakpoints :
   - ≤576px : Très petits écrans (mobiles)
   - ≤768px : Tablettes et mobiles
   - ≤992px : Tablettes en mode portrait
*/

/* ============================================
   HEADERS ET TITRES
   ============================================ */

@media (max-width: 768px) {
    /* Headers Premium */
    .header-premium,
    .header-premium-modern {
        padding: 1.5rem 1rem !important;
    }
    
    .header-premium h1.display-5,
    .header-premium h1.display-4 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    .header-premium .lead {
        font-size: 0.95rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Icônes décoratives réduites */
    .header-premium > div[style*="font-size: 15rem"],
    .header-premium-modern > div[style*="font-size: 15rem"] {
        font-size: 8rem !important;
        top: -10px !important;
        right: -10px !important;
    }
    
    /* Stats cards dans headers */
    .header-premium .stat-card,
    .header-premium-modern .stat-card {
        padding: 0.75rem !important;
    }
    
    .header-premium .stat-card .fs-2,
    .header-premium-modern .stat-card .fs-2 {
        font-size: 1.5rem !important;
    }
}

@media (max-width: 576px) {
    .header-premium,
    .header-premium-modern {
        padding: 1rem 0.75rem !important;
    }
    
    .header-premium h1.display-5,
    .header-premium h1.display-4 {
        font-size: 1.5rem !important;
    }
    
    .header-premium .lead {
        font-size: 0.875rem !important;
    }
    
    .header-premium > div[style*="font-size: 15rem"],
    .header-premium-modern > div[style*="font-size: 15rem"] {
        font-size: 6rem !important;
    }
    
    .header-premium .stat-card,
    .header-premium-modern .stat-card {
        padding: 0.5rem !important;
    }
    
    .header-premium .stat-card .fs-2,
    .header-premium-modern .stat-card .fs-2 {
        font-size: 1.25rem !important;
    }
}

/* ============================================
   BOUTONS
   ============================================ */

@media (max-width: 768px) {
    /* Boutons principaux */
    .btn-lg,
    button.btn-lg,
    a.btn-lg {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Boutons avec px-4 py-3 */
    .btn[class*="px-4"][class*="py-3"],
    button[class*="px-4"][class*="py-3"] {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Boutons avec px-5 py-3 */
    .btn[class*="px-5"][class*="py-3"],
    button[class*="px-5"][class*="py-3"],
    a[class*="px-5"][class*="py-3"] {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Boutons rounded-pill */
    .btn.rounded-pill {
        padding: 0.5rem 1rem !important;
    }
    
    /* Icônes dans boutons */
    .btn i {
        font-size: 0.875rem !important;
        margin-right: 0.25rem !important;
    }
}

@media (max-width: 576px) {
    .btn-lg,
    button.btn-lg,
    a.btn-lg {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
    
    .btn[class*="px-4"][class*="py-3"],
    button[class*="px-4"][class*="py-3"] {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.8rem !important;
    }
    
    .btn[class*="px-5"][class*="py-3"],
    button[class*="px-5"][class*="py-3"],
    a[class*="px-5"][class*="py-3"] {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
    
    .btn.rounded-pill {
        padding: 0.375rem 0.75rem !important;
    }
    
    .btn i {
        font-size: 0.8rem !important;
        margin-right: 0.25rem !important;
    }
}

/* ============================================
   TEXTES ET TYPOGRAPHIE
   ============================================ */

@media (max-width: 768px) {
    /* Display classes réduites */
    .display-5 {
        font-size: 1.75rem !important;
    }
    
    .display-4 {
        font-size: 2rem !important;
    }
    
    /* Font sizes réduits */
    .fs-2 {
        font-size: 1.5rem !important;
    }
    
    .fs-4 {
        font-size: 1.25rem !important;
    }
    
    .fs-5 {
        font-size: 1rem !important;
    }
    
    /* Lead réduit */
    .lead {
        font-size: 0.95rem !important;
    }
    
    /* H1-H6 réduits */
    h1 {
        font-size: 1.75rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    h4 {
        font-size: 1.1rem !important;
    }
    
    h5 {
        font-size: 1rem !important;
    }
    
    h6 {
        font-size: 0.95rem !important;
    }
}

@media (max-width: 576px) {
    .display-5 {
        font-size: 1.5rem !important;
    }
    
    .display-4 {
        font-size: 1.75rem !important;
    }
    
    .fs-2 {
        font-size: 1.25rem !important;
    }
    
    .fs-4 {
        font-size: 1.1rem !important;
    }
    
    .fs-5 {
        font-size: 0.95rem !important;
    }
    
    .lead {
        font-size: 0.875rem !important;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
    }
    
    h3 {
        font-size: 1.1rem !important;
    }
    
    h4 {
        font-size: 1rem !important;
    }
    
    h5 {
        font-size: 0.95rem !important;
    }
    
    h6 {
        font-size: 0.875rem !important;
    }
}

/* ============================================
   ESPACEMENTS
   ============================================ */

@media (max-width: 768px) {
    /* Gaps réduits */
    .gap-3 {
        gap: 0.75rem !important;
    }
    
    .gap-4 {
        gap: 1rem !important;
    }
    
    .gap-5 {
        gap: 1rem !important;
    }
    
    /* Marges bottom réduites */
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    .mb-5 {
        margin-bottom: 1.5rem !important;
    }
    
    /* Padding réduits */
    .p-4 {
        padding: 1rem !important;
    }
    
    .p-5 {
        padding: 1.25rem !important;
    }
    
    .px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .px-5 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    .py-5 {
        padding-top: 1.25rem !important;
        padding-bottom: 1.25rem !important;
    }
}

@media (max-width: 576px) {
    .gap-3 {
        gap: 0.5rem !important;
    }
    
    .gap-4 {
        gap: 0.75rem !important;
    }
    
    .gap-5 {
        gap: 0.75rem !important;
    }
    
    .mb-4 {
        margin-bottom: 0.75rem !important;
    }
    
    .mb-5 {
        margin-bottom: 1rem !important;
    }
    
    .p-4 {
        padding: 0.75rem !important;
    }
    
    .p-5 {
        padding: 1rem !important;
    }
    
    .px-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .px-5 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
    
    .py-5 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* ============================================
   TABLEAUX
   ============================================ */

@media (max-width: 768px) {
    /* Tableaux responsive */
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.375rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Masquer certaines colonnes sur mobile */
    .table th.d-none-mobile,
    .table td.d-none-mobile {
        display: none !important;
    }
}

@media (max-width: 576px) {
    .table-responsive {
        font-size: 0.8rem;
    }
    
    .table th,
    .table td {
        padding: 0.375rem 0.25rem !important;
        font-size: 0.8rem !important;
    }
}

/* ============================================
   MODALS
   ============================================ */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-content {
        border-radius: 0.5rem !important;
    }
    
    .modal-header {
        padding: 1rem !important;
    }
    
    .modal-body {
        padding: 1rem !important;
    }
    
    .modal-footer {
        padding: 0.75rem 1rem !important;
    }
    
    .modal-title {
        font-size: 1.25rem !important;
    }
}

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.25rem !important;
        max-width: calc(100% - 0.5rem) !important;
    }
    
    .modal-header {
        padding: 0.75rem !important;
    }
    
    .modal-body {
        padding: 0.75rem !important;
    }
    
    .modal-footer {
        padding: 0.5rem 0.75rem !important;
    }
    
    .modal-title {
        font-size: 1.1rem !important;
    }
}

/* ============================================
   CARDS ET CARTES
   ============================================ */

@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem !important;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    .card-header {
        padding: 0.75rem 1rem !important;
    }
    
    .card-footer {
        padding: 0.75rem 1rem !important;
    }
}

@media (max-width: 576px) {
    .card-body {
        padding: 0.75rem !important;
    }
    
    .card-header {
        padding: 0.5rem 0.75rem !important;
    }
    
    .card-footer {
        padding: 0.5rem 0.75rem !important;
    }
}

/* ============================================
   FORMULAIRES
   ============================================ */

@media (max-width: 768px) {
    .form-control-lg,
    .form-select-lg {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
    
    .form-label {
        font-size: 0.875rem !important;
        margin-bottom: 0.375rem !important;
    }
    
    .input-group-lg .form-control {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
}

@media (max-width: 576px) {
    .form-control-lg,
    .form-select-lg {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.8rem !important;
    }
    
    .form-label {
        font-size: 0.8rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .input-group-lg .form-control {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.8rem !important;
    }
}

/* ============================================
   BADGES
   ============================================ */

@media (max-width: 768px) {
    .badge {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
    }
    
    .badge.rounded-pill {
        padding: 0.25rem 0.75rem !important;
    }
}

@media (max-width: 576px) {
    .badge {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    
    .badge.rounded-pill {
        padding: 0.2rem 0.5rem !important;
    }
}

/* ============================================
   CONTAINERS
   ============================================ */

@media (max-width: 768px) {
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .container-fluid.px-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .container-fluid.py-3,
    .container-fluid.py-4,
    .container-fluid.py-5 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    .container-fluid.px-4 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    .container-fluid.py-3,
    .container-fluid.py-4,
    .container-fluid.py-5 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

/* ============================================
   CLASSES UTILITAIRES RESPONSIVE
   ============================================ */

/* Classes pour masquer/afficher selon la taille d'écran */
@media (max-width: 576px) {
    .small-md-normal {
        font-size: 1rem !important;
    }
    
    .h3-md {
        font-size: 1.5rem !important;
    }
    
    .h2-md {
        font-size: 1.75rem !important;
    }
    
    .h5-md {
        font-size: 1rem !important;
    }
    
    .fs-5-md {
        font-size: 1rem !important;
    }
    
    .fs-6-md {
        font-size: 0.95rem !important;
    }
}

/* Classes pour padding responsive */
@media (max-width: 576px) {
    .p-2-md {
        padding: 0.75rem !important;
    }
    
    .p-3-md {
        padding: 1rem !important;
    }
    
    .px-2-md {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .py-2-md {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

/* ============================================
   CORRECTION BOUTONS TOGGLE LISTE/CARTE
   ============================================ */
@media (max-width: 768px) {
    /* Forcer les boutons toggle sur leur propre ligne */
    .d-flex.flex-wrap .btn-group {
        width: 100% !important;
        margin-top: 0.5rem !important;
        justify-content: center !important;
    }
    
    .d-flex.align-items-center.gap-2 .btn-group {
        width: 100% !important;
        margin-top: 0.5rem !important;
    }
    
    /* Boutons toggle compacts */
    .btn-group .btn {
        flex: 1 !important;
        padding: 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Search box et toggle sur mobile */
    .search-box + .btn-group {
        width: 100% !important;
        margin-top: 0.75rem !important;
    }
}

@media (max-width: 576px) {
    .btn-group .btn {
        padding: 0.4rem 0.5rem !important;
        font-size: 0.8rem !important;
    }
}

/* ============================================
   CORRECTION DROPDOWNS QUI DÉBORDENT
   ============================================ */
@media (max-width: 768px) {
    /* Dropdowns dans les cartes */
    .card .dropdown-menu,
    .dropdown-menu.dropdown-menu-end {
        position: fixed !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        margin-top: 0.5rem !important;
        min-width: 200px !important;
        max-width: 90vw !important;
        z-index: 1050 !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    }
    
    /* Dropdowns près du bord droit */
    .card-header .dropdown:last-child .dropdown-menu,
    .d-flex.justify-content-between .dropdown:last-child .dropdown-menu {
        left: auto !important;
        right: 1rem !important;
        transform: none !important;
    }
    
    /* Dropdowns près du bord gauche */
    .card-header .dropdown:first-child .dropdown-menu {
        left: 1rem !important;
        right: auto !important;
        transform: none !important;
    }
}

@media (max-width: 576px) {
    .dropdown-menu {
        min-width: 180px !important;
        max-width: 85vw !important;
        font-size: 0.875rem !important;
    }
    
    .dropdown-item {
        padding: 0.5rem 0.75rem !important;
    }
}

/* Boutons entête Reporting (Statistiques / Nouveau Reporting) */
@media (max-width: 767.98px) {
    .header-premium-modern .col-12.col-lg-4 .btn {
        font-size: 0.75rem !important;
        padding: 0.45rem 0.9rem !important;
    }

    .header-premium-modern .col-12.col-lg-4 .d-flex {
        gap: 0.5rem !important;
    }
}
