/* ============================================================================
   MOBILE OPTIMIZATIONS - LyciaMenu V2
   Améliorations ergonomiques pour mobile
   ============================================================================ */

/* ============================================================================
   BREAKPOINTS
   ============================================================================ */
:root {
    --mobile-breakpoint: 768px;
    --tablet-breakpoint: 1024px;
}

/* ============================================================================
   BASE MOBILE IMPROVEMENTS
   ============================================================================ */

@media (max-width: 768px) {
    /* Améliorer la taille des zones cliquables */
    button, 
    a.btn, 
    input[type="submit"],
    .clickable {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
        font-size: 16px; /* Évite le zoom sur iOS */
    }
    
    /* Améliorer les champs de formulaire */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Évite le zoom sur iOS */
        padding: 12px 16px;
        min-height: 44px;
        width: 100%;
        border-radius: 8px;
    }
    
    /* Espacements généreux */
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    /* Marges verticales réduites */
    h1 {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.5rem;
        margin-bottom: 0.875rem;
    }
    
    h3 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    /* Texte plus lisible */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    /* Espacements de sections */
    .section {
        padding: 2rem 1rem;
    }
}

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

@media (max-width: 768px) {
    /* Header mobile */
    header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .header-content {
        padding: 12px 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Logo mobile */
    .logo {
        font-size: 1.25rem;
        font-weight: 700;
    }
    
    /* Menu burger */
    .mobile-menu-toggle {
        display: block;
        width: 44px;
        height: 44px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        position: relative;
    }
    
    .mobile-menu-toggle span {
        display: block;
        width: 28px;
        height: 3px;
        background: var(--color-text);
        margin: 6px 0;
        transition: all 0.3s ease;
        border-radius: 2px;
    }
    
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 8px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }
    
    /* Menu mobile */
    .mobile-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        z-index: 999;
        padding: 1rem;
    }
    
    .mobile-menu.active {
        transform: translateX(0);
    }
    
    .mobile-menu nav {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .mobile-menu a {
        padding: 16px 20px;
        display: flex;
        align-items: center;
        gap: 12px;
        border-radius: 8px;
        transition: background 0.2s;
        font-size: 16px;
        font-weight: 500;
    }
    
    .mobile-menu a:hover {
        background: var(--color-gray-100);
    }
    
    .mobile-menu a i {
        width: 24px;
        text-align: center;
        font-size: 18px;
    }
}

/* ============================================================================
   FORMULAIRES MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    /* Stack les éléments de formulaire */
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-group {
        width: 100%;
    }
    
    /* Labels plus grands */
    label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 8px;
        display: block;
    }
    
    /* Groupes de boutons */
    .btn-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* Formulaire de recherche */
    .search-form {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    /* Autocomplétion mobile */
    .autocomplete-dropdown,
    .suggestions-dropdown {
        position: fixed;
        left: 16px;
        right: 16px;
        top: auto;
        max-height: 50vh;
        z-index: 1001;
    }
}

/* ============================================================================
   GRILLES RESPONSIVES
   ============================================================================ */

@media (max-width: 768px) {
    /* Grilles en une colonne */
    .grid,
    .card-grid,
    .recipe-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Cartes pleine largeur */
    .card {
        width: 100%;
    }
    
    /* Suppression des marges latérales */
    .card {
        margin-left: 0;
        margin-right: 0;
    }
}

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

@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    
    .modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        border-bottom: 1px solid var(--color-gray-200);
        padding: 16px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid var(--color-gray-200);
        padding: 16px;
    }
}

/* ============================================================================
   TABLEAUX MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    /* Scroll horizontal pour les tableaux */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Ou transformation en cartes */
    .table-card {
        display: block;
    }
    
    .table-card thead {
        display: none;
    }
    
    .table-card tbody,
    .table-card tr {
        display: block;
        margin-bottom: 1rem;
    }
    
    .table-card tr {
        background: white;
        border: 1px solid var(--color-gray-200);
        border-radius: 8px;
        padding: 1rem;
    }
    
    .table-card td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }
    
    .table-card td::before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 1rem;
    }
}

/* ============================================================================
   NAVIGATION PAR ONGLETS MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
    
    .tabs-nav {
        display: flex;
        gap: 0.5rem;
        min-width: min-content;
    }
    
    .tab-button {
        white-space: nowrap;
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* ============================================================================
   CARDS & LISTS MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    /* Cartes de recettes */
    .recipe-card {
        display: flex;
        flex-direction: column;
    }
    
    .recipe-card img {
        width: 100%;
        height: 200px;
        object-fit: cover;
    }
    
    .recipe-card-content {
        padding: 1rem;
    }
    
    .recipe-card-title {
        font-size: 1.125rem;
        margin-bottom: 0.5rem;
    }
    
    .recipe-card-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Listes d'ingrédients */
    .ingredient-list {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .ingredient-item {
        display: flex;
        align-items: center;
        padding: 12px;
        background: var(--color-gray-50);
        border-radius: 8px;
    }
}

/* ============================================================================
   BOTTOM NAVIGATION (Style App Mobile)
   ============================================================================ */

@media (max-width: 768px) {
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid var(--color-gray-200);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1000;
        padding: 8px 0;
    }
    
    .bottom-nav-items {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    
    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px 16px;
        text-decoration: none;
        color: var(--color-gray-600);
        transition: color 0.2s;
        flex: 1;
        text-align: center;
    }
    
    .bottom-nav-item i {
        font-size: 20px;
    }
    
    .bottom-nav-item span {
        font-size: 11px;
        font-weight: 500;
    }
    
    .bottom-nav-item.active,
    .bottom-nav-item:hover {
        color: var(--color-primary);
    }
    
    /* Ajouter un padding en bas du body pour la bottom nav */
    body {
        padding-bottom: 70px;
    }
}

/* ============================================================================
   FLOATING ACTION BUTTON (FAB)
   ============================================================================ */

@media (max-width: 768px) {
    .fab {
        position: fixed;
        bottom: 80px; /* Au-dessus de la bottom nav */
        right: 16px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--color-primary);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(0,0,0,0.25);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        cursor: pointer;
        transition: transform 0.2s, box-shadow 0.2s;
        z-index: 999;
    }
    
    .fab:active {
        transform: scale(0.95);
    }
    
    .fab:hover {
        box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    }
}

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

@media (max-width: 768px) {
    .swipeable {
        position: relative;
        touch-action: pan-y;
    }
    
    .swipeable::after {
        content: '→';
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--color-gray-400);
        font-size: 20px;
        opacity: 0.5;
    }
}

/* ============================================================================
   AMÉLIORATION DES PERFORMANCES
   ============================================================================ */

@media (max-width: 768px) {
    /* Réduire les animations sur mobile */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Optimiser le scroll */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Éviter le reflow */
    img {
        max-width: 100%;
        height: auto;
    }
}

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

@media (max-width: 768px) {
    /* Focus visible */
    *:focus {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }
    
    /* Skip to content */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: var(--color-primary);
        color: white;
        padding: 8px 16px;
        text-decoration: none;
        z-index: 10000;
    }
    
    .skip-to-content:focus {
        top: 0;
    }
}

/* ============================================================================
   LANDSCAPE MODE
   ============================================================================ */

@media (max-width: 768px) and (orientation: landscape) {
    /* Réduire les hauteurs en mode paysage */
    .hero {
        min-height: 50vh;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    /* Cacher certains éléments non essentiels */
    .decorative {
        display: none;
    }
}

/* ============================================================================
   TABLET OPTIMIZATIONS
   ============================================================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    /* Grilles 2 colonnes sur tablette */
    .grid,
    .card-grid,
    .recipe-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ============================================================================
   TOUCH IMPROVEMENTS
   ============================================================================ */

@media (hover: none) and (pointer: coarse) {
    /* Améliorer les hover states pour le tactile */
    button:hover,
    a:hover {
        opacity: 1;
    }
    
    button:active,
    a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    
    /* Désactiver les tooltips sur tactile */
    [title] {
        position: relative;
    }
    
    [title]::after {
        display: none;
    }
}
