/* ColisBled - Mobile-First Responsive Design */

/* ===========================================
   BASE MOBILE-FIRST STYLES
   =========================================== */

/* Reset pour mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    /* CRITIQUE: Empêche débordement */
    overflow-x: hidden;
    width: 100%;
}

body {
    /* CRITIQUE: Empêche TOUT débordement horizontal */
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

/* ===========================================
   NAVIGATION MOBILE
   =========================================== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

@media (max-width: 991px) {
    .navbar-collapse {
        background: white;
        border-radius: var(--radius-lg);
        margin-top: var(--space-4);
        box-shadow: var(--shadow-lg);
        padding: var(--space-4);
    }

    .navbar-nav {
        padding: var(--space-2) 0;
    }

    .navbar-nav .nav-link {
        padding: var(--space-3) var(--space-4) !important;
        border-radius: var(--radius);
        margin: var(--space-1) 0;
    }

    .navbar-nav .nav-link:hover {
        background: var(--gray-100);
    }
}

/* ===========================================
   CONTAINER MOBILE
   =========================================== */

.container,
.container-fluid {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

@media (min-width: 768px) {
    .container,
    .container-fluid {
        padding-left: var(--space-6);
        padding-right: var(--space-6);
    }
}

@media (min-width: 1024px) {
    .container,
    .container-fluid {
        padding-left: var(--space-8);
        padding-right: var(--space-8);
    }
}

/* ===========================================
   GRILLES RESPONSIVE
   =========================================== */

.responsive-grid {
    display: grid;
    gap: var(--space-4);
}

/* Mobile: 1 colonne */
.responsive-grid {
    grid-template-columns: 1fr;
}

/* Tablette: 2 colonnes */
@media (min-width: 768px) {
    .responsive-grid-2,
    .responsive-grid-3,
    .responsive-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .responsive-grid {
        gap: var(--space-6);
    }
}

/* Desktop: colonnes multiples */
@media (min-width: 1024px) {
    .responsive-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .responsive-grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .responsive-grid {
        gap: var(--space-8);
    }
}

/* ===========================================
   CARTES RESPONSIVE
   =========================================== */

.card-responsive {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

@media (min-width: 768px) {
    .card-responsive {
        padding: var(--space-6);
    }
}

@media (min-width: 1024px) {
    .card-responsive {
        padding: var(--space-8);
    }
}

.card-responsive:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

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

.form-responsive {
    width: 100%;
}

.form-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .form-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.form-input-mobile {
    padding: var(--space-3) var(--space-4);
    font-size: 16px; /* Empêche le zoom sur iOS */
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
    width: 100%;
}

@media (min-width: 768px) {
    .form-input-mobile {
        font-size: 1rem;
    }
}

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

.btn-mobile {
    padding: var(--space-3) var(--space-4);
    font-size: 0.9375rem;
    border-radius: var(--radius);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

@media (min-width: 768px) {
    .btn-mobile {
        width: auto;
        padding: var(--space-3) var(--space-6);
    }
}

.btn-mobile:active {
    transform: scale(0.98);
}

/* ===========================================
   TYPOGRAPHIE RESPONSIVE
   =========================================== */

.heading-1-mobile {
    font-size: 2rem;
    line-height: 1.2;
    font-weight: 800;
}

@media (min-width: 768px) {
    .heading-1-mobile {
        font-size: 3rem;
    }
}

@media (min-width: 1024px) {
    .heading-1-mobile {
        font-size: 4rem;
    }
}

.heading-2-mobile {
    font-size: 1.75rem;
    line-height: 1.3;
    font-weight: 700;
}

@media (min-width: 768px) {
    .heading-2-mobile {
        font-size: 2.5rem;
    }
}

.heading-3-mobile {
    font-size: 1.5rem;
    line-height: 1.3;
    font-weight: 700;
}

@media (min-width: 768px) {
    .heading-3-mobile {
        font-size: 2rem;
    }
}

.body-text-mobile {
    font-size: 0.9375rem;
    line-height: 1.6;
}

@media (min-width: 768px) {
    .body-text-mobile {
        font-size: 1rem;
    }
}

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

.section-padding-mobile {
    padding: var(--space-12) 0;
}

@media (min-width: 768px) {
    .section-padding-mobile {
        padding: var(--space-16) 0;
    }
}

@media (min-width: 1024px) {
    .section-padding-mobile {
        padding: var(--space-20) 0;
    }
}

.mb-mobile-4 {
    margin-bottom: var(--space-4);
}

@media (min-width: 768px) {
    .mb-mobile-4 {
        margin-bottom: var(--space-6);
    }
}

/* ===========================================
   HERO SECTION RESPONSIVE
   =========================================== */

.hero-mobile {
    min-height: 70vh;
    padding: var(--space-12) 0;
    display: flex;
    align-items: center;
}

@media (min-width: 768px) {
    .hero-mobile {
        min-height: 80vh;
        padding: var(--space-16) 0;
    }
}

@media (min-width: 1024px) {
    .hero-mobile {
        min-height: 90vh;
        padding: var(--space-20) 0;
    }
}

/* ===========================================
   NAVIGATION TABS MOBILE
   =========================================== */

.tabs-mobile {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--space-2);
}

.tabs-mobile::-webkit-scrollbar {
    display: none;
}

.tab-mobile {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    background: white;
    border: 1px solid var(--gray-300);
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.tab-mobile.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===========================================
   MODALES MOBILE
   =========================================== */

@media (max-width: 767px) {
    .modal-dialog {
        margin: var(--space-2);
        max-width: calc(100% - var(--space-4));
    }
    
    .modal-content {
        border-radius: var(--radius-lg);
    }
    
    .modal-fullscreen-mobile {
        max-width: 100%;
        margin: 0;
        height: 100vh;
    }
    
    .modal-fullscreen-mobile .modal-content {
        border-radius: 0;
        height: 100%;
    }
}

/* ===========================================
   TABLES RESPONSIVE
   =========================================== */

.table-responsive-mobile {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    .table-card-mobile {
        display: block;
    }
    
    .table-card-mobile thead {
        display: none;
    }
    
    .table-card-mobile tbody,
    .table-card-mobile tr {
        display: block;
    }
    
    .table-card-mobile tr {
        margin-bottom: var(--space-4);
        background: white;
        border-radius: var(--radius);
        box-shadow: var(--shadow-sm);
        padding: var(--space-4);
    }
    
    .table-card-mobile td {
        display: flex;
        justify-content: space-between;
        padding: var(--space-2) 0;
        border: none;
    }
    
    .table-card-mobile td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600);
    }
}

/* ===========================================
   BOTTOM NAVIGATION MOBILE
   =========================================== */

.bottom-nav-mobile {
    display: none;
}

@media (max-width: 767px) {
    .bottom-nav-mobile {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        padding: var(--space-2);
        justify-content: space-around;
    }
    
    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-1);
        padding: var(--space-2);
        color: var(--gray-600);
        text-decoration: none;
        font-size: 0.75rem;
        font-weight: 600;
        transition: var(--transition);
    }
    
    .bottom-nav-item i {
        font-size: 1.25rem;
    }
    
    .bottom-nav-item.active {
        color: var(--primary);
    }
    
    /* Ajuste le padding du body pour la bottom nav */
    body {
        padding-bottom: 70px;
    }
}

/* ===========================================
   FILTRES MOBILE (DRAWER)
   =========================================== */

@media (max-width: 767px) {
    .filters-drawer {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: white;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }
    
    .filters-drawer.open {
        transform: translateX(0);
    }
    
    .filters-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-4);
        border-bottom: 1px solid var(--gray-200);
        position: sticky;
        top: 0;
        background: white;
        z-index: 1;
    }
    
    .filters-content {
        padding: var(--space-4);
    }
    
    .filters-footer {
        position: sticky;
        bottom: 0;
        background: white;
        padding: var(--space-4);
        border-top: 1px solid var(--gray-200);
        display: flex;
        gap: var(--space-2);
    }
}

/* ===========================================
   IMAGES RESPONSIVE
   =========================================== */

img {
    max-width: 100%;
    height: auto;
}

.img-mobile-full {
    width: 100%;
    height: auto;
    object-fit: cover;
}

@media (min-width: 768px) {
    .img-mobile-full {
        width: auto;
        max-width: 100%;
    }
}

/* ===========================================
   AVATARS ET PROFILS RESPONSIVE
   =========================================== */

.profile-card-mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-3);
}

@media (min-width: 768px) {
    .profile-card-mobile {
        flex-direction: row;
        text-align: left;
    }
}

/* ===========================================
   STATS RESPONSIVE
   =========================================== */

.stats-row-mobile {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

@media (min-width: 768px) {
    .stats-row-mobile {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--space-4);
    }
}

/* ===========================================
   TOUCH-FRIENDLY ELEMENTS
   =========================================== */

.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===========================================
   SWIPE GESTURES
   =========================================== */

.swipeable {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.swipeable::-webkit-scrollbar {
    display: none;
}

.swipeable > * {
    scroll-snap-align: start;
}

/* ===========================================
   PULL TO REFRESH (VISUAL FEEDBACK)
   =========================================== */

.ptr-container {
    position: relative;
}

.ptr-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.ptr-pulling .ptr-indicator {
    opacity: 1;
}

/* ===========================================
   LOADING STATES MOBILE
   =========================================== */

.loading-mobile {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-8);
}

.spinner-mobile {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===========================================
   EMPTY STATES MOBILE
   =========================================== */

.empty-state-mobile {
    text-align: center;
    padding: var(--space-12) var(--space-4);
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--gray-300);
    margin-bottom: var(--space-4);
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    color: var(--gray-500);
    margin-bottom: var(--space-6);
}

/* ===========================================
   OPTIMISATIONS PERFORMANCE MOBILE
   =========================================== */

/* Éviter les reflows pendant le scroll */
.fixed-header {
    will-change: transform;
}

/* Optimiser les animations */
.animate {
    will-change: transform, opacity;
}

/* Réduire les ombres sur mobile */
@media (max-width: 767px) {
    .shadow-light-mobile {
        box-shadow: var(--shadow-sm) !important;
    }
}

/* ===========================================
   UTILITAIRES HIDE/SHOW RESPONSIVE
   =========================================== */

.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
}

.show-mobile {
    display: block;
}

@media (min-width: 768px) {
    .show-mobile {
        display: none;
    }
}

/* Flex utilities */
.flex-mobile-column {
    flex-direction: column;
}

@media (min-width: 768px) {
    .flex-mobile-column {
        flex-direction: row;
    }
}

/* ===========================================
   SAFE AREA (iPhone notch, etc.)
   =========================================== */

@supports (padding: max(0px)) {
    .safe-area-inset-top {
        padding-top: max(var(--space-4), env(safe-area-inset-top));
    }
    
    .safe-area-inset-bottom {
        padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
    }
}
