/* 
=============================================================================
 ALALAY-AI — Mobile Phone UI Stylesheet
 Scoped strictly to @media (max-width: 768px) to protect Desktop/PC Interface
=============================================================================
*/

@media (max-width: 768px) {

    /* ── 1. Page Body & Container Layout ───────────────────────────── */
    body {
        padding-bottom: 6.5rem !important; /* Space for the floating bottom nav */
        background: #ffffff !important; /* Remove blue gradient background on mobile */
        background-color: #ffffff !important;
    }

    main.container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-top: 1rem !important;
        padding-bottom: 2rem !important;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* Outer glassmorphic wrapper — flattened & maximized for mobile viewport space */
    .rounded-5.p-3.p-xl-4.shadow-xl {
        padding: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        background: #ffffff !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }

    .main-container {
        padding: 0 !important;
        background: transparent !important;
    }

    /* Hide the desktop left sidebar */
    aside.col-xl-3 {
        display: none !important;
    }

    /* Expand main content to full width */
    section.col-xl-9 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 !important;
    }

    .main-content {
        padding: 1.25rem 1rem !important;
        border-radius: 1.25rem !important;
    }

    /* ── 2. Floating Bottom Navigation Pill Bar ───────────────────── */
    .mobile-floating-nav {
        position: fixed;
        bottom: 1.25rem;
        left: 1rem;
        right: 1rem;
        margin: 0 auto;
        max-width: 380px;
        z-index: 1050;
        pointer-events: auto;
    }

    .mobile-nav-pill {
        background: linear-gradient(135deg, #4a62e0 0%, #5d75f2 100%);
        border-radius: 9999px;
        padding: 0.4rem 0.6rem;
        display: flex;
        align-items: center;
        justify-content: space-around;
        box-shadow: 0 10px 28px rgba(45, 65, 170, 0.35);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    .mobile-nav-item {
        color: #ffffff !important;
        font-size: 1.4rem;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        border-radius: 9999px;
        text-decoration: none;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
    }

    .mobile-nav-item:hover {
        color: #ffffff !important;
        transform: scale(1.05);
    }

    /* Translucent Bubble Highlight for Active Tab */
    .mobile-nav-item.active {
        background: rgba(255, 255, 255, 0.28) !important;
        box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1);
        transform: scale(1.04);
    }

    .mobile-nav-item i {
        line-height: 1;
    }

    /* ── 3. Home Screen Mobile Optimization ────────────────────────── */
    .import-card {
        max-width: 100% !important;
        width: 100% !important;
        padding: 1.75rem 1rem !important;
        border-radius: 1.25rem !important;
    }

    /* ── 4. My Decks Screen Mobile Optimization ────────────────────── */
    .deck-grid, .decks-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.85rem !important;
    }

    .deck-card-item {
        width: 100% !important;
        border-radius: 1.25rem !important;
        padding: 1rem 1.25rem !important;
    }

    /* Floating (+) Button for mobile deck creation */
    .mobile-fab-btn {
        position: fixed;
        bottom: 5.5rem;
        right: 1.25rem;
        width: 52px;
        height: 52px;
        border-radius: 50% !important;
        background-color: #1a237e !important;
        color: #ffffff !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 1.6rem;
        box-shadow: 0 6px 18px rgba(26, 35, 126, 0.4) !important;
        border: none !important;
        z-index: 1040;
        text-decoration: none;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .mobile-fab-btn:active {
        transform: scale(0.94);
    }

    /* ── 5. Flashcard Study Deck Screen ────────────────────────────── */
    .flashcard-header {
        padding: 0.75rem 1rem !important;
    }

    .flashcard-panel-top, .flashcard-panel-bottom {
        padding: 1.5rem 1.25rem !important;
    }

    .btn-study-deck-mobile-container {
        position: fixed !important;
        bottom: 24px !important;
        left: 5% !important;
        width: 90% !important;
        z-index: 1040 !important;
    }

    body[data-page="flashcard_deck"] {
        padding-bottom: 7rem !important;
    }

    body[data-page="flashcard"] {
        padding-bottom: 7rem !important;
    }

    .btn-study-deck-mobile {
        background-color: #1a237e !important;
        color: #ffffff !important;
        border-radius: 9999px !important;
        font-weight: 700;
        font-size: 1.1rem;
        padding: 0.85rem 1.5rem !important;
        width: 100%;
        box-shadow: 0 4px 14px rgba(26, 35, 126, 0.35);
    }

    /* ── 6. Quiz Screen Mobile Optimization ────────────────────────── */
    body[data-page="quiz"],
    body[data-page="quiz_deck"] {
        padding-bottom: 0 !important;
        min-height: 100vh !important;
        background-color: #ffffff !important;
    }

    body[data-page="quiz"] .quiz-container,
    body[data-page="quiz_deck"] .quiz-container {
        min-height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
    }

    body[data-page="quiz"] .quiz-workspace,
    body[data-page="quiz_deck"] .quiz-workspace {
        flex-grow: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    /* Position arrow buttons beside the quiz content on mobile */
    body[data-page="quiz"] .quiz-content-stack,
    body[data-page="quiz_deck"] .quiz-content-stack {
        padding-left: 46px !important;
        padding-right: 46px !important;
    }

    body[data-page="quiz"] .row > .col-auto.position-md-absolute:first-child,
    body[data-page="quiz_deck"] .row > .col-auto.position-md-absolute:first-child {
        position: absolute !important;
        left: 0 !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        z-index: 10 !important;
    }

    body[data-page="quiz"] .row > .col-auto.position-md-absolute:last-child,
    body[data-page="quiz_deck"] .row > .col-auto.position-md-absolute:last-child {
        position: absolute !important;
        right: 0 !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        z-index: 10 !important;
    }

    body[data-page="quiz"] .btn-quiz-nav,
    body[data-page="quiz_deck"] .btn-quiz-nav {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.05rem !important;
    }

    /* Mobile Exit Notification Modal Center Placement */
    #exitQuizModal .modal-dialog,
    .modal-dialog-centered {
        width: calc(100% - 2rem) !important;
        max-width: 380px !important;
        margin: auto !important;
    }

    .quiz-header {
        height: auto !important;
        padding: 0.75rem 1rem !important;
    }

    .quiz-subject-title {
        font-size: 1.15rem !important;
    }

    .quiz-question-card {
        padding: 1.5rem 1.25rem !important;
        min-height: 120px !important;
        border-radius: 1.25rem !important;
    }

    .quiz-question-text {
        font-size: 1.05rem !important;
    }

    .btn-quiz-option {
        padding: 1rem 1.25rem !important;
        font-size: 0.98rem !important;
        border-radius: 1.25rem !important;
        min-height: 52px;
    }

    /* ── 7. Accessibility & Profile Screens ────────────────────────── */
    .accessibility-card, .profile-card {
        padding: 1.25rem 1rem !important;
        border-radius: 1.25rem !important;
    }

    .profile-avatar-container {
        margin: 0 auto 1.25rem auto;
    }

    /* Hide Keyboard Navigation & Hotkeys customizer card on mobile */
    #keyboard-navigation-card {
        display: none !important;
    }

    /* ── 8. Profile Screen Mobile Specific Layout ─────────────────── */
    .profile-header-container {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        position: relative !important;
        width: 100% !important;
    }

    .profile-header-container > div {
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
    }

    .profile-avatar-container {
        width: 120px !important;
        height: 120px !important;
        margin: 0 auto 1rem auto !important;
        position: relative !important;
    }

    .profile-img {
        width: 120px !important;
        height: 120px !important;
    }

    .btn-edit-icon {
        position: absolute !important;
        top: 80px !important;
        left: calc(50% + 20px) !important;
        margin: 0 !important;
        width: 38px !important;
        height: 38px !important;
        background-color: #ffffff !important;
        color: #3b49a1 !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15) !important;
    }

    .profile-header-container h1 {
        font-size: 1.5rem !important;
        font-weight: 700 !important;
        margin-top: 0.5rem !important;
        text-align: center !important;
    }

    .profile-header-container p.text-muted {
        font-size: 0.9rem !important;
        text-align: center !important;
        margin-bottom: 1rem !important;
    }

    /* Settings badges layout on mobile */
    #ai-recommendations-list {
        justify-content: center !important;
        gap: 0.5rem !important;
    }

    #ai-recommendations-list .badge {
        font-size: 0.78rem !important;
        padding: 0.4rem 0.75rem !important;
    }

    /* Adjust divider-line to fit mobile bounds without causing overflow scroll */
    .divider-line {
        margin-left: -1rem !important;
        margin-right: -1rem !important;
        width: calc(100% + 2rem) !important;
    }

    /* Adjust analytics card padding and borders for mobile */
    .card.border.shadow-sm.rounded-4.p-4 {
        padding: 1.25rem 1rem !important;
        border-radius: 1.25rem !important;
    }

    /* Spacing for individual index column cards on mobile */
    .profile-header-container + hr + .row.mb-5 .col-md-4 {
        margin-bottom: 1.25rem !important;
    }

    .profile-header-container + hr + .row.mb-5 .col-md-4:last-child {
        margin-bottom: 0 !important;
    }

    /* Adjust progress deck cards to match style rules */
    .progress-deck-card {
        padding: 1rem !important;
        border-radius: 1.25rem !important;
    }

    /* ── 9. Home Screen Mobile Specific Layout ────────────────────── */
    .mobile-logo-header img {
        max-height: 72px !important;
        width: auto !important;
    }

    .import-card {
        max-width: 100% !important;
        border-radius: 1.25rem !important;
        padding: 2.25rem 1.5rem !important;
        background: #ffffff !important;
        border: 1px solid #eef2ff !important;
        box-shadow: 0 8px 24px rgba(59, 73, 161, 0.06) !important;
    }

    .jump-back-in-section {
        width: 100% !important;
    }

    /* ── 10. Authentication Page Mobile Layout ────────────────────── */
    html, body[data-page="auth"] {
        background: linear-gradient(135deg, rgba(248, 250, 252, 0.82) 0%, rgba(226, 232, 240, 0.82) 100%), 
                    url('/static/assets/adaptive_learning_bg1.jpg') no-repeat center center fixed !important;
        background-size: cover !important;
        min-height: 100vh !important;
        height: auto !important;
    }

    body[data-page="auth"] .auth-wrapper {
        background: transparent !important;
        align-items: flex-start !important; /* Fix flexbox vertical centering overflow bug */
        padding: 1rem 0.5rem 3rem 0.5rem !important; /* Scaled down padding to allow stretching */
        min-height: 100vh !important;
        width: 100% !important;
    }

    body[data-page="auth"] .auth-card {
        width: 96% !important; /* Stretch card width to fill space */
        max-width: 96% !important;
        padding: 1.75rem 1rem !important; /* Tightened internal padding */
        border-radius: 1.5rem !important;
        margin: 0.5rem auto 1.5rem auto !important; /* Centered card with smaller top/bottom margin */
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.05) !important;
    }

    /* Keep disability cards readable and compact on mobile */
    body[data-page="auth"] .disability-option-card {
        padding: 1rem !important;
        border-radius: 1rem !important;
        margin-bottom: 0.75rem !important;
        width: 100% !important;
    }

    /* ── 11. Flashcards & Decks Header Mobile Layout ─────────────── */
    .deck-header-wrapper {
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.75rem !important;
        margin-bottom: 1.5rem !important;
        padding-bottom: 1rem !important;
        width: 100% !important;
    }

    .deck-header-wrapper > div {
        width: 100% !important;
    }

    /* Prevent truncation, wrap the deck name nicely so the full name is readable */
    .deck-header-wrapper h1 {
        font-size: 1.6rem !important;
        font-weight: 700 !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        word-break: break-word !important;
    }

    /* Hide top buttons on mobile to avoid overlap and match mockup layout */
    .deck-header-buttons {
        display: none !important;
    }

    .btn-back-circle {
        width: 42px !important;
        height: 42px !important;
        border-radius: 50% !important;
        background-color: #f8f9fc !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
        transition: transform 0.2s ease !important;
    }

    .btn-back-circle:active {
        transform: scale(0.95) !important;
    }
}



