/**
 * OPTIMISATIONS MOBILE GLOBALES
 * Garantir une expérience mobile parfaite
 */

/* ==========================================
BASE MOBILE OPTIMIZATIONS
   ========================================== */

/* Smooth scrolling on iOS */
html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Better font rendering on mobile */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Remove tap highlight on mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Better touch scrolling */
.overflow-auto,
.modal,
.dropdown-menu {
    -webkit-overflow-scrolling: touch;
}

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

/* Minimum touch target size (44x44px Apple, 48x48px Google) */
/* Exclusion du header pour éviter les conflits */
button:not(.mobile-menu-btn):not(.search-trigger):not(.search-close):not(.notif-trigger):not(.user-trigger):not(.guest-trigger),
input[type="button"],
input[type="submit"],
input[type="reset"],
.btn:not(.btn-login):not(.btn-register):not(.btn-create),
.clickable {
    min-height: 44px;
    min-width: 44px;
}

/* Better form inputs on mobile */
input,
textarea,
select {
    font-size: 16px; /* Prevent zoom on iOS */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Remove default iOS button styles */
/* Exclusion du header pour préserver le design moderne */
button:not(.pro-header button),
input[type="button"],
input[type="submit"],
input[type="reset"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Better select on mobile */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2.5rem;
}

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

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

/* Prevent image drag on mobile */
img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-select: none;
}

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

@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 0.875rem;
        padding-right: 0.875rem;
    }
    
    /* Reduce row gaps */
    .row {
        --bs-gutter-x: 1rem;
    }
}

@media (max-width: 375px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .row {
        --bs-gutter-x: 0.75rem;
    }
}

/* ==========================================
   MODAL OPTIMIZATIONS FOR MOBILE
   ========================================== */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-fullscreen-sm-down {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }
    
    .modal-fullscreen-sm-down .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }
}

/* ==========================================
   DROPDOWN OPTIMIZATIONS FOR MOBILE
   ========================================== */

@media (max-width: 768px) {
    .dropdown-menu {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .dropdown-item {
        padding: 0.875rem 1rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ==========================================
   CARD OPTIMIZATIONS
   ========================================== */

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

@media (max-width: 576px) {
    .card-body {
        padding: 0.875rem;
    }
}

/* ==========================================
   TYPOGRAPHY MOBILE
   ========================================== */

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.125rem; }
    h6 { font-size: 1rem; }
    
    .display-1 { font-size: 3.5rem; }
    .display-2 { font-size: 3rem; }
    .display-3 { font-size: 2.5rem; }
    .display-4 { font-size: 2rem; }
    .display-5 { font-size: 1.75rem; }
    .display-6 { font-size: 1.5rem; }
}

@media (max-width: 576px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .display-1 { font-size: 3rem; }
    .display-2 { font-size: 2.5rem; }
    .display-3 { font-size: 2rem; }
    .display-4 { font-size: 1.75rem; }
}

/* ==========================================
   BUTTON OPTIMIZATIONS
   ========================================== */

@media (max-width: 768px) {
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }
    
    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1.125rem;
    }
    
    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* Full width buttons on mobile */
.btn-mobile-full {
    width: 100%;
}

@media (max-width: 576px) {
    .btn-mobile-full,
    .btn-mobile-full-sm {
        width: 100%;
        display: block;
    }
}

/* ==========================================
   NAVBAR MOBILE
   ========================================== */

@media (max-width: 992px) {
    .navbar-nav {
        padding: 1rem 0;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ==========================================
   TABLE RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
    .table-responsive {
        border: 0;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
}

/* ==========================================
   SPACING UTILITIES MOBILE
   ========================================== */

@media (max-width: 768px) {
    .py-mobile-3 { padding-top: 1rem; padding-bottom: 1rem; }
    .py-mobile-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
    .py-mobile-5 { padding-top: 2rem; padding-bottom: 2rem; }
    
    .my-mobile-3 { margin-top: 1rem; margin-bottom: 1rem; }
    .my-mobile-4 { margin-top: 1.5rem; margin-bottom: 1.5rem; }
    .my-mobile-5 { margin-top: 2rem; margin-bottom: 2rem; }
}

/* ==========================================
   ANIMATIONS MOBILE (reduce motion)
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================
   LANDSCAPE MOBILE
   ========================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .hero-section,
    .hero-section-v2 {
        padding: 1.5rem 0;
    }
    
    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ==========================================
   DARK MODE SUPPORT
   ========================================== */

@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #667eea;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 10000;
}

.skip-to-main:focus {
    top: 0;
}

/* ==========================================
   PERFORMANCE
   ========================================== */

/* GPU acceleration for animations */
.animated,
[data-aos] {
    will-change: transform, opacity;
}

/* Prevent layout shift */
img[width][height] {
    height: auto;
}

/* ==========================================
   UTILITY CLASSES MOBILE
   ========================================== */

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
    
    .mobile-hidden {
        display: none;
    }
}

/* Text alignment on mobile */
@media (max-width: 768px) {
    .text-mobile-center {
        text-align: center;
    }
    
    .text-mobile-left {
        text-align: left;
    }
}
