/* ============================================
   ZimLearn - Base Styles & Layout
   ============================================ */

:root {
    --primary: #6C63FF;
    --primary-light: #8B83FF;
    --primary-dark: #5A52D5;
    --accent: #FF6B6B;
    --accent-alt: #4ECDC4;
    --success: #2ECC71;
    --warning: #F1C40F;
    --danger: #E74C3C;
    --bg: #F0F4FF;
    --surface: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --text-muted: #B2BEC3;
    --border: #DFE6E9;
    --shadow: rgba(108, 99, 255, 0.1);
    --shadow-md: rgba(108, 99, 255, 0.15);

    /* Subject colors */
    --english: #3498DB;
    --maths: #E74C3C;
    --shona: #27AE60;
    --social: #F39C12;
    --agric: #8B4513;
    --pe: #E67E22;
    --ict: #9B59B6;
    --heritage: #E91E63;

    --nav-height: 60px;
    --topbar-height: 56px;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
}

/* Animations */
@keyframes zlSlideUp { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:translateY(0); } }
@keyframes zlSlideDown { from { opacity:0; transform:translateY(-20px); } to { opacity:1; transform:translateY(0); } }
@keyframes zlPop { 0% { transform:scale(0.5); opacity:0; } 60% { transform:scale(1.1); } 100% { transform:scale(1); opacity:1; } }
@keyframes zlBounce { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-6px); } }
@keyframes zlBarGrow { from { transform:scaleY(0); } to { transform:scaleY(1); } }
@keyframes zlFadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes zlScaleIn { from { opacity:0; transform:scale(0.8); } to { opacity:1; transform:scale(1); } }
@keyframes zlWiggle { 0%,100% { transform:rotate(0); } 25% { transform:rotate(-6deg); } 75% { transform:rotate(6deg); } }
@keyframes zlXpFill { from { width:0; } }
@keyframes zlPulse { 0%,100% { transform:scale(1); } 50% { transform:scale(1.03); } }
.zl-slide-up { animation: zlSlideUp 0.4s ease-out both; }
.zl-slide-down { animation: zlSlideDown 0.4s ease-out both; }
.zl-pop { animation: zlPop 0.4s ease-out both; }
.zl-bounce-emoji { animation: zlBounce 1s ease-in-out infinite; }
.zl-wiggle { animation: zlWiggle 0.6s ease-in-out; }
.zl-fade-in { animation: zlFadeIn 0.4s ease-out both; }
.zl-bar-grow { transform-origin: bottom; animation: zlBarGrow 0.6s ease-out both; }
.zl-pulse { animation: zlPulse 2s ease-in-out infinite; }
.zl-subj-detail { overflow:hidden; max-height:0; transition: max-height 0.35s ease-out, padding 0.35s ease-out; padding:0 16px; }
.zl-subj-detail.open { max-height:2000px; padding:0 16px 14px; transition: max-height 0.5s ease-in, padding 0.3s ease-in; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Top Bar
   ============================================ */
.topbar {
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    padding: 0 16px;
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.topbar-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    margin-right: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-btn:active {
    background: rgba(255,255,255,0.2);
}

.topbar-title {
    flex: 1;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.topbar-xp {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
}

.page {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ============================================
   Bottom Navigation
   ============================================ */
.bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    z-index: 100;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    gap: 2px;
    min-width: 64px;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active svg {
    stroke: var(--primary);
    transform: scale(1.1);
}

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

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: slideDown 0.3s ease, slideUp 0.3s ease 2.7s;
    pointer-events: auto;
    text-align: center;
}

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

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text); }
.toast.info { background: var(--primary); }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px 20px;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: var(--bg);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
}

/* ============================================
   Confetti Canvas
   ============================================ */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

/* ============================================
   Scrollbar
   ============================================ */
.main-content::-webkit-scrollbar { width: 4px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ============================================
   Auth Pages (Login/Register)
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
    color: white;
}

.auth-logo h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
}

.auth-logo p {
    font-size: 14px;
    opacity: 0.8;
    margin-top: 4px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

.auth-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    border: none;
    background: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: rgba(255,255,255,0.7);
    font-size: 13px;
}

.auth-footer a {
    color: white;
    font-weight: 600;
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
    color: var(--text-light);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state .emoji {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================
   Tablet Portrait (768px+)
   ============================================ */
@media (min-width: 768px) {
    .page {
        max-width: none;
        padding: 20px 24px;
    }

    .topbar {
        padding: 0 24px;
    }

    .topbar-title {
        font-size: 20px;
    }

    .nav-item {
        font-size: 12px;
        padding: 8px 20px;
        min-width: 80px;
    }

    .nav-item svg {
        width: 24px;
        height: 24px;
    }

    .modal-content {
        max-width: 600px;
        padding: 28px 24px;
    }

    .auth-card {
        max-width: 480px;
        padding: 32px 28px;
    }

    .auth-logo h1 {
        font-size: 40px;
    }

    .empty-state {
        padding: 56px 32px;
    }

    .empty-state .emoji {
        font-size: 56px;
    }

    .empty-state h3 {
        font-size: 20px;
    }

    .empty-state p {
        font-size: 15px;
    }

    .toast-container {
        max-width: 480px;
    }
}

/* ============================================
   Tablet Landscape (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    .page {
        max-width: none;
        padding: 24px 32px;
    }

    .modal-content {
        max-width: 680px;
    }

    .auth-card {
        max-width: 520px;
        padding: 36px 32px;
    }
}
