/* Mobile-Specific Styles for QuizNotion */

/* ========== Base Mobile Styles ========== */
@media (max-width: 767px) {
    /* Prevent horizontal scrolling */
    html, body {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        touch-action: pan-y;
    }
    
    /* Reduce padding on mobile */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Hide desktop navigation on mobile */
    .navbar-collapse {
        background-color: var(--navbar-bg);
        margin: 0 -15px;
        padding: 15px;
    }
}

/* ========== Interactive Quiz Mobile Styles ========== */
@media (max-width: 767px) {
    /* Mobile Quiz Header */
    .quiz-header-mobile {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: var(--bg-primary);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        padding: 10px 15px;
    }
    
    /* Compact header layout */
    .mobile-header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-quiz-title {
        font-size: 16px;
        font-weight: 600;
        margin: 0;
        max-width: 50%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .mobile-stats {
        display: flex;
        gap: 10px;
        align-items: center;
    }
    
    .mobile-stat {
        display: flex;
        align-items: center;
        gap: 3px;
        font-size: 14px;
        cursor: pointer;
        padding: 5px 8px;
        border-radius: 15px;
        background: var(--bg-secondary);
        transition: transform 0.2s;
    }
    
    .mobile-stat:active {
        transform: scale(0.95);
    }
    
    .mobile-stat i {
        font-size: 12px;
    }
    
    /* Progress bar in header */
    .mobile-progress {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: var(--bg-secondary);
    }
    
    .mobile-progress-fill {
        height: 100%;
        background: var(--bs-primary);
        transition: width 0.3s ease;
    }
    
    /* Content area adjustment */
    .mobile-quiz-content {
        padding-top: 70px; /* Space for fixed header */
        padding-bottom: 80px; /* Space for bottom nav */
        min-height: 100vh;
    }
    
    /* Mobile Question Display */
    .mobile-question-container {
        padding: 15px;
    }
    
    .question-text {
        font-size: 18px;
        line-height: 1.5;
        margin-bottom: 20px;
    }
    
    /* Mobile Option Cards */
    .mobile-option-card {
        display: block;
        width: 100%;
        margin: 10px 0;
        padding: 15px;
        background: var(--bg-secondary);
        border: 2px solid transparent;
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.2s;
        position: relative;
        text-align: left;
    }
    
    .mobile-option-card:active {
        transform: scale(0.98);
        background: var(--bg-active);
    }
    
    .mobile-option-card.selected {
        border-color: var(--bs-primary);
        background: var(--bg-selected);
    }
    
    .mobile-option-card input[type="radio"] {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }
    
    .option-content {
        display: flex;
        align-items: flex-start;
        gap: 12px;
    }
    
    .option-letter {
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-primary);
        border-radius: 50%;
        font-weight: bold;
        font-size: 16px;
    }
    
    .option-text {
        flex: 1;
        font-size: 16px;
        line-height: 1.4;
        padding-top: 7px;
    }
    
    /* Mobile Bottom Navigation */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .nav-button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px;
        border: none;
        background: none;
        color: var(--text-secondary);
        font-size: 11px;
        cursor: pointer;
        transition: color 0.2s;
    }
    
    .nav-button:active {
        transform: scale(0.95);
    }
    
    .nav-button.active,
    .nav-button:hover {
        color: var(--bs-primary);
    }
    
    .nav-button i {
        font-size: 20px;
        margin-bottom: 2px;
    }
    
    .nav-button.submit {
        color: var(--bs-success);
    }
    
    .nav-button.mark.marked {
        color: var(--bs-warning);
    }
    
    /* Hide desktop elements on mobile */
    .desktop-only {
        display: none !important;
    }
    
    /* Show mobile elements */
    .mobile-only {
        display: block !important;
    }
    
    /* Adjust card padding */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Mobile AI Assistant Button */
    .mobile-ai-button {
        position: fixed;
        bottom: 70px;
        right: 15px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--bs-primary);
        color: white;
        border: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        z-index: 999;
        transition: transform 0.2s;
    }
    
    .mobile-ai-button:active {
        transform: scale(0.95);
    }
    
    /* Timer display for mobile */
    #timerDisplay {
        margin-right: 0 !important;
    }
    
    .timer-container {
        transform: scale(0.8);
        margin: -5px;
    }
    
    /* Points display adjustments */
    #pointsDisplay {
        flex-wrap: nowrap;
        gap: 5px;
    }
    
    .points-counter {
        font-size: 0.9rem;
    }
    
    .streak-counter {
        font-size: 0.85rem;
        padding: 3px 8px;
    }
    
    /* Keyboard help collapse on mobile */
    #keyboardHelp {
        position: fixed;
        bottom: 60px;
        left: 0;
        right: 0;
        max-height: 50vh;
        overflow-y: auto;
        z-index: 999;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
    }
}

/* ========== Mobile AI Assistant Drawer ========== */
.mobile-ai-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.mobile-ai-drawer.open {
    transform: translateY(0);
}

.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

.drawer-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.drag-handle {
    padding: 10px;
    cursor: grab;
    touch-action: none;
}

.handle-bar {
    width: 40px;
    height: 4px;
    background: var(--text-secondary);
    border-radius: 2px;
    margin: 0 auto;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action:active {
    transform: scale(0.95);
    background: var(--bg-active);
}

.quick-action i {
    font-size: 20px;
    margin-bottom: 5px;
}

/* ========== Landscape Mode Adjustments ========== */
@media (max-width: 767px) and (orientation: landscape) {
    .mobile-quiz-content {
        padding-top: 60px;
    }
    
    .mobile-question-container {
        max-height: calc(100vh - 140px);
        overflow-y: auto;
    }
    
    .mobile-options {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .mobile-ai-drawer {
        max-height: 90vh;
    }
}

/* ========== Tablet Adjustments ========== */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        max-width: 100%;
        padding: 0 20px;
    }
    
    .mobile-option-card {
        padding: 20px;
    }
    
    .option-letter {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .option-text {
        font-size: 18px;
    }
}

/* ========== iOS-Specific Fixes ========== */
.ios .mobile-bottom-nav {
    padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
}

.ios .mobile-ai-drawer {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Prevent iOS bounce scrolling */
.ios .mobile-quiz-content {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* ========== Dark Mode Mobile Adjustments ========== */
[data-theme="dark"] .mobile-option-card {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .mobile-option-card.selected {
    background: rgba(13, 110, 253, 0.2);
}

[data-theme="dark"] .mobile-bottom-nav {
    background: #1a1a1a;
    border-top-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .mobile-ai-drawer {
    background: #1a1a1a;
}

[data-theme="dark"] .quick-action {
    background: rgba(255, 255, 255, 0.05);
}

/* ========== Animation Classes ========== */
@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}