/* Mobile-Optimized Styles for LearnAndEarn */
/* Smartphone compatibility improvements */

/* Hamburger menu button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    color: #333;
    z-index: 1001;
}

/* Hide mobile-only elements on desktop */
@media (min-width: 769px) {
    .mobile-user-section,
    .mobile-menu-separator {
        display: none !important;
    }
}

.mobile-menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: #333;
    margin: 5px 0;
    transition: 0.3s;
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

/* Base mobile styles for tablets and below */
@media (max-width: 768px) {
    /* Show hamburger menu */
    .mobile-menu-toggle {
        display: block;
        position: absolute;
        left: 10px;
        top: 10px;
    }
    
    /* Navigation improvements */
    .user-header {
        position: relative;
        padding: 10px;
        min-height: 50px;
    }
    
    .nav-links {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 250px;
        height: 100vh;
        background: white;
        flex-direction: column;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        z-index: 1000;
        padding: 60px 0 20px 0;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .nav-links.active {
        transform: translateX(0);
    }
    
    .nav-link {
        padding: 15px 20px;
        font-size: 1em;
        border-bottom: 1px solid #f0f0f0;
        width: 100%;
        text-align: left;
    }
    
    /* Mobile user section in menu */
    .mobile-user-section {
        margin-top: auto;
        padding-bottom: 20px;
    }
    
    .mobile-profile-link {
        color: #007bff !important;
        font-weight: 500;
    }
    
    .mobile-logout-btn {
        color: #dc3545 !important;
        font-weight: 500;
        transition: opacity 0.2s;
    }
    
    .mobile-logout-btn:hover {
        opacity: 0.8;
    }
    
    /* Mobile user section in menu */
    .mobile-user-section {
        display: block !important;
        margin-top: 10px;
    }
    
    .mobile-menu-separator {
        display: block !important;
    }
    
    /* Ensure profile link matches other nav links */
    .mobile-profile-link {
        color: #333 !important;
        font-weight: 500;
    }
    
    .user-menu {
        flex-direction: column;
        width: 100%;
        text-align: center;
        margin-left: 50px;
    }
    
    .user-info {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }
    
    .user-actions {
        display: none; /* Hide on mobile - will be moved to hamburger menu */
    }
    
    /* Hamburger animation */
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
    
    /* Hero section mobile optimization */
    .hero-section {
        padding: 40px 20px;
        margin-bottom: 20px;
    }
    
    .hero-section h1 {
        font-size: 2.2em;
        letter-spacing: -0.5px;
    }
    
    .hero-section p {
        font-size: 1.1em;
        margin: 0 auto 20px;
    }
    
    /* CTA buttons stack on mobile */
    .cta-buttons {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
    
    .cta-button {
        width: 100%;
        padding: 15px 20px;
        font-size: 1em;
    }
    
    /* Emphasize login button on mobile */
    .cta-login {
        font-size: 1.1em;
        padding: 18px 25px;
        order: -1; /* Place login button first on mobile */
    }
    
    .login-prompt {
        margin-bottom: 20px;
        padding: 12px 20px;
    }
    
    .login-prompt p {
        font-size: 1em;
    }
    
    /* Feature cards */
    .features-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-top: 30px;
    }
    
    .feature-card {
        padding: 25px;
    }
    
    /* Steps section */
    .steps {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-top: 30px;
    }
    
    /* Container padding */
    .container {
        padding: 15px;
        margin: 10px auto;
        width: 95%;
    }
    
    /* Video detail page */
    .video-detail-container {
        padding: 0;
    }
    
    /* Search page */
    .search-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .search-container input,
    .category-filter {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .search-container button {
        width: 100%;
        padding: 12px;
    }
    
    /* Results grid */
    .results-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Vocabulary cards */
    .vocab-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .vocab-card {
        padding: 20px;
    }
    
    /* Modal optimization */
    .modal-content,
    .dictation-content {
        width: 95%;
        margin: 20px auto;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Learning time analytics */
    .time-analytics {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .time-card {
        padding: 15px;
    }
    
    .time-value {
        font-size: 2em;
    }
    
    /* Activity breakdown */
    .activity-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .activity-name {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .activity-progress {
        width: 100%;
        margin: 5px 0;
    }
    
    .activity-percent {
        width: 100%;
        text-align: left;
        margin-top: 5px;
    }
    
    /* Filters */
    .time-filters,
    .feature-filters {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .filter-btn {
        padding: 8px 15px;
        font-size: 0.9em;
    }
    
    /* Progress page */
    .stat-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 200px;
    }
}

/* Smartphone-specific styles */
@media (max-width: 480px) {
    /* User header adjustments */
    .user-header {
        padding-left: 60px; /* Space for hamburger */
    }
    
    .user-info {
        font-size: 0.9em;
    }
    
    .user-name {
        display: inline-block;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Even smaller hero text */
    .hero-section h1 {
        font-size: 1.8em;
    }
    
    .hero-section p {
        font-size: 1em;
    }
    
    /* Time analytics single column */
    .time-analytics {
        grid-template-columns: 1fr;
    }
    
    /* Smaller modals on very small screens */
    .modal-content,
    .dictation-content {
        width: 100%;
        margin: 0;
        padding: 15px;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }
    
    /* Full-width buttons */
    button, .btn {
        width: 100%;
        min-height: 44px; /* iOS touch target */
    }
    
    /* Dictation controls side by side on mobile */
    .dictation-controls {
        flex-direction: row;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .control-button {
        flex: 1;
        min-width: 140px;
        padding: 10px 12px;
        font-size: 0.9em;
    }
    
    /* Speech result always visible on mobile */
    .speech-result {
        display: block !important;
        margin: 15px 0;
        padding: 15px;
    }
    
    .transcribed-text {
        min-height: 60px;
        font-size: 1em;
    }
    
    .speech-button {
        width: 100%;
        padding: 12px 20px;
        font-size: 1em;
    }
    
    /* Improve sentence selection on mobile */
    .sentence-display {
        font-size: 1.1em;
        line-height: 1.8;
        padding: 20px;
        -webkit-user-select: text !important;
        -webkit-touch-callout: default !important;
        user-select: text !important;
    }
    
    .selection-hint {
        font-size: 0.9em;
        padding: 10px;
        background: #f0f7ff;
        border-radius: 8px;
        margin: 10px 0;
    }
    
    /* Visual feedback for selected text */
    .sentence-display.has-selection {
        background: #e3f2fd;
        border-color: #1976d2;
    }
    
    /* Selection highlight */
    .sentence-display::selection {
        background: #1976d2;
        color: white;
    }
    
    .sentence-display::-webkit-selection {
        background: #1976d2;
        color: white;
    }
    
    /* Practice mode selector */
    .vocab-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .practice-mode-selector {
        width: 100%;
    }
    
    /* Vocabulary stats */
    .vocab-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .stat-card {
        width: 100%;
    }
    
    /* Word selection modal */
    .word-options-grid {
        grid-template-columns: 1fr;
        padding: 15px;
    }
    
    /* Sentences modal */
    .sentences-modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .word-sentence-item {
        flex-direction: column;
        gap: 10px;
    }
    
    .word-sentence-item .practice-sentence-btn {
        width: 100%;
    }
    
    /* Speech button */
    .speech-button {
        width: 100%;
        padding: 20px;
        font-size: 1.2em;
    }
    
    /* Rating buttons */
    .rating-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .rate-btn {
        width: 100%;
        padding: 12px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    button, .btn, .nav-link, .cta-button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .vocab-card:hover,
    .video-card:hover,
    .feature-card:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Larger clickable areas */
    .clickable-word {
        padding: 5px 8px;
        margin: 2px;
    }
    
    /* Disable text selection on buttons */
    button, .btn {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding: 20px;
    }
    
    .hero-section h1 {
        font-size: 1.5em;
    }
    
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .time-analytics {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Safe area adjustments for modern phones with notches */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .user-header {
        padding-top: max(10px, env(safe-area-inset-top));
    }
}

/* Prevent iOS form zoom */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    font-size: 16px !important;
}

/* Smooth scrolling for mobile */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbars on mobile for cleaner look */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        display: none;
    }
    
    * {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}