/* Responsive Design - Mobile First */

/* Mobile (320px - 768px) */
@media (max-width: 768px) {
    .main-header {
        height: 80px;
        min-height: 80px;
        max-height: 80px;
        padding: 0.75rem 0;
    }
    
    .header-logo {
        height: 70px;
        margin-left: 0.75rem;
    }
    
    .logo-title {
        font-size: 1.8rem;
    }
    
    .logo-subtitle {
        font-size: 0.95rem;
        letter-spacing: 1.2px;
    }
    
    .main-nav {
        display: none !important;
    }
    
    .hamburger-btn {
        display: flex !important;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-title-wrapper {
        gap: 0.75rem;
    }
    
    .settings-icon-link {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .feature-card {
        margin-bottom: var(--spacing-md);
    }
    
    .card-icon {
        font-size: 2.5rem;
    }
    
    .card-title {
        font-size: 1.2rem;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-icon-size {
        font-size: 2rem !important;
    }
    
    /* Sélecteur de période responsive */
    .periode-select {
        min-width: 100% !important;
        font-size: 1rem !important;
        padding: 0.6rem 0.8rem !important;
    }
    
    /* Graphiques responsive */
    .chart-container {
        height: 250px !important;
        min-height: 250px !important;
        padding: 0.5rem;
    }
    
    /* Graphique camembert sur mobile */
    #graphiqueProduits {
        max-width: 100% !important;
    }
    
    /* Tableaux responsive */
    .table-dashboard {
        font-size: 0.8rem;
    }
    
    .table-dashboard th,
    .table-dashboard td {
        padding: 0.4rem 0.2rem;
        font-size: 0.75rem;
    }
    
    /* Cartes de statistiques */
    .stat-card {
        margin-bottom: 1rem;
    }
    
    .stat-card .card-title {
        font-size: 0.9rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.3rem;
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Masquer le tableau sur mobile/tablette */
    .table-responsive-wrapper {
        display: none !important;
    }
    
    /* Afficher les cartes sur mobile/tablette */
    .commandes-cards,
    .tarifs-cards {
        display: block !important;
        padding: 0 1rem;
    }
    
    .commande-card,
    .tarif-card {
        max-width: 100%;
    }
    
    /* Modal responsive */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .modal-body {
        padding: 1rem;
        overflow-x: hidden;
        max-width: 100%;
    }
    
    .modal-body .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .modal-body .col-12,
    .modal-body .col-sm-12,
    .modal-body .col-md-12 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Sur mobile, les col-lg-6 prennent toute la largeur */
    .modal-body .col-lg-6 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Container fluid responsive */
    .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* Éviter le scroll horizontal */
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    html {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Menu burger responsive - Petits écrans (320px - 480px) */
    .mobile-nav {
        max-width: 100%;
        padding: 1rem;
        gap: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .mobile-nav-link {
        padding: 0.9rem 1rem;
        font-size: 1rem;
        gap: 1rem;
        min-height: 48px;
    }
    
    .nav-icon {
        font-size: 1.2rem;
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }
    
    .nav-text {
        font-size: 1rem;
    }
    
    /* Menu burger responsive - Très petits écrans (320px - 375px) */
    @media (max-width: 375px) {
        .mobile-nav {
            padding: 0.75rem;
            gap: 0.75rem;
            max-height: calc(100vh - 1.5rem);
        }
        
        .mobile-nav-link {
            padding: 0.75rem 0.9rem;
            font-size: 0.9rem;
            gap: 0.75rem;
        }
        
        .nav-icon {
            font-size: 1.1rem;
            width: 28px;
            height: 28px;
        }
        
        .nav-text {
            font-size: 0.9rem;
        }
    }
    
    /* Menu burger responsive - Écrans moyens (375px - 480px) */
    @media (min-width: 376px) and (max-width: 480px) {
        .mobile-nav {
            padding: 1.25rem;
            gap: 1.1rem;
            max-height: calc(100vh - 2.5rem);
        }
        
        .mobile-nav-link {
            padding: 1rem 1.2rem;
            font-size: 1.05rem;
            gap: 1.1rem;
            min-height: 46px;
        }
        
        .nav-icon {
            font-size: 1.3rem;
            width: 35px;
            height: 35px;
            flex-shrink: 0;
        }
        
        .nav-text {
            font-size: 1.05rem;
        }
    }
    
    /* Menu burger responsive - Grands mobiles (480px - 768px) */
    @media (min-width: 481px) and (max-width: 768px) {
        .mobile-nav {
            padding: 1.5rem;
            gap: 1.25rem;
            max-height: calc(100vh - 3rem);
        }
        
        .mobile-nav-link {
            padding: 1.1rem 1.3rem;
            font-size: 1.15rem;
            gap: 1.25rem;
            min-height: 50px;
        }
        
        .nav-icon {
            font-size: 1.4rem;
            width: 38px;
            height: 38px;
            flex-shrink: 0;
        }
        
        .nav-text {
            font-size: 1.15rem;
        }
    }
}

/* Tablette */
@media (min-width: 768px) and (max-width: 1024px) {
    .table {
        min-width: 700px;
    }
    
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* Tablette (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .hero-title {
        font-size: 2.5rem;
    }
    
    .main-nav {
        gap: var(--spacing-md);
    }
    
    /* Menu hamburger aussi sur tablette */
    .main-nav {
        display: none !important;
    }
    
    .hamburger-btn {
        display: flex !important;
    }
    
    .mobile-menu-overlay {
        display: flex;
    }
    
    /* Menu burger responsive sur tablette */
    .mobile-nav {
        max-width: 450px;
        padding: 2rem;
        gap: 1.5rem;
        max-height: calc(100vh - 4rem);
    }
    
    .mobile-nav-link {
        padding: 1.2rem 1.5rem;
        font-size: 1.2rem;
        gap: 1.5rem;
        min-height: 52px;
    }
    
    .nav-icon {
        font-size: 1.5rem;
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }
    
    .nav-text {
        font-size: 1.2rem;
    }
    
    /* Masquer le tableau sur tablette */
    .table-responsive-wrapper {
        display: none !important;
    }
    
    /* Afficher les cartes sur tablette avec marges */
    .commandes-cards,
    .tarifs-cards {
        display: block !important;
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
        padding: 0 2rem;
    }
    
    .commande-card,
    .tarif-card {
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Container avec marges sur tablette */
    .container-fluid {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }
    
    /* Graphiques sur tablette */
    .chart-container {
        height: 280px !important;
        min-height: 280px !important;
    }
    
    /* Graphique camembert sur tablette */
    #graphiqueProduits {
        max-width: 100% !important;
    }
    
    /* Sélecteur de période sur tablette */
    .periode-select {
        min-width: 200px !important;
        font-size: 1rem !important;
    }
    
    /* Tableaux sur tablette */
    .table-dashboard {
        font-size: 0.85rem;
    }
}

/* Desktop (1024px et plus) */
@media (min-width: 1024px) {
    .container {
        max-width: 1200px;
    }
    
    /* Cacher le menu mobile sur desktop */
    .hamburger-btn {
        display: none !important;
    }
    
    .mobile-menu-overlay {
        display: none !important;
    }
    
    .main-nav {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        width: 100% !important;
    }
    
    /* S'assurer que la colonne du menu est bien alignée */
    .col-md-6:last-child {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
    }
    
    /* Afficher le tableau sur desktop */
    .table-responsive-wrapper {
        display: block !important;
    }
    
    /* Masquer les cartes sur desktop */
    .commandes-cards,
    .tarifs-cards {
        display: none !important;
    }
    
    /* Cartes de statistiques en 4 colonnes sur desktop */
    .stats-row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .stats-row > .col-lg-3,
    .stats-row > .col-xl-3 {
        flex: 0 0 25%;
        max-width: 25%;
        padding-left: calc(var(--bs-gutter-x) * 0.5);
        padding-right: calc(var(--bs-gutter-x) * 0.5);
    }
    
    .stats-row > .col-lg-3 > .stat-card,
    .stats-row > .col-xl-3 > .stat-card {
        width: 100%;
        margin: 0;
    }
    
    /* Modal - colonnes côte à côte sur desktop */
    #formCommande .row {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 1.5rem;
    }
    
    #formCommande .col-lg-6 {
        flex: 0 0 calc(50% - 0.75rem) !important;
        max-width: calc(50% - 0.75rem) !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Plage spécifique 1025px - 1062px */
@media (min-width: 1025px) and (max-width: 1062px) {
    .main-nav {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        width: 100% !important;
        gap: 0.75rem !important;
        margin-left: auto !important;
        flex-wrap: nowrap !important;
    }
    
    .col-md-6:last-child {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        padding-right: 0.5rem !important;
        padding-left: 0 !important;
    }
    
    .nav-link {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.5rem !important;
        white-space: nowrap !important;
    }
    
    .main-header .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Page Paramètres - Mobile */
    .user-card {
        margin-bottom: 1rem;
        padding: 1rem !important;
    }
    
    .user-permissions-mobile {
        font-size: 0.85rem;
    }
    
    .permissions-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
    }
    
    .permissions-list .badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        white-space: normal;
        word-break: break-word;
        line-height: 1.4;
    }
}

/* Page Paramètres - Desktop */
@media (min-width: 768px) {
    .users-cards {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 1.5rem;
    }
    
    .user-card {
        padding: 1.5rem !important;
    }
    
    .user-card .card-header {
        width: 100%;
    }
}

/* Assurer que toutes les cartes principales ont la même largeur */
@media (min-width: 992px) {
    .card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .card .card-header {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Les deux sections principales doivent avoir la même largeur */
    .row .col-lg-8.mx-auto .card,
    .row .col-lg-10.mx-auto .card {
        width: 100%;
    }
}

/* Plage spécifique 1063px - 1251px */
@media (min-width: 1063px) and (max-width: 1251px) {
    .main-nav {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        width: 100% !important;
        gap: 0.75rem !important;
    }
    
    .col-md-6:last-child {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        padding-right: 1rem !important;
    }
    
    .nav-link {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
        white-space: nowrap;
    }
}


