/* ==========================================
   MOBILE RESPONSIVE STYLES
   CompTIA Security+ Study Platform
   ========================================== */

/* ==========================================
   MOBILE BOTTOM TAB BAR
   ========================================== */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: linear-gradient(180deg, #0c1e36 0%, #0a1628 100%);
    border-top: 1px solid rgba(14, 165, 233, 0.2);
    z-index: 3000;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 56px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.mobile-tab .tab-icon {
    font-size: 1.4rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.mobile-tab .tab-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.mobile-tab.active {
    color: var(--primary-light);
}

.mobile-tab.active .tab-icon {
    transform: scale(1.15);
}

.mobile-tab.active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* More menu dropdown */
.mobile-more-menu {
    display: none;
    position: fixed;
    bottom: 72px;
    right: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px;
    z-index: 3001;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
    min-width: 180px;
    animation: slideUp 0.2s ease;
}

.mobile-more-menu.active {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 12px;
    font-size: 0.9rem;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.more-menu-item:hover,
.more-menu-item:active {
    background: rgba(14, 165, 233, 0.15);
    color: var(--text-primary);
}

.more-menu-item.active {
    background: rgba(14, 165, 233, 0.2);
    color: var(--primary-light);
}

.more-menu-item .more-icon {
    font-size: 1.2rem;
}

/* Mobile overlay for more menu */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2999;
}

.mobile-overlay.active {
    display: block;
}

/* ==========================================
   HAMBURGER MENU BUTTON
   ========================================== */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Mobile nav overlay - shown when hamburger is clicked */
.navbar-nav.mobile-open {
    display: flex !important;
    position: fixed;
    top: 54px;
    left: 12px;
    right: 12px;
    flex-direction: column;
    background: linear-gradient(145deg, #0f1d32, #0a1628);
    padding: 12px;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    gap: 4px;
    border: 1px solid rgba(14, 165, 233, 0.2);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.navbar-nav.mobile-open .nav-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.95rem;
}

.navbar-nav.mobile-open .nav-text {
    display: inline;
}

/* ==========================================
   BREAKPOINT 1: TABLETS (max-width: 1024px)
   ========================================== */
@media (max-width: 1024px) {

    /* Sidebar: hide by default */
    .sidebar {
        position: fixed;
        left: -300px;
        transition: left 0.3s ease;
        z-index: 500;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.sidebar-open {
        left: 0;
    }

    /* Main content: no margin */
    .main-content {
        margin-left: 0;
        padding: 24px;
    }

    /* Dashboard grids */
    .dashboard-sections {
        grid-template-columns: 1fr;
    }

    .dashboard-compact-grid {
        grid-template-columns: 1fr;
    }

    /* Dashboard hero */
    .dashboard-hero {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    /* Case layout */
    .case-layout {
        grid-template-columns: 1fr;
    }

    .case-scenario-panel {
        position: static;
    }

    /* PBQ firewall & topology */
    .pbq-firewall-container,
    .pbq-topology-container {
        grid-template-columns: 1fr;
    }

    .pbq-firewall-rules {
        grid-column: span 1;
    }

    /* Exam simulation */
    .exam-sim-body {
        grid-template-columns: 1fr;
    }

    .exam-sim-nav {
        display: none;
    }

    .exam-sim-question {
        padding: 24px;
    }
}

/* ==========================================
   BREAKPOINT 2: MOBILE (max-width: 768px)
   ========================================== */
@media (max-width: 768px) {

    /* ---- BODY & GLOBAL ---- */
    html {
        font-size: 15px;
    }

    body {
        overflow-x: hidden;
    }

    /* ---- TOP NAVBAR ---- */
    .top-navbar {
        height: 54px;
        padding: 0 12px;
        gap: 8px;
    }

    .navbar-brand .logo-text {
        font-size: 1.1rem;
    }

    .navbar-brand .logo-icon {
        font-size: 1.4rem;
    }

    .navbar-brand .version-badge {
        padding: 2px 8px;
        font-size: 0.65rem;
    }

    /* Hide horizontal nav and search on mobile - but allow .mobile-open to override */
    .navbar-nav:not(.mobile-open) {
        display: none;
    }

    .navbar-search {
        display: none;
    }

    /* Show hamburger */
    .hamburger-btn {
        display: flex;
        margin-left: auto;
    }

    /* ---- MOBILE BOTTOM BAR ---- */
    .mobile-bottom-bar {
        display: flex;
    }

    /* ---- APP CONTAINER ---- */
    .app-container {
        padding-top: 54px;
        padding-bottom: 64px;
        /* Space for bottom bar */
    }

    /* ---- SIDEBAR ---- */
    .sidebar {
        display: none;
    }

    /* ---- MAIN CONTENT ---- */
    .main-content {
        margin-left: 0 !important;
        padding: 16px;
        min-height: calc(100vh - 54px - 64px);
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* ---- VIEW HEADERS ---- */
    .view-header {
        margin-bottom: 20px;
    }

    .view-header h1 {
        font-size: 1.5rem;
    }

    .view-header p {
        font-size: 0.95rem;
    }

    /* ---- DASHBOARD ---- */

    /* Hero compact */
    .dashboard-hero-compact {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 14px 16px;
    }

    .dashboard-hero-compact .hero-left h1 {
        font-size: 1.2rem;
    }

    .hero-stats-inline {
        justify-content: center;
    }

    .stat-pill {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Next step card */
    .next-step-card {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 16px;
    }

    .next-step-card h3 {
        font-size: 1.05rem;
    }

    .next-step-card .btn {
        width: 100%;
        padding: 12px 20px;
    }

    /* Dashboard hero (full version) */
    .dashboard-hero {
        grid-template-columns: 1fr;
        padding: 20px;
        gap: 20px;
    }

    .hero-welcome h1 {
        font-size: 1.5rem;
    }

    .hero-stats {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .progress-circle-container {
        width: 80px;
        height: 80px;
    }

    .mini-stats-grid {
        gap: 12px;
    }

    .mini-stat-val {
        font-size: 1.2rem;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        gap: 12px;
    }

    .stat-icon {
        font-size: 2rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* Actions grid */
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .actions-grid-compact {
        grid-template-columns: repeat(2, 1fr);
    }

    .action-btn {
        padding: 14px 10px;
        font-size: 0.8rem;
    }

    /* Dashboard sections */
    .dashboard-sections {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .quick-actions,
    .recent-activity {
        padding: 16px;
    }

    /* Badges */
    .badges-section,
    .badges-section-compact {
        padding: 14px;
    }

    .badges-grid {
        gap: 12px;
    }

    .badge-item {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }

    .badges-scroll .badge-item {
        width: 50px;
        height: 50px;
    }

    /* ---- STUDY PATH ---- */
    .study-path-hero {
        padding: 20px;
        margin-bottom: 16px;
    }

    .study-path-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }

    .study-path-title h2 {
        font-size: 1.3rem;
    }

    .global-progress-circle {
        width: 70px;
        height: 70px;
    }

    /* Phases */
    .roadmap-timeline {
        gap: 16px;
    }

    .phase {
        padding: 16px;
        border-left-width: 4px;
    }

    .phase.collapsed {
        padding: 12px 14px;
    }

    .phase-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 16px;
    }

    .phase-info h3 {
        font-size: 1rem;
    }

    .phase-progress {
        flex-direction: row;
        align-items: center;
        min-width: unset;
        width: 100%;
    }

    .phase-progress-bar {
        flex: 1;
        width: auto;
    }

    /* Steps */
    .step {
        padding: 12px 14px;
        gap: 12px;
    }

    .step-icon {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .step-title {
        font-size: 0.88rem;
    }

    .step-desc {
        font-size: 0.8rem;
    }

    .step-status {
        width: 34px;
        height: 34px;
        font-size: 1.2rem;
    }

    .step:hover:not(.locked) {
        transform: translateX(4px);
    }

    .step-meta {
        flex-direction: row;
        gap: 8px;
    }

    /* ---- STUDY MODE ---- */
    .lesson-tabs {
        padding: 10px 12px;
        gap: 6px;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .lesson-tabs::-webkit-scrollbar {
        display: none;
    }

    .lesson-tab {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .study-content {
        max-width: 100%;
        overflow-x: hidden;
        word-break: break-word;
    }

    #study-view {
        max-width: 100%;
        overflow-x: hidden;
    }

    #study-view .study-content,
    #study-view .study-section,
    #study-view .section-content {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .study-content pre,
    .study-content code {
        max-width: 100%;
        overflow-x: auto;
        word-break: break-all;
    }

    .study-content table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }

    .study-content img {
        max-width: 100%;
        height: auto;
    }

    .section-header {
        padding: 14px 16px;
    }

    .section-header h3 {
        font-size: 0.95rem;
    }

    .study-section {
        overflow: hidden;
    }

    .section-content {
        padding: 16px;
    }

    #study-view .section-content p,
    #study-view .section-content li,
    #study-view .section-content h3,
    #study-view .section-content h4,
    #study-view .concept-card,
    #study-view .definition-item {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .study-bullet-list {
        margin-left: 0;
        padding-left: 1.1rem;
    }

    .concept-card {
        padding: 16px;
    }

    .concept-card p {
        max-width: 100%;
        font-size: 0.95rem;
    }

    .definition-list {
        grid-template-columns: 1fr;
    }

    .definition-item {
        padding: 14px 16px;
    }

    /* ---- EXAM MODE ---- */
    .exam-setup {
        padding: 24px 20px;
        max-width: 100%;
    }

    .exam-setup h2 {
        font-size: 1.25rem;
    }

    .exam-active {
        max-width: 100%;
    }

    .exam-header {
        flex-direction: column;
        gap: 10px;
        padding: 12px 14px;
    }

    .exam-info {
        flex-wrap: wrap;
        gap: 12px;
        font-size: 0.85rem;
    }

    .exam-progress-bar {
        width: 100%;
    }

    .question-container {
        padding: 20px;
    }

    .question-text {
        font-size: 1rem;
    }

    .option {
        padding: 12px 14px;
        gap: 10px;
    }

    .option-letter {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    .exam-actions {
        flex-wrap: wrap;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .btn-lg {
        padding: 14px 28px;
        font-size: 1rem;
    }

    /* Exam results */
    .exam-results {
        max-width: 100%;
    }

    .results-card {
        padding: 24px;
    }

    .results-score {
        font-size: 3rem;
    }

    .results-stats {
        grid-template-columns: 1fr 1fr;
    }

    /* ---- EXAM SIMULATION ---- */
    .exam-sim-header {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .exam-sim-title h2 {
        font-size: 1rem;
    }

    .exam-sim-timer .timer-value {
        font-size: 1.1rem;
    }

    .exam-sim-controls {
        gap: 8px;
    }

    .exam-sim-controls .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .exam-sim-question {
        padding: 16px;
    }

    .exam-sim-footer {
        padding: 10px 14px;
        gap: 12px;
        flex-wrap: wrap;
    }

    .exam-results-content {
        padding: 24px;
    }

    .result-score {
        font-size: 3rem;
    }

    .result-breakdown {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* ---- CASES MODE ---- */
    .cases-list {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .case-card {
        padding: 16px;
    }

    .case-scenario {
        padding: 16px;
    }

    .case-scenario-text {
        font-size: 0.95rem;
        padding: 14px;
    }

    /* ---- FLASHCARDS ---- */
    .flashcards-decks {
        max-width: 100%;
    }

    .decks-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .decks-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .deck-card {
        padding: 16px;
    }

    .flashcards-session {
        max-width: 100%;
    }

    .flashcard {
        height: 280px;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 24px;
    }

    .card-content {
        font-size: 1.1rem;
    }

    .session-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 12px 14px;
    }

    .anki-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }

    .anki-btn {
        max-width: calc(50% - 4px);
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        padding: 12px 8px;
    }

    .flashcards-results {
        max-width: 100%;
    }

    /* ---- PBQ MODE ---- */
    .pbq-workspace {
        padding: 16px;
    }

    .pbq-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .pbq-scenario {
        font-size: 1rem;
        padding: 14px;
    }

    .pbq-game-area {
        grid-template-columns: 1fr;
        gap: 16px;
        min-height: auto;
    }

    .pbq-zones-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .pbq-matching-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .pbq-analysis-options {
        grid-template-columns: 1fr;
    }

    .pbq-cards-grid {
        grid-template-columns: 1fr;
    }

    .pbq-filter-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .pbq-filter-select {
        width: 100%;
        min-width: unset;
    }

    .pbq-stats-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .pbq-ordering-container {
        max-width: 100%;
        padding: 12px;
    }

    .pbq-command-container {
        max-width: 100%;
        padding: 12px;
    }

    .pbq-terminal-input {
        min-width: 120px;
    }

    .pbq-log-container {
        max-width: 100%;
        padding: 12px;
    }

    .pbq-log-content {
        font-size: 0.75rem;
    }

    .pbq-log-timestamp {
        min-width: 80px;
        font-size: 0.7rem;
    }

    /* PBQ simulation details */
    .simulation-details {
        grid-template-columns: 1fr;
    }

    .simulation-info-panel {
        padding: 16px;
    }

    /* PBQ Firewall */
    .pbq-firewall-container {
        grid-template-columns: 1fr;
    }

    .pbq-rule-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .pbq-rule-row label {
        width: auto;
    }

    .pbq-firewall-rule {
        flex-wrap: wrap;
        font-size: 0.8rem;
        padding: 10px 12px;
    }

    /* PBQ Topology */
    .pbq-topology-container {
        grid-template-columns: 1fr;
    }

    .pbq-network-map {
        min-height: 250px;
    }

    /* ---- NOTES VIEW ---- */
    .notes-container {
        max-width: 100%;
    }

    .notes-header-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 12px 14px;
    }

    /* ---- CHAT VIEW (Full Page) ---- */
    .chat-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 54px - 64px - 32px);
    }

    .chat-sidebar {
        display: none;
    }

    .chat-main {
        height: calc(100vh - 54px - 64px - 32px);
        border-radius: 12px;
    }

    .chat-messages-lg {
        padding: 16px;
    }

    .chat-message-lg {
        gap: 10px;
    }

    .message-bubble-lg {
        padding: 12px 16px;
    }

    .chat-input-area-lg {
        padding: 12px;
    }

    .input-wrapper-lg {
        max-width: 100%;
    }

    #full-chat-input {
        padding: 12px 44px 12px 14px;
        font-size: 0.95rem;
    }

    .suggestion-chips {
        max-width: 100%;
    }

    .suggestion-chips button {
        font-size: 0.8rem;
        padding: 6px 12px;
    }

    /* ---- CHAT PANEL (Floating) ---- */
    .chat-panel {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: 80px;
        max-height: 70vh;
    }

    /* ---- FABs ---- */
    .fab-container {
        bottom: 76px;
        right: 16px;
    }

    .fab {
        width: 48px;
        height: 48px;
    }

    .fab-icon {
        font-size: 1.3rem;
    }

    /* ---- MODALS ---- */
    .modal-content {
        width: 95%;
        max-height: 85vh;
        margin: auto;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    /* ---- TOASTS ---- */
    #toast-container {
        right: 12px;
        left: 12px;
        top: 62px;
    }

    .toast {
        width: 100%;
    }

    .toast-badge {
        min-width: auto;
        width: 100%;
    }

    /* ---- EXAM READINESS PANEL ---- */
    .exam-readiness-panel {
        padding: 16px;
    }

    .readiness-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .domains-grid {
        grid-template-columns: 1fr;
    }

    .recommendation-item {
        flex-wrap: wrap;
    }

    .recommendation-priority {
        margin-left: 0;
    }

    /* ---- SEARCH RESULTS ---- */
    .search-container {
        padding: 0 12px 12px;
    }

    /* ---- FORM ELEMENTS ---- */
    .radio-option,
    .checkbox-option {
        padding: 12px 14px;
    }

    select {
        font-size: 0.95rem;
    }
}

/* ==========================================
   BREAKPOINT 3: SMALL PHONES (max-width: 480px)
   ========================================== */
@media (max-width: 480px) {

    html {
        font-size: 14px;
    }

    .top-navbar {
        height: 48px;
        padding: 0 10px;
    }

    .navbar-brand .logo-text {
        font-size: 1rem;
    }

    .navbar-brand .version-badge {
        display: none;
    }

    .app-container {
        padding-top: 48px;
    }

    .main-content {
        padding: 10px;
        min-height: calc(100vh - 48px - 64px);
    }

    /* Bottom bar: shrink labels */
    .mobile-tab .tab-label {
        font-size: 0.6rem;
    }

    .mobile-tab .tab-icon {
        font-size: 1.2rem;
    }

    /* Dashboard */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
        gap: 8px;
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .dashboard-hero-compact .hero-left h1 {
        font-size: 1.1rem;
    }

    .stat-pill {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    /* Study path */
    .study-path-hero {
        padding: 14px;
    }

    .study-path-title h2 {
        font-size: 1.1rem;
    }

    .phase {
        padding: 12px;
    }

    .step {
        padding: 10px 12px;
        gap: 10px;
    }

    .step-icon {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }

    .step-title {
        font-size: 0.82rem;
    }

    .step-desc {
        font-size: 0.75rem;
    }

    /* Flashcards */
    .flashcard {
        height: 240px;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 20px;
    }

    .card-content {
        font-size: 1rem;
    }

    .card-label {
        font-size: 0.65rem;
    }

    /* Exam */
    .question-container {
        padding: 14px;
    }

    .question-text {
        font-size: 0.95rem;
    }

    .option {
        padding: 10px 12px;
    }

    .option-letter {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    /* Exam simulation */
    .exam-sim-header {
        padding: 8px 10px;
    }

    .exam-sim-title h2 {
        font-size: 0.9rem;
    }

    .exam-sim-timer {
        padding: 6px 12px;
    }

    .exam-sim-timer .timer-value {
        font-size: 1rem;
    }

    .exam-sim-question {
        padding: 12px;
    }

    .exam-option {
        padding: 12px 14px;
        gap: 10px;
    }

    .question-actions {
        flex-direction: column;
        gap: 8px;
    }

    .question-actions .btn {
        width: 100%;
    }

    /* Results */
    .results-score,
    .result-score {
        font-size: 2.5rem;
    }

    .result-breakdown {
        grid-template-columns: 1fr;
    }

    /* Cases */
    .case-card h3 {
        font-size: 1rem;
    }

    .case-scenario-text {
        font-size: 0.9rem;
        padding: 10px;
    }

    /* PBQ */
    .pbq-workspace {
        padding: 12px;
    }

    .pbq-scenario {
        font-size: 0.9rem;
        padding: 10px;
    }

    .pbq-draggable {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .zone-label {
        font-size: 0.8rem;
        padding: 8px;
    }

    .zone-content {
        padding: 10px;
    }

    /* Chat */
    .chat-panel {
        bottom: 72px;
    }

    .chat-messages {
        min-height: 200px;
        max-height: 250px;
    }

    .chat-welcome-lg h1 {
        font-size: 1.3rem;
    }

    /* Modals */
    .modal-content {
        width: 98%;
        border-radius: 12px;
    }

    /* FABs above bottom bar */
    .fab-container {
        bottom: 72px;
        right: 10px;
    }

    .fab {
        width: 44px;
        height: 44px;
    }
}

/* ==========================================
   TOUCH DEVICE OVERRIDES
   ========================================== */
@media (hover: none) and (pointer: coarse) {

    /* Remove hover transform effects */
    .stat-card:hover,
    .case-card:hover,
    .deck-card:hover,
    .badge-item:hover,
    .action-btn:hover,
    .action-btn-compact:hover,
    .definition-item:hover,
    .note-card:hover,
    .pbq-card:hover,
    .pbq-draggable:hover,
    .pbq-dropzone:hover,
    .pbq-match-item:hover,
    .domain-item:hover,
    .step:hover:not(.locked),
    .phase:hover {
        transform: none;
    }

    /* Ensure min touch targets */
    .nav-btn,
    .lesson-tab,
    .option,
    .exam-option,
    .radio-option,
    .checkbox-option,
    .step,
    .anki-btn,
    .btn,
    .fab,
    .mobile-tab,
    .more-menu-item,
    .pbq-draggable,
    .pbq-match-item,
    .pbq-order-item,
    .pbq-issue-option,
    .pbq-analysis-option,
    .suggestion-chips button,
    .icon-btn {
        min-height: 44px;
    }

    /* Improve tap usability */
    .navbar-nav .nav-btn:hover {
        transform: none;
    }

    .lesson-tab:hover {
        transform: none;
    }

    .option:hover:not(.disabled) {
        transform: none;
    }

    .recommendation-item:hover {
        transform: none;
    }

    /* Active state feedback for touch */
    .mobile-tab:active {
        transform: scale(0.9);
    }

    .btn:active:not(:disabled) {
        transform: scale(0.97);
    }

    .option:active:not(.disabled) {
        background: rgba(14, 165, 233, 0.15);
    }

    .step:active:not(.locked) {
        background: rgba(14, 165, 233, 0.15);
    }
}

/* ==========================================
   LANDSCAPE MOBILE
   ========================================== */
@media (max-height: 500px) and (orientation: landscape) {

    .mobile-bottom-bar {
        height: 48px;
    }

    .mobile-tab .tab-label {
        display: none;
    }

    .mobile-tab .tab-icon {
        font-size: 1.3rem;
    }

    .app-container {
        padding-bottom: 48px;
    }

    .flashcard {
        height: 200px;
    }

    .chat-panel {
        max-height: 60vh;
        bottom: 56px;
    }

    .fab-container {
        bottom: 56px;
    }
}

/* ==========================================
   SAFE AREA INSETS (Notch phones)
   ========================================== */
@supports (padding: max(0px)) {

    .mobile-bottom-bar {
        padding-bottom: max(4px, env(safe-area-inset-bottom));
        height: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .top-navbar {
        padding-top: env(safe-area-inset-top, 0);
    }

    .main-content {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* ==========================================
   PRINT QUERY - AVOID BOTTOM BAR
   ========================================== */
@media print {

    .mobile-bottom-bar,
    .fab-container,
    .chat-panel,
    .hamburger-btn,
    .mobile-more-menu,
    .mobile-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding-bottom: 0 !important;
    }
}
