/**
 * Mobile UI Improvements
 * Améliorations spécifiques pour mobile
 */

/* ========================================
   TOPBAR MOBILE
   ======================================== */

@media (max-width: 1023px) {
    #topbar {
        height: 64px;
        padding: 0 1rem;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        z-index: 1000; /* Au-dessus du panel de pointage */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }

    .topbar-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--gray-900);
    }

    /* Bouton menu hamburger */
    .menu-toggle {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.5rem;
        transition: all 0.2s ease;
    }

    .menu-toggle:active {
        background: var(--gray-100);
        transform: scale(0.95);
    }

    /* User menu mobile */
    .user-menu-mobile {
        position: relative;
    }

    .user-avatar-mobile {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: 2px solid var(--yaye-green);
    }
}

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

@media (max-width: 768px) {
    /* Tabs horizontaux scrollables */
    .nav-tabs-mobile {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        background: white;
        border-bottom: 1px solid var(--gray-200);
        position: sticky;
        top: 64px;
        z-index: 100;
    }

    .nav-tabs-mobile::-webkit-scrollbar {
        display: none;
    }

    .nav-tab-mobile {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.625rem 1rem;
        border-radius: 0.5rem;
        font-size: 0.875rem;
        font-weight: 500;
        white-space: nowrap;
        flex-shrink: 0;
        color: var(--gray-600);
        background: transparent;
        border: 1px solid transparent;
        transition: all 0.2s ease;
    }

    .nav-tab-mobile.active {
        color: var(--yaye-green);
        background: rgba(34, 197, 94, 0.1);
        border-color: var(--yaye-green);
    }

    .nav-tab-mobile svg {
        width: 16px;
        height: 16px;
    }
}

/* ========================================
   CARDS MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Card avec shadow douce */
    .card-mobile-enhanced {
        background: white;
        border-radius: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        margin-bottom: 1rem;
        overflow: hidden;
    }

    /* Card header sticky */
    .card-header-sticky {
        position: sticky;
        top: 64px;
        z-index: 50;
        background: white;
        border-bottom: 1px solid var(--gray-200);
    }

    /* Liste d'items mobile */
    .list-item-mobile {
        display: flex;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid var(--gray-100);
        transition: background 0.2s ease;
    }

    .list-item-mobile:active {
        background: var(--gray-50);
    }

    .list-item-mobile:last-child {
        border-bottom: none;
    }

    .list-item-icon {
        width: 48px;
        height: 48px;
        border-radius: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 1rem;
        flex-shrink: 0;
    }

    .list-item-content {
        flex: 1;
        min-width: 0;
    }

    .list-item-title {
        font-size: 0.938rem;
        font-weight: 600;
        color: var(--gray-900);
        margin-bottom: 0.25rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .list-item-subtitle {
        font-size: 0.813rem;
        color: var(--gray-600);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .list-item-action {
        margin-left: 0.75rem;
        color: var(--gray-400);
    }
}

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

@media (max-width: 768px) {
    .fab-container {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 900;
    }

    .fab {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--yaye-green) 0%, var(--yaye-green-dark) 100%);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .fab:active {
        transform: scale(0.9);
    }

    .fab svg {
        width: 24px;
        height: 24px;
    }

    /* FAB avec label */
    .fab-extended {
        width: auto;
        border-radius: 28px;
        padding: 0 1.5rem;
        gap: 0.5rem;
    }

    .fab-label {
        font-size: 0.875rem;
        font-weight: 600;
    }
}

/* ========================================
   BOTTOM SHEET MOBILE
   ======================================== */

@media (max-width: 768px) {
    .bottom-sheet-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .bottom-sheet-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .bottom-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-radius: 20px 20px 0 0;
        z-index: 1001;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        max-height: 90vh;
        display: flex;
        flex-direction: column;
    }

    .bottom-sheet.active {
        transform: translateY(0);
    }

    .bottom-sheet-handle {
        width: 40px;
        height: 4px;
        background: var(--gray-300);
        border-radius: 2px;
        margin: 12px auto 8px;
    }

    .bottom-sheet-header {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--gray-200);
    }

    .bottom-sheet-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--gray-900);
    }

    .bottom-sheet-body {
        flex: 1;
        overflow-y: auto;
        padding: 1.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .bottom-sheet-footer {
        padding: 1rem 1.5rem;
        border-top: 1px solid var(--gray-200);
        background: var(--gray-50);
    }
}

/* ========================================
   PULL TO REFRESH
   ======================================== */

@media (max-width: 768px) {
    .pull-to-refresh-indicator {
        position: fixed;
        top: 64px;
        left: 50%;
        transform: translateX(-50%);
        background: white;
        padding: 0.5rem 1rem;
        border-radius: 2rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.875rem;
        color: var(--gray-600);
        z-index: 100;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .pull-to-refresh-indicator.visible {
        opacity: 1;
        visibility: visible;
    }

    .pull-to-refresh-spinner {
        width: 16px;
        height: 16px;
        border: 2px solid var(--gray-300);
        border-top-color: var(--yaye-green);
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

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

/* ========================================
   BADGES & CHIPS MOBILE
   ======================================== */

@media (max-width: 768px) {
    .badge-mobile {
        display: inline-flex;
        align-items: center;
        padding: 0.25rem 0.625rem;
        border-radius: 1rem;
        font-size: 0.75rem;
        font-weight: 600;
        line-height: 1;
    }

    .badge-success {
        background: #d1fae5;
        color: #059669;
    }

    .badge-warning {
        background: #fef3c7;
        color: #d97706;
    }

    .badge-danger {
        background: #fee2e2;
        color: #dc2626;
    }

    .badge-info {
        background: #dbeafe;
        color: #2563eb;
    }

    .chip-mobile {
        display: inline-flex;
        align-items: center;
        gap: 0.375rem;
        padding: 0.375rem 0.75rem;
        background: var(--gray-100);
        border-radius: 1.5rem;
        font-size: 0.813rem;
        color: var(--gray-700);
    }

    .chip-mobile svg {
        width: 14px;
        height: 14px;
    }
}

/* ========================================
   EMPTY STATES MOBILE
   ======================================== */

@media (max-width: 768px) {
    .empty-state-mobile {
        text-align: center;
        padding: 3rem 1.5rem;
    }

    .empty-state-icon {
        width: 80px;
        height: 80px;
        margin: 0 auto 1.5rem;
        opacity: 0.5;
    }

    .empty-state-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--gray-900);
        margin-bottom: 0.5rem;
    }

    .empty-state-description {
        font-size: 0.875rem;
        color: var(--gray-600);
        margin-bottom: 1.5rem;
        line-height: 1.6;
    }

    .empty-state-action {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        background: var(--yaye-green);
        color: white;
        border-radius: 0.5rem;
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.2s ease;
    }

    .empty-state-action:active {
        transform: scale(0.96);
        background: var(--yaye-green-dark);
    }
}

/* ========================================
   TOUCH FEEDBACK
   ======================================== */

@media (max-width: 768px) {
    /* Améliorer le feedback tactile */
    .touch-feedback {
        position: relative;
        overflow: hidden;
    }

    .touch-feedback::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.1);
        transform: translate(-50%, -50%);
        transition: width 0.3s, height 0.3s;
    }

    .touch-feedback:active::after {
        width: 200px;
        height: 200px;
    }

    /* Désactiver le highlight sur tap */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    /* Améliorer la zone de tap */
    .btn,
    button,
    a {
        min-height: 44px; /* Recommandation Apple */
        min-width: 44px;
    }
}

/* ========================================
   SAFE AREA (iPhone notch, etc.)
   ======================================== */

@media (max-width: 768px) {
    @supports (padding: max(0px)) {
        #topbar {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }

        .bottom-sheet,
        .fab-container {
            padding-bottom: env(safe-area-inset-bottom);
        }

        #content {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

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

@media (max-width: 768px) {
    /* Désactiver les animations coûteuses sur mobile */
    .reduce-motion * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Optimiser le scroll */
    .scroll-optimized {
        -webkit-overflow-scrolling: touch;
        will-change: scroll-position;
    }

    /* Optimiser les transformations */
    .transform-optimized {
        will-change: transform;
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}
