/* ============================================
   ADVANCED MOBILE UX IMPROVEMENTS
   Week 2-4 Enhancements
   Created: 2025-11-11
   ============================================ */

/* ============================================
   WEEK 2: ENHANCED MOBILE NAVIGATION
   ============================================ */

/* Swipe Feedback Animation */
@keyframes swipeFeedback {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

.swipe-indicator {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.swipe-indicator.show {
    opacity: 1;
}

/* Bottom Navigation Bar */
.bottom-navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: none; /* Hidden by default, shown when logged in */
}

@media (max-width: 768px) {
    .bottom-navigation {
        display: block;
    }

    /* Adjust content to account for bottom nav */
    #app {
        padding-bottom: 80px;
    }
}

.bottom-nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 64px;
    padding: 0 8px;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item:active svg {
    transform: scale(0.9);
}

/* Primary center button */
.nav-item-primary {
    position: relative;
    margin: 0 8px;
}

.nav-item-primary::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-color), var(--success-color));
    border-radius: 50%;
    z-index: -1;
}

.nav-item-primary svg {
    color: var(--white);
    width: 28px;
    height: 28px;
}

.nav-item-primary span {
    color: var(--primary-color);
    font-weight: 600;
}

/* Mobile Modal Styles */
.mobile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-modal.active {
    opacity: 1;
}

.mobile-modal-content {
    background: var(--white);
    width: 100%;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-modal.active .mobile-modal-content {
    transform: translateY(0);
}

.mobile-modal.closing .mobile-modal-content {
    transform: translateY(100%);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0 auto 16px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
}

/* Quiz Mode Selection Modal */
.mode-select-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    margin-bottom: 12px;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-select-btn:active {
    transform: scale(0.98);
    background: var(--white);
}

.mode-icon {
    font-size: 32px;
}

.mode-info h3 {
    margin: 0 0 4px;
    font-size: 18px;
    color: var(--text-dark);
}

.mode-info p {
    margin: 0;
    font-size: 14px;
    color: var(--text-light);
}

/* Progressive Disclosure */
.show-more-btn {
    color: var(--primary-color);
    background: none;
    border: none;
    padding: 4px 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s ease;
}

.show-more-btn:hover {
    opacity: 0.8;
}

/* ============================================
   WEEK 3: ACCESSIBILITY & PERFORMANCE
   ============================================ */

/* Voice Input Button */
.voice-input-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--white);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 90;
}

.voice-input-btn:hover {
    transform: scale(1.05);
}

.voice-input-btn.listening {
    background: var(--danger-color);
    border-color: var(--danger-color);
    animation: pulse 1.5s infinite;
}

.voice-input-btn.listening svg {
    color: var(--white);
}

.voice-input-btn span {
    display: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(211, 47, 47, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0);
    }
}

.voice-feedback {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 20px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Dark Mode - REMOVED (feature disabled) */

/* Network Status Notifications */
.network-notification {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -20px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.offline .network-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #FF9800;
    color: white;
    padding: 8px;
    text-align: center;
    font-size: 14px;
    z-index: 10000;
}

/* ============================================
   WEEK 4: PROGRESSIVE WEB APP
   ============================================ */

/* Install Banner */
.install-banner {
    position: fixed;
    bottom: 80px;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 16px;
    z-index: 95;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.install-banner.active {
    transform: translateY(0);
}

.install-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
    margin: 0 auto;
}

.install-icon {
    font-size: 40px;
}

.install-text {
    flex: 1;
}

.install-text h3 {
    margin: 0 0 4px;
    font-size: 16px;
    color: var(--text-dark);
}

.install-text p {
    margin: 0;
    font-size: 14px;
    color: var(--text-light);
}

.install-btn {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}

.install-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
}

/* PWA Mode Adjustments */
.pwa-mode .install-banner {
    display: none;
}

.pwa-mode .theme-toggle {
    top: 10px;
    right: 10px;
}

/* A/B Testing Variants */
.ab-buttons-rounded .btn {
    border-radius: 24px;
}

.ab-buttons-gradient .btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--success-color));
}

.ab-buttons-gradient .btn-primary:hover {
    background: linear-gradient(135deg, var(--success-color), var(--primary-color));
}

/* Progress Percentage Display */
.progress-percentage {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    padding: 8px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (min-width: 769px) {
    /* Hide mobile-only elements on desktop */
    .bottom-navigation,
    .voice-input-btn,
    .install-banner {
        display: none;
    }

    .theme-toggle {
        top: 80px;
    }
}

@media (max-width: 350px) {
    /* Extra small devices */
    .bottom-nav-container {
        padding: 0 4px;
    }

    .nav-item span {
        font-size: 10px;
    }

    .nav-item svg {
        width: 20px;
        height: 20px;
    }
}

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

/* Use CSS containment for better performance */
.quiz-container {
    contain: layout style;
}

.modal {
    contain: layout style paint;
}

/* Hardware acceleration for frequently animated elements */
.mobile-modal-content,
.install-banner,
.bottom-navigation {
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .mobile-modal-content,
    .install-banner,
    .swipe-feedback,
    .voice-feedback {
        transition: none !important;
        animation: none !important;
    }
}