/* ===== NATUMEX 2.0 - Mobile & Multi-Page Styles ===== */

/* ===== Page Transitions ===== */
@keyframes pageSlideIn {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes pageSlideOut {
    to { opacity: 0; transform: translateX(-16px); }
}

.page-content {
    animation: pageSlideIn 0.22s ease-out;
}

.page-content.page-exit {
    animation: pageSlideOut 0.18s ease-in forwards;
    pointer-events: none;
}

/* ===== Bottom Mobile Navigation ===== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--bg-card, #fff);
    border-top: 1px solid var(--border-color, rgba(0,0,0,0.08));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    height: 64px;
    padding: 0 var(--spacing-2, 0.5rem);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted, #9ca3af);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: color 0.2s, transform 0.15s;
    padding: 6px 4px;
    border-radius: var(--radius-md, 0.75rem);
    min-width: 0;
}

.bottom-nav-item:active {
    transform: scale(0.92);
}

.bottom-nav-item.active {
    color: var(--green-primary, #006847);
}

.bottom-nav-icon {
    font-size: 1.3rem;
    line-height: 1;
    transition: transform 0.2s;
}

.bottom-nav-item.active .bottom-nav-icon {
    transform: scale(1.1);
}

.bottom-nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ===== Study Page Layout ===== */
.study-page-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-4, 1rem);
    padding: var(--spacing-6, 1.5rem) 0 var(--spacing-4, 1rem);
    border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.08));
    margin-bottom: var(--spacing-6, 1.5rem);
    flex-wrap: wrap;
}

.study-page-header .study-topic-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-3, 0.75rem);
    flex: 1;
    min-width: 0;
}

.study-page-header h1 {
    font-size: var(--font-size-2xl, 1.5rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#modal-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

/* ===== Exam Page Layout ===== */
.exam-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-6, 1.5rem) 0 var(--spacing-4, 1rem);
    border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.08));
    margin-bottom: var(--spacing-6, 1.5rem);
    flex-wrap: wrap;
    gap: var(--spacing-4);
}

.exam-page-header h2 {
    font-size: var(--font-size-2xl, 1.5rem);
    font-weight: 700;
    margin: 0;
}

.exam-page-header .exam-stats {
    display: flex;
    align-items: center;
    gap: var(--spacing-4, 1rem);
    flex-wrap: wrap;
}

/* ===== Dashboard Page ===== */
.dashboard-page-header {
    padding: var(--spacing-6, 1.5rem) 0 var(--spacing-4, 1rem);
}

/* ===== Tabs (standalone, not in modal) ===== */
.page-tabs {
    display: flex;
    gap: var(--spacing-2, 0.5rem);
    padding: var(--spacing-2, 0.5rem);
    background: var(--bg-secondary, #f0f4f8);
    border-radius: var(--radius-xl, 1.25rem);
    margin-bottom: var(--spacing-6, 1.5rem);
}

.page-tabs .tab {
    flex: 1;
    padding: var(--spacing-3, 0.75rem) var(--spacing-4, 1rem);
    border: none;
    background: transparent;
    border-radius: var(--radius-lg, 1rem);
    font-family: var(--font-family);
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.page-tabs .tab.active {
    background: var(--bg-card, #fff);
    color: var(--green-primary, #006847);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.08));
}

.page-tabs .tab:hover:not(.active) {
    background: rgba(255,255,255,0.5);
    color: var(--text-primary);
}

/* ===== Back Button ===== */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2, 0.5rem);
    padding: var(--spacing-2, 0.5rem) var(--spacing-4, 1rem);
    border-radius: var(--radius-full, 9999px);
    background: var(--bg-secondary, #f0f4f8);
    color: var(--text-secondary);
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-back:hover {
    background: var(--border-color, rgba(0,0,0,0.08));
    color: var(--text-primary);
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 768px) {
    /* Show bottom nav */
    .bottom-nav {
        display: flex;
        align-items: center;
    }

    /* Add padding so content doesn't hide behind bottom nav */
    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* Hide desktop nav links on mobile */
    .nav {
        display: none !important;
    }

    /* Hamburger show */
    .hamburger {
        display: flex !important;
    }

    /* Hero adjustments */
    .hero-content h1 {
        font-size: var(--font-size-3xl, 1.875rem) !important;
    }

    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }

    .hero-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    .hero-decoration {
        display: none;
    }

    .hero .container {
        grid-template-columns: 1fr !important;
    }

    /* Topic cards: 1 column on tiny screens, 2 on medium mobile */
    .topics-grid {
        grid-template-columns: 1fr !important;
    }

    /* Study page */
    .study-page-header h1 {
        font-size: var(--font-size-xl, 1.25rem) !important;
    }

    .page-tabs .tab {
        font-size: 0.75rem;
        padding: var(--spacing-2, 0.5rem) var(--spacing-2, 0.5rem);
    }

    /* Exam */
    .exam-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Quiz options: 1 column */
    .quiz-options {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard grid */
    .dashboard-grid-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    .dashboard-layout-main {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard cards: reducir padding en mobile */
    .inner-card {
        padding: 1rem !important;
    }

    .stat-card {
        padding: 0.875rem !important;
        gap: 0.75rem !important;
    }

    .stat-icon {
        width: 44px !important;
        height: 44px !important;
        font-size: 1.4rem !important;
    }

    .stat-value {
        font-size: 1.25rem !important;
    }

    /* Exam stats: 3 columnas pero más compactas */
    .exam-stats-grid {
        gap: 0.5rem !important;
    }

    .exam-stat-item {
        padding: 0.625rem 0.25rem !important;
    }

    .exam-stat-val {
        font-size: 1.25rem !important;
    }

    .exam-stat-lbl {
        font-size: 0.65rem !important;
    }

    /* Header de estadísticas: apilar título y selector en mobile */
    .exam-summary > div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    .premium-select {
        width: 100% !important;
    }

    /* Map */
    #mapWrapper {
        grid-template-columns: 1fr !important;
    }

    #map-container {
        height: 350px !important;
    }

    /* Header */
    .header-content {
        padding: 0 var(--spacing-4, 1rem);
    }

    .auth-button span:last-child {
        display: none;
    }

    /* Modals full screen */
    .modal-container {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh;
        border-radius: 0 !important;
        margin: 0 !important;
    }
}

@media (min-width: 400px) and (max-width: 768px) {
    .topics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 769px) {
    /* Hide bottom nav on desktop */
    .bottom-nav {
        display: none !important;
    }
}

/* Dark theme adjustments for bottom nav */
[data-theme="dark"] .bottom-nav {
    background: var(--bg-card);
    border-top-color: var(--border-color);
}

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

[data-theme="dark"] .page-tabs .tab.active {
    background: rgba(255,255,255,0.1);
}

/* ===== Site Footer ===== */
.site-footer {
    border-top: 1px solid var(--border-color, rgba(0,0,0,0.08));
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .site-footer {
        padding-bottom: 70px;
    }
}

[data-theme="dark"] .btn-back {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-back:hover {
    background: rgba(255,255,255,0.15);
}
