/* Cambridge Kids Academy - Main Stylesheet */
/* Modern, colorful, gamified design for ages 4-17 */

/* ========================================
   VARIABLES & BASE
======================================== */

:root {
    /* Level Colors */
    --a1-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --a2-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --b1-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --b2-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --c1-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --c2-gradient: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
    
    /* Main Colors */
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Neutrals */
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --text-dark: #111827;
    --text-gray: #6b7280;
    --border: #e5e7eb;
    
    /* Spacing */
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========================================
   LOADING SCREEN
======================================== */

.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 1rem auto;
}

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

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

/* ========================================
   NAVIGATION
======================================== */

.navbar {
    background: var(--bg-white);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.nav-brand i {
    font-size: 1.5rem;
}

.nav-menu {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-gray);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-name {
    font-weight: 500;
}

.btn-logout {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: var(--error);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ========================================
   AUTH SCREEN
======================================== */

.auth-screen {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-container {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 450px;
    width: 100%;
    animation: slideUp 0.5s;
}

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

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-gray);
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--bg-light);
    color: var(--text-dark);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-gray);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ========================================
   MAIN APP
======================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.section {
    display: none;
    animation: fadeIn 0.5s;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   DASHBOARD
======================================== */

.welcome-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem;
    border-radius: 20px;
    margin-bottom: 2rem;
    text-align: center;
}

.welcome-banner h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.stat-card h3 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-card p {
    color: var(--text-gray);
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.level-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
}

.level-card[data-level="A1"]::before { background: var(--a1-gradient); }
.level-card[data-level="A2"]::before { background: var(--a2-gradient); }
.level-card[data-level="B1"]::before { background: var(--b1-gradient); }
.level-card[data-level="B2"]::before { background: var(--b2-gradient); }
.level-card[data-level="C1"]::before { background: var(--c1-gradient); }
.level-card[data-level="C2"]::before { background: var(--c2-gradient); }

.level-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.level-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    margin-bottom: 1rem;
}

.level-card[data-level="A1"] .level-badge { background: var(--a1-gradient); }
.level-card[data-level="A2"] .level-badge { background: var(--a2-gradient); }
.level-card[data-level="B1"] .level-badge { background: var(--b1-gradient); }
.level-card[data-level="B2"] .level-badge { background: var(--b2-gradient); }
.level-card[data-level="C1"] .level-badge { background: var(--c1-gradient); }
.level-card[data-level="C2"] .level-badge { background: var(--c2-gradient); }

.level-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.level-card p {
    color: var(--text-gray);
    margin-bottom: 1rem;
}

.level-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-gray);
}

.btn-level {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-level:hover {
    transform: scale(1.05);
}

/* ========================================
   EXERCISES
======================================== */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.btn-back {
    padding: 0.5rem 1rem;
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.btn-back:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.exercise-type-badge {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.categories-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.category-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid var(--border);
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    font-weight: 500;
}

.category-btn:hover,
.category-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.exercises-list {
    display: grid;
    gap: 1rem;
}

.exercise-item {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s;
}

.exercise-item:hover {
    transform: translateX(10px);
    box-shadow: var(--shadow-lg);
}

.exercise-item.completed {
    border-left: 4px solid var(--success);
}

.exercise-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary);
}

.exercise-info {
    flex: 1;
}

.exercise-info h4 {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-badge,
.base-badge {
    font-size: 0.8rem;
}

.ai-badge {
    color: var(--secondary);
}

.base-badge {
    color: var(--success);
}

.exercise-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-gray);
}

.btn-start-exercise {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.btn-start-exercise:hover {
    background: #4f46e5;
    transform: scale(1.05);
}

/* ========================================
   MODAL
======================================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

.modal-header {
    padding: 2rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 2rem;
}

.btn-close {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-light);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-close:hover {
    background: var(--error);
    color: white;
}

.options-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.option-item {
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option-item:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.option-item input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.exercise-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.exercise-result {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: var(--radius);
    display: none;
}

.result-content {
    display: flex;
    gap: 1rem;
    align-items: start;
}

.result-content.correct {
    background: rgba(16, 185, 129, 0.1);
    border: 2px solid var(--success);
}

.result-content.incorrect {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--error);
}

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

.result-content.correct .result-icon {
    color: var(--success);
}

.result-content.incorrect .result-icon {
    color: var(--error);
}

.points-earned {
    margin-top: 0.5rem;
    font-weight: 600;
    color: var(--warning);
}

/* ========================================
   AI ASSISTANT
======================================== */

.ai-assistant-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s;
    z-index: 999;
}

.ai-assistant-btn:hover {
    transform: scale(1.1);
}

.ai-assistant-btn.hidden {
    display: none;
}

.ai-assistant-panel {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    z-index: 1000;
    animation: slideUp 0.3s;
}

.ai-assistant-panel.active {
    display: flex;
}

.assistant-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.assistant-message {
    display: flex;
    gap: 0.75rem;
    align-items: start;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.assistant-message.bot .message-avatar {
    background: var(--secondary);
    color: white;
}

.assistant-message.user .message-avatar {
    background: var(--primary);
    color: white;
}

.message-content {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--bg-light);
}

.assistant-input {
    padding: 1rem;
    border-top: 2px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

.assistant-input input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
}

.assistant-input button {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
}

.assistant-input button:hover {
    background: #4f46e5;
}

/* ========================================
   TOAST NOTIFICATIONS
======================================== */

.toast-container {
    position: fixed;
    top: 5rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 300px;
    animation: slideInRight 0.3s;
    opacity: 0;
}

.toast.show {
    opacity: 1;
}

.toast-info {
    background: var(--info);
    color: white;
}

.toast-success {
    background: var(--success);
    color: white;
}

.toast-warning {
    background: var(--warning);
    color: white;
}

.toast-error {
    background: var(--error);
    color: white;
}

.toast button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
    }
    to {
        transform: translateX(0);
    }
}

/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-menu {
        flex-direction: column;
    }
    
    .nav-link {
        justify-content: center;
    }
    
    .stats-grid,
    .levels-grid {
        grid-template-columns: 1fr;
    }
    
    .ai-assistant-panel {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .toast-container {
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        min-width: auto;
    }
}

/* ========================================
   UTILITIES
======================================== */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-gray);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
