/* ==========================================================================
   DESIGN SYSTEM & CUSTOM PROPERTIES
   ========================================================================== */
:root {
    /* Color System (LDS-inspired Navy/Gold + Gamification Yellow) */
    --color-bg-base: #faf9f6;       /* Soft cream background */
    --color-bg-card: #ffffff;       /* Pure white card backgrounds */
    --color-primary: #0f2537;       /* Elegant deep navy blue */
    --color-primary-light: #1b3d59; /* Soft navy for secondary text/borders */
    --color-accent-gold: #c5a059;   /* Classic LDS gold */
    --color-accent-gold-light: #e5cf9c;
    --color-yellow-button: #f9cb40; /* High-contrast bright yellow */
    --color-yellow-hover: #f7bd15;  /* Deep yellow hover state */
    --color-text-dark: #202b35;     /* Dark charcoal text for readability */
    --color-text-muted: #64748b;    /* Slate gray for subtitles */
    --color-border: #e2e8f0;        /* Card dividers */
    --color-success: #10b981;       /* Active badges */
    --color-success-light: #ecfdf5; /* Completed card background */
    --color-error: #ef4444;         /* Error text */
    --color-error-light: #fef2f2;   /* Incorrect option background */
    
    /* Layout & Styling Tokens */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 4px 6px -1px rgba(15, 37, 55, 0.05), 0 2px 4px -1px rgba(15, 37, 55, 0.03);
    --shadow-md: 0 10px 15px -3px rgba(15, 37, 55, 0.08), 0 4px 6px -2px rgba(15, 37, 55, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(15, 37, 55, 0.1), 0 10px 10px -5px rgba(15, 37, 55, 0.04);
    --shadow-glow: 0 0 20px rgba(249, 203, 64, 0.4);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Fonts */
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg-base);
    color: var(--color-text-dark);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
    border-bottom: 3px solid var(--color-accent-gold);
}

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

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

#app-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.75rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, var(--color-accent-gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ==========================================================================
   NAVIGATION TABS
   ========================================================================== */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.07);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    padding: 0.6rem 1.2rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: calc(var(--radius-sm) - 2px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--color-primary);
    background-color: var(--color-yellow-button);
    box-shadow: var(--shadow-sm);
}

.tab-icon {
    font-size: 1.1rem;
}

/* ==========================================================================
   LAYOUT STRUCTURE (SPLIT VIEW)
   ========================================================================== */
.main-split-container {
    max-width: 1200px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1.5rem;
    flex-grow: 1;
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 2rem;
    align-items: start;
}

/* ==========================================================================
   LEFT PANEL (TEACHER CONTAINER)
   ========================================================================== */
.left-panel {
    position: sticky;
    top: 100px;
}

.teacher-box {
    background-color: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Speech Bubble styling */
.speech-bubble-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 2rem;
    perspective: 1000px;
}

.speech-bubble {
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    position: relative;
    font-size: 1.05rem;
    line-height: 1.5;
    font-weight: 500;
    border: 2px solid var(--color-accent-gold);
    animation: bubblePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Speech bubble pointer arrow pointing down */
.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid var(--color-accent-gold);
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 9px solid var(--color-primary);
    z-index: 2;
}

/* Avatar container with floating teacher */
.avatar-container {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0.5rem 0 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(197,160,89,0.15) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    animation: glowPulse 3s ease-in-out infinite;
}

.sprite-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    border: 4px solid var(--color-accent-gold);
    background-color: #f8fafc;
    box-shadow: var(--shadow-sm);
    animation: avatarFloat 4s ease-in-out infinite;
    transition: var(--transition-smooth);
}

.sprite-img.happy {
    border-color: var(--color-yellow-button);
}

.sprite-img.serious {
    border-color: var(--color-primary);
}

.sprite-img.doubtful {
    border-color: var(--color-accent-gold);
}

.teacher-nametag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 0.5rem 1.25rem;
    border-radius: 50px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    border: 1px solid var(--color-accent-gold);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-yellow-button);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(249, 203, 64, 0.7);
    animation: pulse 1.8s infinite;
}

/* ==========================================================================
   RIGHT PANEL (VIEWS & CARDS)
   ========================================================================== */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.view-content {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view-content.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Premium Card Design */
.card {
    background-color: var(--color-bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: var(--transition-smooth);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 1.75rem 2rem 1.25rem 2rem;
    border-bottom: 1px solid var(--color-border);
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    color: var(--color-primary);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.card-body {
    padding: 2rem;
}

/* ==========================================================================
   VIEW 1: INICIO DETAILS
   ========================================================================== */
.intro-art-container {
    position: relative;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    color: #ffffff;
    margin-bottom: 2rem;
    overflow: hidden;
}

.intro-art-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 250px;
    height: 250px;
    background-color: rgba(197, 160, 89, 0.15);
    border-radius: 50%;
    filter: blur(40px);
}

.intro-preview-img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--color-yellow-button);
    background-color: #ffffff;
    flex-shrink: 0;
}

.welcome-text-overlay h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--color-yellow-button);
}

.welcome-text-overlay p {
    font-size: 0.95rem;
    opacity: 0.9;
}

.intro-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.25rem;
}

.stat-box {
    background-color: var(--color-bg-base);
    border: 1px solid var(--color-border);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    text-align: center;
    transition: var(--transition-smooth);
}

.stat-box:hover {
    border-color: var(--color-accent-gold);
    transform: translateY(-2px);
}

.stat-number {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn-primary {
    background-color: var(--color-yellow-button);
    color: var(--color-primary);
    border: none;
    padding: 1rem 2rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 2px solid transparent;
}

.action-btn-primary:hover {
    background-color: var(--color-yellow-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.action-btn-primary:active {
    transform: translateY(0);
}

/* ==========================================================================
   NEW: PROFILE FORM STYLING
   ========================================================================== */
.profile-card {
    margin-top: 1.5rem;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-primary);
}

.form-group input[type="text"] {
    padding: 0.85rem 1rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: #f8fafc;
    color: var(--color-text-dark);
    outline: none;
    transition: var(--transition-smooth);
}

.form-group input[type="text"]:focus {
    border-color: var(--color-accent-gold);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.25);
}

.nickname-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: #f8fafc;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.nickname-input-wrapper:focus-within {
    border-color: var(--color-accent-gold);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.25);
}

.nickname-prefix {
    padding: 0.85rem 0 0.85rem 1rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-accent-gold);
    font-size: 1.1rem;
    user-select: none;
}

.nickname-input-wrapper input {
    border: none !important;
    background: transparent !important;
    padding-left: 0.25rem !important;
    width: 100%;
    outline: none;
}

.profile-action-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.action-btn-primary.small-btn {
    width: auto;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
}

.status-success-message {
    color: var(--color-success);
    font-weight: 600;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease-out;
}

/* ==========================================================================
   VIEW 2: COURSES STYLES
   ========================================================================== */
.course-category {
    margin-bottom: 2.25rem;
}

.course-category:last-child {
    margin-bottom: 0;
}

.category-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.category-icon {
    font-size: 1.4rem;
}

.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
}

.course-btn {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #ffffff;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: left;
    width: 100%;
}

.course-btn-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.course-emoji {
    font-size: 2.2rem;
    transition: var(--transition-smooth);
}

.course-info {
    display: flex;
    flex-direction: column;
}

.course-name {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary);
}

.course-status-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.course-btn.active-course {
    position: relative;
    overflow: hidden;
}

.course-btn.active-course:hover {
    border-color: var(--color-yellow-button);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.course-btn.active-course:hover .course-emoji {
    transform: scale(1.15) rotate(5deg);
}

.course-arrow {
    font-size: 1.2rem;
    color: var(--color-accent-gold);
    font-weight: bold;
    transition: var(--transition-smooth);
}

.course-btn.active-course:hover .course-arrow {
    transform: translateX(4px);
    color: var(--color-yellow-hover);
}

.course-btn.locked-course {
    background-color: #f1f5f9;
    cursor: not-allowed;
    opacity: 0.65;
    border-style: dashed;
}

.course-btn.locked-course .course-name {
    color: #94a3b8;
}

.course-btn.locked-course .course-emoji {
    filter: grayscale(80%);
}

.lock-icon {
    font-size: 1.1rem;
    color: #94a3b8;
}

.course-btn.locked-course:hover {
    background-color: #e2e8f0;
}

/* ==========================================================================
   NEW: COURSE DETAIL & LEVELS SCREEN
   ========================================================================== */
.detail-header-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.back-btn {
    background-color: #f1f5f9;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.back-btn:hover {
    background-color: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
    transform: translateX(-2px);
}

.course-progress-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    background-color: #f8fafc;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.progress-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-primary);
}

.progress-bar-bg {
    flex-grow: 1;
    height: 12px;
    background-color: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    min-width: 150px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-yellow-button) 0%, var(--color-accent-gold) 100%);
    border-radius: 6px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-percentage-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-primary);
}

.levels-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.level-section {
    background-color: #f8fafc;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--color-border);
}

.level-section-header {
    margin-bottom: 1.25rem;
}

.level-section-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--color-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.level-section-header h3::before {
    content: "⚡";
    font-size: 1.1rem;
}

.level-section-header .subtitle {
    margin-top: 0.15rem;
}

.lessons-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.lesson-card {
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
}

.lesson-card:hover {
    transform: translateY(-3px);
    border-color: var(--color-accent-gold);
    box-shadow: var(--shadow-sm);
}

.lesson-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.lesson-card h4 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary);
    max-width: 80%;
}

.lesson-xp-tag {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    background-color: #f1f5f9;
    color: var(--color-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.lesson-card-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.lesson-status-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.lesson-card.completed {
    background-color: var(--color-success-light);
    border-color: var(--color-success);
}

.lesson-card.completed h4 {
    color: #065f46;
}

.lesson-card.completed .lesson-status-footer {
    color: var(--color-success);
}

.lesson-card.completed .lesson-xp-tag {
    background-color: rgba(16, 185, 129, 0.15);
    color: #065f46;
}

/* ==========================================================================
   NEW: LESSON STUDY VIEW & QUIZ STYLING
   ========================================================================== */
.lesson-meta-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.xp-gain-badge {
    background-color: rgba(249, 203, 64, 0.15);
    color: #9a3412;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
}

.lesson-content-box {
    background-color: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.lesson-content-box h3 {
    font-family: var(--font-heading);
    color: var(--color-primary);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.lesson-text {
    font-size: 1.05rem;
    color: var(--color-text-dark);
    white-space: pre-line;
    line-height: 1.7;
}

.quiz-box {
    border: 2px solid var(--color-accent-gold);
    animation: fadeIn 0.4s ease-out;
}

.mini-header {
    background-color: rgba(197, 160, 89, 0.05);
    padding: 1.25rem 1.5rem;
}

.mini-header h3 {
    font-size: 1.2rem !important;
}

.mini-body {
    padding: 1.5rem;
}

.quiz-question-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-primary);
    margin-bottom: 1.25rem;
}

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

.quiz-btn {
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-dark);
    text-align: left;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.quiz-btn:hover:not(:disabled) {
    background-color: #f8fafc;
    border-color: var(--color-primary-light);
    transform: translateY(-1px);
}

.quiz-btn:disabled {
    cursor: not-allowed;
}

.quiz-btn.correct {
    background-color: var(--color-success-light) !important;
    border-color: var(--color-success) !important;
    color: #065f46 !important;
    font-weight: 600;
}

.quiz-btn.incorrect {
    background-color: var(--color-error-light) !important;
    border-color: var(--color-error) !important;
    color: #991b1b !important;
}

.quiz-feedback-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    animation: bubblePop 0.3s ease-out;
}

.quiz-feedback-box.correct-box {
    background-color: var(--color-success-light);
    border: 1px solid var(--color-success);
    color: #065f46;
}

.quiz-feedback-box.incorrect-box {
    background-color: var(--color-error-light);
    border: 1px solid var(--color-error);
    color: #991b1b;
}

#quiz-feedback-icon {
    font-size: 1.5rem;
}

#quiz-feedback-text {
    font-weight: 600;
    font-size: 0.95rem;
}

/* ==========================================================================
   VIEW 3: PROGRESO & LEADERBOARD STYLES
   ========================================================================== */
.leaderboard-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.leaderboard-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.sort-direction-btn, .refresh-btn {
    background-color: #f8fafc;
    border: 1px solid var(--color-border);
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text-dark);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.sort-direction-btn:hover, .refresh-btn:hover {
    background-color: #f1f5f9;
    border-color: var(--color-accent-gold);
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.leaderboard-table th {
    background-color: #f8fafc;
    padding: 1rem 1.25rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-border);
}

.leaderboard-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    transition: var(--transition-smooth);
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-table tbody tr:hover td {
    background-color: rgba(197, 160, 89, 0.03);
}

.th-rank {
    width: 70px;
    text-align: center;
}

.td-rank {
    text-align: center;
    font-weight: 700;
    font-family: var(--font-heading);
}

.rank-1 {
    color: #eab308;
    background-color: rgba(234, 179, 8, 0.1);
    border-radius: 50%;
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.rank-2 {
    color: #94a3b8;
    background-color: rgba(148, 163, 184, 0.1);
    border-radius: 50%;
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.rank-3 {
    color: #b45309;
    background-color: rgba(180, 83, 9, 0.1);
    border-radius: 50%;
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.td-student {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.student-name {
    font-weight: 600;
    color: var(--color-primary);
}

.student-nickname {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.th-points, .td-points {
    text-align: right;
    font-weight: 700;
    font-family: var(--font-heading);
}

.td-points {
    color: var(--color-primary-light);
}

/* Highlight Gold, Silver, Bronze rows or current user */
.ssj-glow {
    background-color: rgba(249, 203, 64, 0.08) !important;
    position: relative;
    border-left: 4px solid var(--color-yellow-button) !important;
}

.ssj-glow td {
    color: #9a3412 !important;
}

.ssj-glow .student-name {
    color: #b45309 !important;
    text-shadow: 0 0 2px rgba(249, 203, 64, 0.2);
}

.ssj-glow .student-name::after {
    content: " 🔥";
    display: inline-block;
    animation: firePulse 1s infinite alternate;
}

.ssj-glow .td-points {
    color: #b45309 !important;
    font-weight: 900;
    text-shadow: 0 0 5px rgba(249, 203, 64, 0.3);
}

/* Local Player Highlight row */
.local-player-row {
    background-color: rgba(197, 160, 89, 0.08) !important;
    border-left: 4px solid var(--color-accent-gold) !important;
}

.local-player-row td {
    color: var(--color-primary) !important;
}

.local-player-row .student-name {
    color: var(--color-primary) !important;
    font-weight: 700;
}

.local-player-row .student-name::after {
    content: " ✨ (Tú)";
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-accent-gold);
}

/* Loading/Empty State */
.loader-container {
    padding: 3rem 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--color-text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top: 4px solid var(--color-accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

/* ==========================================================================
   APP FOOTER
   ========================================================================== */
.app-footer {
    background-color: var(--color-primary);
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    padding: 1.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 3rem;
}

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

@keyframes bubblePop {
    0% { transform: scale(0.85) translateY(5px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

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

@keyframes glowPulse {
    0% { transform: scale(0.9); opacity: 0.3; }
    50% { transform: scale(1.15); opacity: 0.6; }
    100% { transform: scale(0.9); opacity: 0.3; }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(249, 203, 64, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(249, 203, 64, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(249, 203, 64, 0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes firePulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

/* ==========================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ========================================================================== */
@media (max-width: 900px) {
    .main-split-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin: 1rem auto;
    }
    
    .left-panel {
        position: relative;
        top: 0;
    }
    
    .teacher-box {
        flex-direction: row;
        text-align: left;
        padding: 1.25rem;
        gap: 1.5rem;
        align-items: center;
    }
    
    .speech-bubble-wrapper {
        margin-bottom: 0;
        flex-grow: 1;
        order: 2;
    }
    
    .speech-bubble {
        padding: 1rem;
        font-size: 0.95rem;
    }
    
    .speech-bubble::after {
        left: -12px;
        top: 50%;
        bottom: auto;
        transform: translateY(-50%) rotate(90deg);
    }
    
    .speech-bubble::before {
        left: -9px;
        top: 50%;
        bottom: auto;
        transform: translateY(-50%) rotate(90deg);
    }
    
    .avatar-container {
        width: 100px;
        height: 100px;
        margin: 0;
        flex-shrink: 0;
        order: 1;
    }
    
    .teacher-nametag {
        display: none;
    }
}

@media (max-width: 600px) {
    .header-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .nav-tabs {
        width: 100%;
        justify-content: center;
    }
    
    .tab-btn {
        flex-grow: 1;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .teacher-box {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }
    
    .avatar-container {
        width: 110px;
        height: 110px;
        margin-bottom: 1rem;
    }
    
    .speech-bubble-wrapper {
        width: 100%;
        order: 2;
    }
    
    .speech-bubble::after {
        left: 50%;
        top: -12px;
        bottom: auto;
        transform: translateX(-50%) rotate(180deg);
    }
    
    .speech-bubble::before {
        left: 50%;
        top: -9px;
        bottom: auto;
        transform: translateX(-50%) rotate(180deg);
    }
    
    .card-header, .card-body {
        padding: 1.25rem;
    }
    
    .courses-grid {
        grid-template-columns: 1fr;
    }
    
    .leaderboard-title-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .leaderboard-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .sort-direction-btn, .refresh-btn {
        flex-grow: 1;
        justify-content: center;
    }
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */
.hidden {
    display: none !important;
}

/* ==========================================================================
   ADDED: CREATOR & LEGACY GUIDES STYLING
   ========================================================================== */

/* Creator Corner - Hidden in bottom left panel */
.creator-corner {
    margin-top: 1.5rem;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px dashed var(--color-border);
    padding-top: 1rem;
}
.creator-link {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition-smooth);
    opacity: 0.7;
}
.creator-link:hover {
    color: var(--color-accent-gold);
    opacity: 1;
    transform: scale(1.05);
}

/* Vial Card & Link Buttons on Home */
.vial-card {
    border-left: 5px solid var(--color-accent-gold);
    background: linear-gradient(to bottom, #ffffff, #fafaf9);
}
.vial-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-top: 0.5rem;
}
.vial-link-btn {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text-dark);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
}
.vial-link-btn .icon {
    font-size: 2.2rem;
    transition: var(--transition-smooth);
}
.vial-link-btn .link-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.vial-link-btn .link-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-primary);
}
.vial-link-btn .link-desc {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.3;
}

/* Hover animations for Home Vial Links */
.vial-link-btn:hover {
    transform: translateY(-4px);
    border-color: var(--color-accent-gold);
    box-shadow: var(--shadow-md);
}
.vial-link-btn.initial-exercises:hover {
    border-color: var(--color-success);
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.1), 0 4px 6px -2px rgba(16, 185, 129, 0.05);
}
.vial-link-btn.study-deep:hover {
    border-color: var(--color-primary);
    box-shadow: 0 10px 15px -3px rgba(15, 37, 55, 0.1), 0 4px 6px -2px rgba(15, 37, 55, 0.05);
}
.vial-link-btn:hover .icon {
    transform: scale(1.2) rotate(-5deg);
}

/* Official Guides (Material Histórico) - Teal themed */
.official-guides-section {
    background-color: #f0f7f7; /* Very light teal/cyan background */
    border: 1px solid #cce5e5;
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}
.official-guides-header {
    margin-bottom: 1.25rem;
    border-bottom: 1px solid #cce5e5;
    padding-bottom: 0.75rem;
}
.official-guides-header h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: #00686b; /* Dark teal */
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.official-guides-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}
.official-guide-card {
    background-color: #ffffff;
    border: 1px solid #b3d9d9;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    text-decoration: none;
    color: var(--color-text-dark);
    position: relative;
    transition: var(--transition-smooth);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 104, 107, 0.04);
}
.official-guide-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: #008b91; /* Guide theme teal */
}
.guide-card-icon {
    font-size: 2rem;
    flex-shrink: 0;
    transition: var(--transition-smooth);
}
.guide-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-right: 0.5rem;
}
.guide-card-info h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: #005658;
    line-height: 1.2;
}
.guide-card-info p {
    font-size: 0.78rem;
    color: #556b6b;
    line-height: 1.4;
}
.guide-card-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #008b91;
    background-color: #e0f2f1;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* Hover effect for Official Guide Cards */
.official-guide-card:hover {
    transform: translateY(-3px);
    border-color: #008b91;
    box-shadow: 0 8px 16px rgba(0, 139, 145, 0.12);
    background-color: #fafdfd;
}
.official-guide-card:hover .guide-card-icon {
    transform: scale(1.15) rotate(4deg);
}

/* Responsive adjustment for Vial Grid & Official Guides */
@media (max-width: 768px) {
    .vial-links-grid, .official-guides-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   ADDED: QUIZ PROGRESS & NEXT QUESTION BUTTON STYLING
   ========================================================================== */
.quiz-progress-indicator {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-accent-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    display: inline-block;
    background-color: rgba(197, 160, 89, 0.08);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 1px solid rgba(197, 160, 89, 0.2);
}

.next-question-btn {
    background-color: var(--color-yellow-button);
    color: var(--color-primary);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    margin-left: auto; /* Push to the right in the feedback box flex layout */
    transition: var(--transition-smooth);
    box-shadow: 0 4px 6px rgba(249, 203, 64, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.next-question-btn:hover {
    background-color: var(--color-yellow-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(249, 203, 64, 0.35);
}

.next-question-btn:active {
    transform: translateY(0);
}

