/**
 * Optimisations Mobile pour le Dashboard
 * Objectif: Utiliser 100% de la largeur sur mobile, réduire les marges inutiles
 * 98% du trafic est mobile - PRIORITÉ ABSOLUE
 */

/* ===== OPTIMISATIONS GLOBALES MOBILE ===== */
@media (max-width: 768px) {
    /* Classes wrapper du système de shortcodes unifié */
    body.has-marketplace-sidebar {
        padding-left: 0 !important; /* Pas de padding sur mobile - utiliser toute la largeur */
    }
    
    .marketplace-page-wrapper {
        padding-left: 0 !important; /* Pas de padding supplémentaire */
    }
    
    .marketplace-page-container {
        padding: 0 !important;
        max-width: 100% !important;
    }
    
    .marketplace-page-content {
        padding: 0 !important;
        max-width: 100% !important;
        overflow-x: hidden !important; /* Éviter le débordement horizontal */
    }
    
    /* Supprimer les paddings du container principal sur mobile */
    .dashboard-container {
        padding: 0 !important;
        max-width: 100% !important;
    }
    
    /* Les sections doivent utiliser toute la largeur */
    .dashboard-section {
        margin: 0 0 1px 0 !important; /* Seulement 1px entre les sections */
        padding: 20px 15px !important;
        border-radius: 0 !important; /* Pas de coins arrondis sur mobile */
        border: none !important;
        border-bottom: 1px solid #e4e5e7 !important; /* Séparateur horizontal */
        box-shadow: none !important; /* Pas d'ombres sur mobile */
    }
    
    /* La dernière section n'a pas de bordure en bas */
    .dashboard-section:last-child {
        border-bottom: none !important;
    }
    
    /* Sections spécifiques pleine largeur */
    .preferred-quotes-section,
    .reveals-widget,
    .widget,
    .become-vendor-cta-main {
        background: #fff;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        border-radius: 0 !important;
        box-sizing: border-box !important; /* Important pour éviter le débordement */
    }
    
    /* Headers de sections optimisés */
    .section-header {
        margin-bottom: 15px !important;
        padding-bottom: 10px !important;
        border-bottom: 1px solid #e4e5e7 !important;
    }
    
    .section-header h2 {
        font-size: 18px !important;
        margin: 0 !important;
    }
    
    /* Sidebar column en pleine largeur */
    .sidebar-column {
        margin: 0 !important;
        padding: 0 !important;
        grid-template-columns: 1fr !important;
        gap: 1px !important; /* Seulement 1px entre les widgets */
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Widgets dans la sidebar */
    .sidebar-column .widget {
        margin: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        border-bottom: 1px solid #e4e5e7 !important;
        box-shadow: none !important;
    }
    
    .sidebar-column .widget:last-child {
        border-bottom: none !important;
    }
    
    /* Overview two columns - pas de gap sur mobile */
    .overview-two-columns {
        gap: 0 !important;
    }
    
    /* Main column pleine largeur */
    .main-column {
        padding: 0 !important;
    }
    
    /* Dashboard content sans padding latéral */
    .dashboard-content {
        padding: 0 !important;
    }
    
    /* Stats cards optimisées */
    .dashboard-stats,
    .stats-grid {
        gap: 10px !important;
        margin-bottom: 15px !important;
    }
    
    .stat-card {
        padding: 15px !important;
        border-radius: 8px !important; /* Légèrement arrondi pour les cartes */
    }
    
    /* Quote cards compactes */
    .quote-card-compact {
        padding: 15px !important;
        margin-bottom: 10px !important;
        border-radius: 8px !important;
    }
    
    /* Boutons pleine largeur sur mobile */
    .btn-view-quote,
    .btn-primary,
    .btn-success,
    .btn-upgrade {
        width: 100% !important;
        justify-content: center !important;
        padding: 12px 16px !important;
        font-size: 16px !important;
    }
    
    /* Reveals widget spécifique */
    .reveals-widget {
        background: #f8f9fa !important; /* Légèrement différent pour se démarquer */
    }
    
    .reveals-widget.no-reveals {
        background: #fee !important;
    }
    
    .reveals-widget.low-reveals {
        background: #fff8dc !important;
    }
    
    /* Progress bars optimisées */
    .progress-wrapper {
        margin: 15px 0 !important;
    }
    
    /* CTA sections */
    .become-vendor-cta-main {
        padding: 25px 15px !important;
        text-align: center !important;
    }
    
    /* Lists sans marges excessives */
    .quotes-list.compact {
        gap: 10px !important;
    }
    
    /* Formulaires optimisés */
    .form-control {
        font-size: 16px !important; /* Éviter le zoom iOS */
        padding: 12px !important;
    }
    
    /* Modals pleine largeur */
    .modal-content {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
        border-radius: 12px !important;
    }
}

/* ===== CORRECTIONS SUPPLÉMENTAIRES POUR LE DÉBORDEMENT ===== */
@media (max-width: 768px) {
    /* Forcer tous les éléments à respecter la largeur */
    * {
        max-width: 100% !important;
    }
    
    /* Corriger le débordement horizontal global */
    html, body {
        overflow-x: hidden !important;
    }
    
    /* Sidebar en overlay sur mobile pour ne pas prendre d'espace */
    .marketplace-sidebar {
        position: fixed !important;
        left: -260px !important; /* Masquée par défaut */
        width: 260px !important;
        z-index: 9999 !important;
        transition: left 0.3s ease !important;
    }
    
    /* Quand la sidebar est ouverte */
    .marketplace-sidebar.expanded {
        left: 0 !important;
    }
    
    /* Overlay sombre quand la sidebar est ouverte */
    .marketplace-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }
    
    body.sidebar-expanded .marketplace-sidebar-overlay {
        display: block;
    }
    
    /* Ajuster le body padding pour la sidebar collapsed */
    body.has-marketplace-sidebar {
        padding-left: 0 !important; /* Pas de padding sur mobile */
        padding-right: 0 !important;
    }
    
    /* S'assurer que rien ne déborde */
    .overview-two-columns,
    .main-column,
    .dashboard-stats,
    .quotes-list {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
}

/* ===== TRÈS PETITS ÉCRANS (iPhone SE, etc.) ===== */
@media (max-width: 375px) {
    .dashboard-section {
        padding: 15px 12px !important;
    }
    
    .section-header h2 {
        font-size: 16px !important;
    }
    
    .stat-card {
        padding: 12px !important;
    }
    
    .quote-card-compact {
        padding: 12px !important;
    }
    
    .btn-view-quote,
    .btn-primary {
        padding: 10px 14px !important;
        font-size: 15px !important;
    }
}

/* ===== MODE PAYSAGE MOBILE ===== */
@media (max-width: 768px) and (orientation: landscape) {
    /* Réduire les hauteurs en mode paysage */
    .dashboard-section {
        padding: 15px !important;
    }
    
    .section-header {
        margin-bottom: 10px !important;
    }
    
    .stat-card {
        padding: 10px !important;
    }
    
    /* Masquer certains éléments non essentiels */
    .widget-description,
    .cta-benefits-grid {
        display: none !important;
    }
}

/* ===== BOUTON MENU MOBILE ===== */
@media (max-width: 768px) {
    /* Bouton hamburger pour ouvrir la sidebar */
    .mobile-menu-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 10000;
        background: #333;
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 4px;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
    
    /* Cacher le bouton sur desktop */
    @media (min-width: 769px) {
        .mobile-menu-toggle {
            display: none !important;
        }
    }
}

/* ===== ANIMATIONS DÉSACTIVÉES SUR MOBILE ===== */
@media (max-width: 768px) {
    * {
        animation-duration: 0s !important;
        transition-duration: 0.1s !important; /* Transitions rapides seulement */
    }
    
    /* Sauf pour les éléments interactifs importants */
    .btn-primary,
    .btn-success,
    .form-control {
        transition-duration: 0.2s !important;
    }
}

/* ===== OPTIMISATIONS TACTILES ===== */
@media (max-width: 768px) {
    /* Zones de touch minimales de 44px */
    a,
    button,
    input,
    select,
    textarea,
    .clickable {
        min-height: 44px !important;
    }
    
    /* Espacement entre éléments cliquables */
    .quote-actions-compact {
        gap: 12px !important;
    }
    
    /* Checkboxes et radios plus grands */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px !important;
        height: 20px !important;
    }
}