/**
 * COOPPÈRE MOBILE OPTIMIZATIONS
 * Interface responsive révolutionnaire
 */

/* ===== VARIABLES MOBILE ===== */
:root {
    --mobile-padding: 1rem;
    --mobile-header-height: 70px;
    --mobile-nav-height: 60px;
    --touch-target-size: 44px;
    --mobile-font-base: 16px;
    --mobile-font-small: 14px;
    --mobile-font-large: 18px;
}

/* ===== RESET MOBILE ===== */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    body {
        font-size: var(--mobile-font-base);
        line-height: 1.5;
        -webkit-text-size-adjust: 100%;
        overflow-x: hidden;
    }
    
    /* Optimisation des inputs pour mobile */
    input, textarea, select {
        font-size: var(--mobile-font-base) !important;
        border-radius: 8px;
        padding: 12px;
        min-height: var(--touch-target-size);
    }
    
    button, .btn {
        min-height: var(--touch-target-size);
        min-width: var(--touch-target-size);
        font-size: var(--mobile-font-base);
        padding: 12px 20px;
        border-radius: 8px;
        cursor: pointer;
    }
}

/* ===== HEADER MOBILE ===== */
@media (max-width: 768px) {
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--mobile-header-height);
        z-index: 1000;
        padding: 0.5rem 0;
    }
    
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0 var(--mobile-padding);
        gap: 1rem;
    }
    
    .logo-section {
        flex-shrink: 0;
    }
    
    .logo-img {
        width: 40px;
        height: 40px;
    }
    
    .brand-text {
        font-size: 1.2rem;
        margin-left: 0.5rem;
    }
    
    .user-info {
        display: none; /* Masqué sur mobile, disponible dans menu */
    }
    
    .nav-buttons {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e0e0e0;
        padding: 0.5rem;
        display: flex;
        justify-content: space-around;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        height: var(--mobile-nav-height);
    }
    
    .nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.25rem;
        font-size: 0.7rem;
        text-align: center;
        border: none;
        background: none;
        color: var(--forest-dark);
        text-decoration: none;
        min-height: auto;
        min-width: auto;
    }
    
    .nav-btn i {
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }
    
    .nav-btn.active {
        color: var(--primary-green);
    }
    
    /* Ajuster le contenu pour la navigation bottom */
    body {
        padding-top: var(--mobile-header-height);
        padding-bottom: var(--mobile-nav-height);
    }
}

/* ===== DASHBOARD MOBILE ===== */
@media (max-width: 768px) {
    .container {
        padding: var(--mobile-padding);
        margin: 1rem auto;
        max-width: 100%;
    }
    
    .welcome-section {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .welcome-section h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .balance-highlight {
        font-size: 1rem;
        padding: 0.75rem;
        margin: 1rem 0;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .actions-section {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .action-btn {
        padding: 1rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .action-btn i {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }
}

/* ===== FORMULAIRES MOBILE ===== */
@media (max-width: 768px) {
    .signup-form, .login-form {
        padding: 1.5rem;
        margin: 1rem;
        border-radius: 15px;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-group label {
        font-size: var(--mobile-font-base);
        margin-bottom: 0.5rem;
    }
    
    .form-submit {
        width: 100%;
        padding: 15px;
        font-size: var(--mobile-font-large);
        font-weight: 600;
        margin-top: 1rem;
    }
    
    /* Optimisation pour les claviers mobiles */
    input[type="email"] {
        -webkit-appearance: none;
    }
    
    input[type="password"] {
        -webkit-appearance: none;
    }
    
    input[type="tel"] {
        -webkit-appearance: none;
    }
    
    select {
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor'><polyline points='6,9 12,15 18,9'></polyline></svg>");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px;
        padding-right: 40px;
    }
}

/* ===== HERO SECTION MOBILE ===== */
@media (max-width: 768px) {
    .hero {
        min-height: 100vh;
        padding: 2rem 0;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 0 var(--mobile-padding);
        text-align: center;
    }
    
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .hero-features {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin: 1.5rem 0;
    }
    
    .hero-feature {
        justify-content: center;
        font-size: 0.9rem;
    }
}

/* ===== ANIMATIONS MOBILE ===== */
@media (max-width: 768px) {
    /* Réduire les animations pour économiser la batterie */
    .logo-intro {
        animation-duration: 2s;
    }
    
    /* Animations tactiles */
    .touch-feedback {
        transition: transform 0.1s ease;
    }
    
    .touch-feedback:active {
        transform: scale(0.95);
    }
    
    /* Effet de pression pour les boutons */
    .btn:active, .action-btn:active, .nav-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* ===== ACCESSIBILITÉ MOBILE ===== */
@media (max-width: 768px) {
    /* Améliorer la lisibilité */
    p, li, span {
        line-height: 1.6;
        letter-spacing: 0.3px;
    }
    
    /* Zones de toucher plus grandes */
    a, button, input, select, textarea {
        min-height: var(--touch-target-size);
        min-width: var(--touch-target-size);
    }
    
    /* Contraste amélioré */
    .text-small {
        font-size: var(--mobile-font-small);
        color: #555;
    }
    
    /* Focus visible */
    *:focus {
        outline: 2px solid var(--primary-green);
        outline-offset: 2px;
    }
}

/* ===== MODALS & POPUPS MOBILE ===== */
@media (max-width: 768px) {
    .modal, .popup {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 2000;
        padding: var(--mobile-padding);
        overflow-y: auto;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        background: white;
        padding: 1rem 0;
        border-bottom: 1px solid #eee;
        margin-bottom: 1rem;
    }
    
    .modal-close {
        position: absolute;
        top: 1rem;
        right: 1rem;
        font-size: 1.5rem;
        color: #666;
        background: none;
        border: none;
        min-height: var(--touch-target-size);
        min-width: var(--touch-target-size);
    }
}

/* ===== TABLES MOBILE ===== */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Cards layout pour tables complexes */
    .table-card {
        display: block;
        border: 1px solid #eee;
        border-radius: 8px;
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .table-card-header {
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: var(--primary-green);
    }
}

/* ===== PERFORMANCE MOBILE ===== */
@media (max-width: 768px) {
    /* Optimisation images */
    img {
        max-width: 100%;
        height: auto;
        loading: lazy;
    }
    
    /* Réduction des ombres pour performance */
    .card, .section {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* Simplification des gradients */
    .gradient-bg {
        background: var(--primary-green);
    }
}

/* ===== ÉTATS DE CONNEXION MOBILE ===== */
@media (max-width: 768px) {
    .offline-indicator {
        position: fixed;
        top: var(--mobile-header-height);
        left: 0;
        right: 0;
        background: #ff6b6b;
        color: white;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.9rem;
        z-index: 1001;
    }
    
    .loading-mobile {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(255,255,255,0.95);
        padding: 2rem;
        border-radius: 15px;
        text-align: center;
        z-index: 2000;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid var(--primary-green);
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin: 0 auto 1rem;
    }
}

/* ===== SWIPE GESTURES ===== */
@media (max-width: 768px) {
    .swipeable {
        touch-action: pan-x;
        -webkit-overflow-scrolling: touch;
    }
    
    .swipe-indicator {
        position: absolute;
        top: 50%;
        right: 1rem;
        transform: translateY(-50%);
        opacity: 0.5;
        font-size: 1.2rem;
    }
    
    .card-swipe {
        position: relative;
        overflow: hidden;
    }
    
    .card-swipe::after {
        content: '👈 Glissez';
        position: absolute;
        top: 50%;
        right: -100px;
        transform: translateY(-50%);
        background: var(--primary-green);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 20px;
        font-size: 0.8rem;
        transition: right 0.3s ease;
    }
    
    .card-swipe:hover::after {
        right: 1rem;
    }
}

/* ===== CONNEXION PWA ===== */
@media (max-width: 768px) {
    .pwa-install-prompt {
        position: fixed;
        bottom: calc(var(--mobile-nav-height) + 1rem);
        left: 1rem;
        right: 1rem;
        background: var(--primary-green);
        color: white;
        padding: 1rem;
        border-radius: 10px;
        text-align: center;
        z-index: 1500;
        box-shadow: 0 4px 20px rgba(74, 103, 65, 0.3);
    }
    
    .pwa-install-btn {
        background: white;
        color: var(--primary-green);
        border: none;
        padding: 0.75rem 1.5rem;
        border-radius: 25px;
        font-weight: 600;
        margin-top: 0.5rem;
        min-height: var(--touch-target-size);
    }
    
    .pwa-close {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        background: none;
        border: none;
        color: white;
        font-size: 1.2rem;
        min-height: 30px;
        min-width: 30px;
    }
} 