/* ==========================================================================
   MOBILE & TABLET OPTIMIZATIONS - Formulaires Avancés
   ========================================================================== */

/* Formulaires tactiles améliorés */
.form-mobile-optimized .form-control {
    min-height: 52px;
    font-size: 16px; /* Empêche le zoom automatique sur iOS */
    padding: 0.875rem 1rem;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

.form-mobile-optimized .form-control:focus {
    border-color: var(--pal-blue-light);
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.15);
    transform: scale(1.02);
}

.form-mobile-optimized .form-label {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* Validation en temps réel */
.form-control.is-valid {
    border-color: var(--pal-green);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23059669'%3e%3cpath d='M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zm3.97 4.97a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.061L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
}

.form-control.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23dc3545'%3e%3cpath d='M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
}

/* Boutons formulaire mobile */
.form-mobile-optimized .btn-submit {
    width: 100%;
    min-height: 56px;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1rem;
    border-radius: 12px;
    transition: all 0.3s ease;
}

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

/* Groupes de champs optimisés */
.form-group-mobile {
    margin-bottom: 1.5rem;
}

.form-group-mobile:last-child {
    margin-bottom: 2rem;
}

/* Sélecteurs et cases à cocher tactiles */
.form-check-input {
    width: 1.5rem;
    height: 1.5rem;
    margin-top: 0.125rem;
}

.form-check-label {
    font-size: 1rem;
    padding-left: 0.5rem;
    cursor: pointer;
}

.form-select {
    min-height: 52px;
    font-size: 16px;
    padding: 0.875rem 1rem;
    background-position: right 1rem center;
}

/* Feedback utilisateur amélioré */
.invalid-feedback, .valid-feedback {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding-left: 0.25rem;
}

/* Champs de fichier optimisés */
.form-control[type="file"] {
    padding: 0.75rem;
    cursor: pointer;
}

.form-control[type="file"]::-webkit-file-upload-button {
    background: var(--pal-blue);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-right: 1rem;
    cursor: pointer;
}

/* ==========================================================================
   TABLEAUX RESPONSIVE
   ========================================================================== */

/* Container de table mobile */
.table-mobile-container {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

/* Table cards pour très petits écrans */
@media (max-width: 576px) {
    .table-responsive-cards {
        display: none;
    }
    
    .table-cards {
        display: block;
    }
    
    .table-card-item {
        background: white;
        border-radius: 12px;
        padding: 1.25rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border: 1px solid #e5e7eb;
    }
    
    .table-card-header {
        font-weight: 600;
        color: var(--pal-blue);
        margin-bottom: 0.75rem;
        font-size: 1.1rem;
    }
    
    .table-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .table-card-row:last-child {
        border-bottom: none;
    }
    
    .table-card-label {
        font-weight: 500;
        color: var(--text-secondary);
        font-size: 0.9rem;
    }
    
    .table-card-value {
        font-weight: 400;
        text-align: right;
        flex-shrink: 0;
    }
}

@media (min-width: 577px) {
    .table-cards {
        display: none;
    }
    
    .table-responsive-cards {
        display: block;
    }
}

/* Sticky header pour grandes tables */
.table-sticky-header thead th {
    position: sticky;
    top: 0;
    background: var(--pal-blue);
    z-index: 10;
    border: none;
}

/* ==========================================================================
   IMAGES RESPONSIVE & PERFORMANCE
   ========================================================================== */

/* Images adaptatives */
.img-responsive {
    width: 100%;
    height: auto;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.img-responsive:hover {
    transform: scale(1.02);
}

/* Lazy loading placeholder */
.img-lazy {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Hero images responsive */
.hero-image {
    max-width: 100%;
    height: auto;
}

@media (max-width: 768px) {
    .hero-image {
        margin-top: 2rem;
        max-width: 90%;
    }
}

/* ==========================================================================
   EXPÉRIENCE TACTILE AMÉLIORÉE
   ========================================================================== */

/* Zones de toucher minimales (44px) */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Feedback tactile */
.btn, .nav-link, .dropdown-item, .list-group-item {
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
}

.btn:active, .nav-link:active, .dropdown-item:active {
    transform: scale(0.97);
}

/* Amélioration des modals pour mobile */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .modal-content {
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 1.5rem;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-footer {
        padding: 1.5rem;
        border-top: 1px solid #e5e7eb;
    }
}

/* ==========================================================================
   NOTIFICATIONS MOBILES
   ========================================================================== */

@media (max-width: 768px) {
    .toast {
        max-width: calc(100vw - 2rem);
        margin: 1rem;
    }
    
    .alert {
        margin-bottom: 1rem;
        border-radius: 12px;
        padding: 1rem 1.25rem;
    }
}

/* ==========================================================================
   ANIMATIONS OPTIMISÉES POUR PERFORMANCE
   ========================================================================== */

/* Réduction des animations sur connexions lentes */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Accélération matérielle pour animations fluides */
.animated-element {
    will-change: transform;
    transform: translateZ(0);
}

/* ==========================================================================
   UTILITAIRES MOBILE
   ========================================================================== */

/* Espacement mobile */
.mb-mobile-1 { margin-bottom: 0.5rem !important; }
.mb-mobile-2 { margin-bottom: 1rem !important; }
.mb-mobile-3 { margin-bottom: 1.5rem !important; }
.mb-mobile-4 { margin-bottom: 2rem !important; }

.p-mobile-1 { padding: 0.5rem !important; }
.p-mobile-2 { padding: 1rem !important; }
.p-mobile-3 { padding: 1.5rem !important; }

/* Texte mobile */
.text-mobile-sm { font-size: 0.9rem !important; }
.text-mobile-md { font-size: 1rem !important; }
.text-mobile-lg { font-size: 1.1rem !important; }

/* Masquer sur mobile */
@media (max-width: 768px) {
    .d-mobile-none { display: none !important; }
    .d-mobile-block { display: block !important; }
    .d-mobile-flex { display: flex !important; }
}

/* Masquer sur desktop */
@media (min-width: 769px) {
    .d-desktop-none { display: none !important; }
}