/* ============================== */
/* RESPONSIVE & SIDEBAR FIXES     */
/* ============================== */

/* Sidebar Header Container */
.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* Nav Menu - Scrollable Area */
.nav-menu {
    overflow-y: auto !important;
    flex: 1 !important;
    padding: 0.75rem 1rem !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.nav-menu::-webkit-scrollbar {
    width: 5px;
}

.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Nav Item - Smaller for scroll */
.nav-item {
    padding: 0.7rem 0.9rem !important;
    font-size: 0.95rem !important;
    gap: 0.75rem !important;
    margin-bottom: 0.15rem;
}

.nav-item i {
    width: 18px;
    height: 18px;
}

/* User Profile - Fixed Bottom */
.user-profile {
    flex-shrink: 0 !important;
    background: rgba(0, 0, 0, 0.2) !important;
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1001;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 12px;
    background: #3e2723;
    color: var(--accent);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle i {
    width: 24px;
    height: 24px;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
}

/* ============================== */
/* TABLET RESPONSIVE (1024px)     */
/* ============================== */
@media (max-width: 1024px) {
    .app-layout {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .sidebar {
        width: 240px;
        min-width: 240px;
    }

    .nav-item {
        padding: 0.6rem 0.75rem !important;
        font-size: 0.9rem !important;
    }

    .main-content {
        padding: 1.25rem;
    }

    /* Dashboard hero tablet */
    .dashboard-hero {
        padding: 1.5rem;
        gap: 1.5rem;
    }

    .level-ring-container {
        width: 130px;
        height: 130px;
    }

    .level-number {
        font-size: 2.5rem;
    }

    .hero-title {
        font-size: 1.6rem;
    }

    /* Strategy */
    .strategy-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .strategy-stat-value {
        font-size: 2.5rem;
    }
}

/* ============================== */
/* MOBILE RESPONSIVE (768px)      */
/* ============================== */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .app-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding: 0;
        gap: 0;
    }

    /* Mobile Header Bar */
    .mobile-menu-toggle {
        display: none !important;
    }

    /* Sidebar - Full screen overlay on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        border-radius: 0;
        border: none;
        border-right: 4px solid #4e342e;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Main content full width */
    .main-content {
        border-radius: 0;
        border: none;
        border-top: 4px solid #4e342e;
        padding: 1rem;
        padding-top: 1rem;
        padding-bottom: 100px !important;
        min-height: 100vh;
    }

    /* ========== DASHBOARD ========== */
    .dashboard-container {
        gap: 1.25rem;
    }

    .dashboard-hero {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem 1rem;
        gap: 1.25rem;
    }

    .level-ring-container {
        width: 120px;
        height: 120px;
    }

    .level-number {
        font-size: 2.25rem;
    }

    .hero-info {
        width: 100%;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .hero-stats {
        justify-content: center;
        flex-wrap: wrap;
        gap: 1.25rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .action-btn {
        padding: 1rem;
    }

    .action-btn i {
        width: 24px;
        height: 24px;
    }

    .action-btn span {
        font-size: 0.8rem;
    }

    .achievements-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .achievement-item {
        padding: 0.75rem 0.5rem;
    }

    .achievement-icon {
        font-size: 1.25rem;
    }

    .achievement-name {
        font-size: 0.65rem;
    }

    .level-road {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .level-road::before {
        display: none;
    }

    .milestone-marker {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }

    /* ========== NOTES ========== */
    .notes-container {
        grid-template-columns: 1fr !important;
        height: auto !important;
        gap: 0.75rem;
    }

    .notes-sidebar {
        max-height: 280px;
        border-radius: 12px;
    }

    .notes-editor {
        min-height: 50vh;
        border-radius: 12px;
    }

    .editor-toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .title-input {
        width: 100%;
        font-size: 1.1rem;
        order: 1;
    }

    .toolbar-actions {
        width: 100%;
        order: 2;
        justify-content: space-between;
    }

    .cat-select {
        flex: 1;
        min-width: 0;
    }

    .md-toolbar {
        padding: 0.5rem;
        gap: 0.2rem;
    }

    .md-toolbar button {
        width: 28px;
        height: 28px;
    }

    .editor-panes {
        grid-template-columns: 1fr !important;
    }

    .editor-preview {
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        max-height: 300px;
    }

    .view-mode-toggle {
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .view-mode-toggle button {
        flex: 1;
        min-width: 80px;
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    /* ========== AI TUTOR ========== */
    .tutor-container {
        height: auto;
        min-height: auto;
        max-height: none;
    }

    .tutor-header {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .tutor-avatar {
        width: 48px;
        height: 48px;
        font-size: 2rem;
    }

    .tutor-title {
        font-size: 1.1rem;
    }

    .tutor-subtitle {
        font-size: 0.8rem;
    }

    .quick-topics {
        padding: 0.75rem;
    }

    .quick-topics h3 {
        font-size: 0.8rem;
    }

    .topic-chips {
        gap: 0.35rem;
    }

    .topic-chip {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }

    .chat-messages {
        min-height: 300px;
        max-height: 50vh;
        padding: 0.75rem;
    }

    .chat-message {
        max-width: 92%;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }

    .message-text {
        font-size: 0.9rem;
        padding: 0.75rem;
    }

    .chat-input-area {
        padding: 0.75rem;
    }

    .chat-input {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .send-btn {
        width: 44px;
        height: 44px;
    }

    /* ========== EXAM ========== */
    .exam-container {
        padding: 0.75rem;
    }

    .exam-title {
        font-size: 1.5rem;
    }

    .exam-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .exam-option-card {
        padding: 1rem;
    }

    .option-buttons {
        gap: 0.35rem;
    }

    .option-buttons button {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .start-exam-btn {
        width: 100%;
        padding: 0.9rem 1.5rem;
        font-size: 1rem;
    }

    .exam-timer-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
        justify-content: center;
    }

    .timer-text {
        font-size: 1.1rem;
    }

    .question-progress {
        font-size: 0.8rem;
    }

    .finish-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    .question-dots {
        max-height: 50px;
        overflow-y: auto;
        margin-bottom: 1rem;
    }

    .dot {
        width: 10px;
        height: 10px;
    }

    .question-card {
        padding: 1rem;
    }

    .question-text {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .option-item {
        padding: 0.75rem;
    }

    .option-letter {
        width: 24px;
        height: 24px;
        font-size: 0.85rem;
    }

    .option-text {
        font-size: 0.9rem;
    }

    .question-nav {
        gap: 0.75rem;
    }

    .nav-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .results-summary {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }

    .result-card {
        padding: 1rem;
    }

    .result-value {
        font-size: 1.5rem;
    }

    .result-label {
        font-size: 0.75rem;
    }

    .results-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .review-btn,
    .retry-btn {
        width: 100%;
    }

    /* ========== PROGRESS ========== */
    .progress-page {
        padding: 0.75rem;
    }

    .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .progress-title {
        font-size: 1.25rem;
    }

    .progress-period {
        width: 100%;
        justify-content: flex-start;
    }

    .progress-period button {
        flex: 1;
        text-align: center;
    }

    .progress-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .chart-card {
        grid-column: span 1 !important;
        padding: 1rem;
    }

    .chart-card h3 {
        font-size: 0.95rem;
    }

    .activity-chart {
        height: 120px;
    }

    .pomo-stats {
        gap: 1.25rem;
        flex-wrap: wrap;
    }

    /* ========== POMODORO ========== */
    .pomodoro-container {
        padding: 1rem;
    }

    .pomodoro-header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .pomodoro-title {
        font-size: 1.25rem;
    }

    .pomodoro-timer-display {
        width: 160px;
        height: 160px;
        margin-bottom: 1.5rem;
    }

    .timer-time {
        font-size: 2.25rem;
    }

    .pomodoro-controls {
        flex-direction: column;
        gap: 0.75rem;
    }

    .pomo-btn {
        width: 100%;
        justify-content: center;
    }

    .pomodoro-settings {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    /* ========== STRATEGY ========== */
    .strategy-container {
        padding: 1rem;
    }

    .strategy-header {
        margin-bottom: 1.5rem;
    }

    .strategy-header h1 {
        font-size: 1.75rem;
    }

    .strategy-header p {
        font-size: 0.8rem;
    }

    .sticky-note {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }

    .sticky-note p {
        font-size: 1rem;
    }

    .strategy-tabs {
        gap: 0.5rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
    }

    .strategy-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .strategy-stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .strategy-stat-card {
        padding: 1.25rem;
    }

    .strategy-stat-value {
        font-size: 2.5rem;
    }

    .strategy-stat-label {
        font-size: 0.75rem;
    }

    .strategy-content {
        padding: 1rem;
    }

    .strategy-content h1 {
        font-size: 1.4rem;
    }

    .strategy-content h2 {
        font-size: 1.2rem;
    }

    .strategy-subject-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* ========== FLASHCARDS ========== */
    .fc-page {
        padding: 0.75rem;
    }

    .fc-title {
        font-size: 1.5rem;
    }

    .fc-card {
        max-height: 400px;
    }

    .flashcard-container {
        padding: 1rem;
    }

    .flashcard-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .flashcard-wrapper {
        height: 280px;
        max-width: 100%;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 1rem;
    }

    .flashcard-text {
        font-size: 0.95rem;
    }

    .flashcard-controls {
        gap: 1rem;
        margin-top: 1.5rem;
    }

    .flashcard-control-btn {
        padding: 0.75rem 1.25rem;
    }

    /* ========== FUN GAMES ========== */
    .fun-page {
        padding: 0.75rem;
    }

    .fun-title {
        font-size: 1.25rem;
    }

    .fun-menu {
        gap: 0.5rem;
    }

    .fun-game-card {
        padding: 0.85rem 1rem;
    }

    .fun-game-icon {
        width: 42px;
        height: 42px;
    }

    .fun-game-name {
        font-size: 0.95rem;
    }

    .fun-game-desc {
        font-size: 0.75rem;
    }

    .game-card {
        padding: 1.25rem;
        max-width: 100%;
    }

    .game-question p {
        font-size: 1rem;
    }

    .game-big-word {
        font-size: 1.75rem;
    }

    .fun-btn {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }

    /* ========== QUESTIONS ========== */
    .quiz-paper {
        padding: 0.75rem;
    }

    .quiz-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1.25rem;
    }

    /* ========== JOURNEY ========== */
    .journey-container {
        padding: 0.5rem;
    }

    /* ========== TEXTBOOK/NOTEBOOK ========== */
    .textbook-container,
    .notebook-container {
        padding: 1.5rem;
        min-height: auto;
    }

    .textbook-title,
    .notebook-title {
        font-size: 1.75rem;
    }

    .index-item,
    .notebook-item {
        padding: 0.6rem 0.75rem;
    }

    .index-title,
    .notebook-text {
        font-size: 0.95rem;
    }

    /* ========== LECTURE ========== */
    .lecture-content-wrapper {
        padding-bottom: 2rem;
    }

    .lecture-content {
        padding: 1.5rem;
        min-height: 400px;
    }

    .lecture-content h1 {
        font-size: 1.75rem;
    }

    .lecture-content h2 {
        font-size: 1.35rem;
    }

    .btn-close-lecture {
        top: 0.5rem;
        right: 0.5rem;
        width: 36px;
        height: 36px;
    }

    /* ========== MODAL ========== */
    .modal-overlay {
        padding: 0.75rem;
    }

    .modal-content {
        padding: 1.25rem;
        max-width: 100%;
    }

    .modal-content h2 {
        font-size: 1.25rem;
    }

    /* ========== CHALKBOARD ========== */
    .chalkboard-frame {
        padding: 0.5rem;
        border-radius: 8px;
    }

    .chalkboard-surface {
        padding: 1rem;
    }

    .chalk-header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        margin-bottom: 1.25rem;
    }

    .chalk-title {
        font-size: 1.35rem;
    }

    .chalk-score {
        font-size: 1rem;
    }

    .chalk-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .chalk-item {
        padding: 1rem;
    }

    .chalk-tray {
        display: none;
    }
}

/* ============================== */
/* SMALL MOBILE (480px)           */
/* ============================== */
@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
        padding-top: 0.5rem;
    }

    .logo-text {
        font-size: 0.95rem;
    }

    .nav-item {
        padding: 0.45rem 0.55rem !important;
        font-size: 0.8rem !important;
    }

    /* Dashboard */
    .dashboard-hero {
        padding: 1rem;
    }

    .level-ring-container {
        width: 100px;
        height: 100px;
    }

    .level-number {
        font-size: 2rem;
    }

    .hero-title {
        font-size: 1.3rem;
    }

    .hero-stats {
        gap: 1rem;
    }

    .stat-item i {
        width: 20px;
        height: 20px;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Flashcards */
    .flashcard-wrapper {
        height: 260px;
    }

    .fc-card {
        max-height: 350px;
    }

    .fc-card-text {
        font-size: 0.8rem;
    }

    .fc-back-text {
        display: none;
    }

    .fc-study-subject {
        display: none;
    }

    .fc-ctrl-btn span {
        display: none;
    }

    .fc-ctrl-btn {
        padding: 0.85rem;
    }

    .fc-swipe-hint {
        display: flex;
    }

    /* Exam */
    .exam-title {
        font-size: 1.25rem;
    }

    .timer-text {
        font-size: 1rem;
    }

    .question-dots {
        max-height: 40px;
    }

    .dot {
        width: 8px;
        height: 8px;
    }

    .results-summary {
        grid-template-columns: 1fr !important;
    }

    /* Fun games */
    .fun-menu {
        gap: 0.35rem;
    }

    .game-choice-buttons {
        flex-direction: column;
    }

    .fun-btn {
        width: 100%;
    }

    /* Notes */
    .notes-sidebar {
        max-height: 220px;
    }

    .save-btn span,
    .delete-btn span {
        display: none;
    }

    .save-btn,
    .delete-btn {
        padding: 0.5rem;
    }

    /* Progress */
    .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .stat-badge {
        position: static;
        align-self: center;
    }

    /* Pomodoro */
    .pomodoro-timer-display {
        width: 140px;
        height: 140px;
    }

    .timer-time {
        font-size: 2rem;
    }

    /* Strategy */
    .strategy-header h1 {
        font-size: 1.5rem;
    }

    .strategy-stat-value {
        font-size: 2rem;
    }

    /* Tutor */
    .chat-messages {
        min-height: 250px;
    }

    .tutor-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .tutor-title {
        font-size: 1rem;
    }

    .topic-chip {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }
}

/* ============================== */
/* VERY SMALL MOBILE (360px)      */
/* ============================== */
@media (max-width: 360px) {
    .mobile-menu-toggle {
        width: 42px;
        height: 42px;
        top: 0.5rem;
        left: 0.5rem;
    }

    .main-content {
        padding-top: 0.5rem;
    }

    .dashboard-hero {
        padding: 0.75rem;
    }

    .level-ring-container {
        width: 90px;
        height: 90px;
    }

    .level-number {
        font-size: 1.75rem;
    }

    .hero-title {
        font-size: 1.15rem;
    }

    .hero-subtitle {
        font-size: 0.85rem;
    }

    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.35rem;
    }

    .achievement-item {
        padding: 0.5rem;
    }

    .flashcard-wrapper {
        height: 240px;
    }

    .fc-card {
        max-height: 320px;
    }

    .pomodoro-timer-display {
        width: 120px;
        height: 120px;
    }

    .timer-time {
        font-size: 1.75rem;
    }
}