/**
 * MASSCOMPAS - CSS MOBILE-FIRST RESPONSIVE
 * Breakpoints: Mobile (320px+) → Tablet (768px+) → Desktop (1024px+)
 */

/* ========================================
   VARIABLES CSS GLOBALES
======================================== */
:root {
    --primary-blue: #002868;
    --primary-red: #CE1126;
    --primary-gold: #FFD700;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --touch-target: 44px; /* Minimum touch target */
    --border-radius: 8px;
    --transition: 0.3s ease;
}

/* ========================================
   BASE MOBILE-FIRST
======================================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-family: 'Poppins', sans-serif;
}

/* Container responsive */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-sm);
}

/* ========================================
   NAVIGATION MOBILE
======================================== */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--spacing-xs);
    min-width: var(--touch-target);
    min-height: var(--touch-target);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: linear-gradient(180deg, var(--primary-blue), var(--primary-red));
        flex-direction: column;
        align-items: flex-start;
        padding: var(--spacing-lg);
        gap: 0;
        transition: left var(--transition);
        box-shadow: 2px 0 20px rgba(0,0,0,0.3);
        z-index: 9999;
    }
    
    .nav.active {
        left: 0;
    }
    
    .nav a {
        width: 100%;
        padding: var(--spacing-sm);
        border-bottom: 1px solid rgba(255,255,255,0.1);
        font-size: 1.1rem;
    }
    
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
    }
    
    .mobile-overlay.active {
        display: block;
    }
    
    .header .logo a {
        font-size: 1.5rem;
    }
}

/* ========================================
   BOUTONS TOUCH-FRIENDLY
======================================== */
.btn {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    text-decoration: none;
    font-weight: 600;
}

@media (max-width: 768px) {
    .btn {
        width: 100%;
        padding: 1rem;
        font-size: 1.1rem;
    }
    
    .btn-sm {
        min-width: auto;
        width: auto;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* ========================================
   FORMULAIRES MOBILE
======================================== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    font-size: 1rem;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    min-height: var(--touch-target);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    transition: border var(--transition);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 40, 104, 0.1);
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr !important;
        gap: var(--spacing-sm);
    }
    
    .form-control,
    input,
    select,
    textarea {
        font-size: 16px; /* Évite zoom iOS */
    }
}

/* ========================================
   TABLEAUX RESPONSIVE
======================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Force scroll sur mobile */
}

.table th,
.table td {
    padding: var(--spacing-sm);
    text-align: left;
    border-bottom: 1px solid #eee;
}

@media (max-width: 768px) {
    /* Mode CARDS pour tableaux critiques */
    .table-mobile-cards {
        display: block;
        min-width: auto;
    }
    
    .table-mobile-cards thead {
        display: none;
    }
    
    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td {
        display: block;
        width: 100%;
    }
    
    .table-mobile-cards tr {
        margin-bottom: var(--spacing-md);
        padding: var(--spacing-sm);
        border: 1px solid #ddd;
        border-radius: var(--border-radius);
        background: white;
    }
    
    .table-mobile-cards td {
        padding: var(--spacing-xs) 0;
        border: none;
        text-align: left;
    }
    
    .table-mobile-cards td:before {
        content: attr(data-label);
        font-weight: 600;
        display: inline-block;
        width: 40%;
        color: var(--primary-blue);
    }
}

/* ========================================
   GRIDS RESPONSIVE
======================================== */
.grid-auto {
    display: grid;
    gap: var(--spacing-md);
    grid-template-columns: 1fr;
}

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

@media (min-width: 1024px) {
    .grid-auto {
        grid-template-columns: repeat(3, 1fr);
    }
}

.grid-auto-fit {
    display: grid;
    gap: var(--spacing-md);
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ========================================
   CARDS MOBILE
======================================== */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: var(--spacing-md);
    transition: transform var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@media (max-width: 768px) {
    .card {
        padding: var(--spacing-sm);
    }
}

/* ========================================
   SPACING UTILITIES
======================================== */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--spacing-xs) !important; }
.mt-2 { margin-top: var(--spacing-sm) !important; }
.mt-3 { margin-top: var(--spacing-md) !important; }
.mt-4 { margin-top: var(--spacing-lg) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--spacing-xs) !important; }
.mb-2 { margin-bottom: var(--spacing-sm) !important; }
.mb-3 { margin-bottom: var(--spacing-md) !important; }
.mb-4 { margin-bottom: var(--spacing-lg) !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: var(--spacing-xs) !important; }
.p-2 { padding: var(--spacing-sm) !important; }
.p-3 { padding: var(--spacing-md) !important; }
.p-4 { padding: var(--spacing-lg) !important; }

@media (max-width: 768px) {
    .mobile-hidden { display: none !important; }
    .mobile-text-center { text-align: center !important; }
    .mobile-full-width { width: 100% !important; }
}

/* ========================================
   LOADING & FEEDBACK
======================================== */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0,0,0,0.1);
    border-left-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.toast {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .toast {
        width: 90%;
        max-width: 350px;
    }
}

/* ========================================
   SPLASH SCREEN
======================================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-red));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.5s ease;
}

.splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.splash-logo {
    font-size: 3rem;
    color: white;
    font-weight: bold;
    margin-bottom: var(--spacing-md);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* ========================================
   OPTIMISATIONS PERFORMANCE
======================================== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy.loaded {
    opacity: 1;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Prevent iOS bounce scroll */
body {
    overscroll-behavior-y: none;
}
