/* app/assets/style.css */

/* 1. CSS Variables & Theme Setup */
:root {
    /* Existing Dark Mode Defaults (kept as fallback) */
    --bg: #090c14;
    --card-bg: #1e293b;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --border-color: rgba(255,255,255,0.08);
    --nav-bg: rgba(9, 12, 20, 0.95);
    
    /* Core Identity Colors (Dark Mode Versions) */
    --duo-green: #58cc02;
    --duo-green-shadow: #46a302;
    --duo-red: #ff4b4b;
    --duo-red-shadow: #d43636;
    --duo-blue: #1cb0f6;
    --duo-blue-shadow: #1899d6;
    
    /* Functional Mapping */
    --primary: var(--duo-green); 
    --success: var(--duo-green); 
    --error: var(--duo-red);
    --gold: #f59e0b;
    
    --path-track: rgba(255,255,255,0.1);
    --shadow-color: rgba(0,0,0,0.5);
    
    /* Button Shadows */
    --btn-shadow: #46a302; 
}

/* --- 🔥 NEW VISUAL IDENTITY (Light Mode) 🔥 --- */
body.light-mode {
    /* New Backgrounds */
    --bg: #f7f7f7;             
    --card-bg: #ffffff;        
    
    /* New Text Colors */
    --text-main: #3c3c3c;      
    --text-muted: #777777;     
    
    /* New Borders */
    --border-color: #e5e5e5;   
    --nav-bg: rgba(255, 255, 255, 0.95);
    
    /* New Identity Colors (Exact Hex Codes) */
    --duo-green: #58cc02;
    --duo-green-shadow: #46a302;
    --duo-red: #ff4b4b;
    --duo-red-shadow: #d43636;
    --duo-blue: #1cb0f6;
    --duo-blue-shadow: #1899d6;

    /* Functional Mapping Update */
    --success: var(--duo-green);
    --primary: var(--duo-green); /* Primary is now Green (Success) */
    --error: var(--duo-red);
    
    /* Map shadows for the 3D effect */
    --btn-shadow: var(--duo-green-shadow); 
    --path-track: #e5e5e5;
    --shadow-color: rgba(0,0,0,0.1); 
}

/* 2. Global Reset & Mobile Fixes */
* { 
    box-sizing: border-box; 
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden; 
}

body {
    /* Updated Font Family */
    font-family: 'Nunito', sans-serif; 
    background-color: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
    padding-top: 70px; 
    position: relative;
}

/* 3. Top Navigation Bar (Fixed) */
.topbar {
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000; 
    backdrop-filter: blur(16px); 
    background: var(--nav-bg);
    border-bottom: 2px solid var(--border-color); /* Thicker border per new style */
    padding: 12px 20px;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}

.brand-logo { 
    font-weight: 800; /* Bolder */
    color: var(--duo-green); /* Brand color */
    font-size: 1.4rem; 
    letter-spacing: -0.5px;
}

.logout-link { 
    color: var(--text-muted); 
    text-decoration: none; 
    font-size: 0.9rem; 
    font-weight: 700; 
    transition: color 0.2s;
}
.logout-link:hover { color: var(--duo-blue); }

.user-stats { 
    display: flex; 
    gap: 15px; 
    font-weight: bold; 
    font-size: 0.9rem; 
}

.stat-icon { margin-right: 4px; }

/* Theme Toggle Button */
.theme-btn {
    background: none; 
    border: none; 
    cursor: pointer; 
    font-size: 1.2rem;
    margin-right: 15px; 
    padding: 5px; 
    border-radius: 50%;
    transition: background 0.2s;
}
.theme-btn:hover { background: rgba(128,128,128,0.2); }

/* 4. Map Container */
.page { 
    width: 100%; 
    max-width: 600px; 
    margin: 0 auto; 
    padding: 20px 0; 
    position: relative; 
}

.map-container { 
    position: relative; 
    width: 100%; 
    overflow: visible; 
}

/* SVG Path Styles */
.path-svg { 
    width: 100%; 
    height: 100%; 
    position: absolute; 
    top: 0; 
    left: 0; 
    z-index: 0; 
    overflow: visible; 
}

.path-track { 
    fill: none; 
    stroke: var(--path-track); 
    stroke-width: 14; /* Thicker path */
    stroke-linecap: round; 
    stroke-dasharray: 0 0; /* Solid line looks better with new style, or keep dash */
    transition: stroke 0.3s; 
}

.path-progress { 
    fill: none; 
    stroke: var(--duo-green); 
    stroke-width: 14; 
    stroke-linecap: round; 
    filter: none; /* Removed glow for cleaner look */
    transition: stroke-dashoffset 0.1s linear; 
}

/* 5. Nodes (Lessons) */
.node {
    position: absolute; 
    transform: translate(-50%, -50%);
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    z-index: 2; 
    width: 90px; 
    height: 90px;
}

.node-btn {
    width: 70px; 
    height: 70px; 
    border-radius: 50%; 
    border: none; 
    cursor: pointer;
    background: var(--card-bg); 
    color: var(--border-color);
    box-shadow: 0 6px 0 var(--border-color); /* Static shadow */
    font-size: 28px; 
    display: grid; 
    place-items: center;
    transition: all 0.2s; 
    position: relative; 
    z-index: 2; 
    flex-shrink: 0; 
    text-decoration: none;
}

.node-btn::before { 
    content:''; 
    position: absolute; 
    inset: 0; 
    background: var(--card-bg); 
    border-radius: 50%; 
    z-index: -1; 
}

.node-title {
    font-size: 13px; 
    font-weight: 800; 
    color: var(--text-muted);
    margin-top: 12px; 
    position: relative; 
    white-space: nowrap;
    background: var(--nav-bg); 
    padding: 4px 10px; 
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Node States */
.node.done .node-btn { 
    background: var(--duo-green); 
    color: #fff; /* White Check */
    box-shadow: 0 6px 0 var(--duo-green-shadow); 
}
.node.done .node-btn::before { background: var(--duo-green); }
.node.done .node-title { color: var(--duo-green); }

.node.locked .node-btn { 
    background: var(--card-bg);
    color: var(--border-color);
    box-shadow: 0 6px 0 var(--border-color);
    opacity: 1; /* Removed opacity for cleaner locked look */
    filter: grayscale(1); 
    cursor: not-allowed; 
}

.node.current .node-btn {
    background: var(--duo-green); 
    color: #fff;
    box-shadow: 0 6px 0 var(--duo-green-shadow); 
    animation: smoothPulse 2s infinite;
}
.node.current .node-btn::before { background: transparent; }

/* 6. Floating Info Text */
.floating-text {
    position: absolute; 
    top: 50%; 
    transform: translateY(-50%);
    width: 180px; 
    pointer-events: none; 
    opacity: 0; 
    transition: all 0.4s ease; 
    z-index: 10;
    background: var(--card-bg);
    padding: 10px 15px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.floating-text h4 { 
    margin: 0; 
    color: var(--text-main); 
    font-size: 16px; 
    font-weight: 800; 
    text-shadow: none;
}

.floating-text p { 
    margin: 5px 0 0; 
    font-size: 13px; 
    color: var(--text-muted); 
    font-weight: 600; 
    text-shadow: none;
}

.floating-text.left { 
    right: 75px; 
    text-align: right; 
    transform: translateY(-50%) translateX(-10px); 
}

.floating-text.right { 
    left: 75px; 
    text-align: left; 
    transform: translateY(-50%) translateX(10px); 
}

.floating-text.show { 
    opacity: 1; 
    transform: translateY(-50%) translateX(0); 
}

/* 7. End Cards */
.end-message-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 90%; 
    max-width: 340px;
    z-index: 20;
    text-align: center;
    pointer-events: none; 
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.end-message-container.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(-20px);
}

.celebration-card {
    background: var(--card-bg);
    border: 2px solid var(--gold); 
    border-radius: 20px; 
    padding: 30px;
    box-shadow: 0 10px 0 #d97706; /* Gold Shadow */
}

.locked-message {
    background: var(--card-bg);
    border: 2px solid var(--border-color); 
    border-radius: 20px; 
    padding: 25px;
    box-shadow: 0 6px 0 var(--border-color);
}

.celebration-btn {
    margin-top: 15px; 
    background: var(--gold); 
    border: none; 
    padding: 12px 25px;
    border-radius: 12px; 
    font-weight: 800; 
    cursor: pointer; 
    color: #fff;
    box-shadow: 0 4px 0 #d97706;
}

.locked-icon { 
    font-size: 2.5rem; 
    display: block; 
    filter: grayscale(1); 
    opacity: 0.5; 
    margin-bottom: 10px; 
}

/* 8. Animations */
.confetti { 
    position: fixed; 
    width: 10px; 
    height: 10px; 
    top: -10px; 
    z-index: 999; 
    pointer-events: none; 
    animation: fall linear forwards; 
}

@keyframes fall { 
    to { transform: translateY(100vh) rotate(720deg); } 
}

@keyframes smoothPulse { 
    0% { transform: scale(1); }
    50% { transform: scale(1.05); } 
    100% { transform: scale(1); } 
}

/* --- Quiz / Lesson Specific Styles --- */

.lesson-wrapper {
    max-width: 600px; margin: 0 auto; padding: 20px;
    min-height: 80vh; display: flex; flex-direction: column;
}

/* Progress Header */
.quiz-header {
    display: flex; align-items: center; gap: 15px; margin-bottom: 30px;
}
.close-btn {
    font-size: 1.8rem; text-decoration: none; color: var(--border-color); transition: color 0.2s;
    font-weight: 700;
}
.close-btn:hover { color: var(--text-muted); }

.progress-bar-bg {
    flex-grow: 1; height: 16px; background: var(--border-color);
    border-radius: 12px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; background: var(--duo-green); width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); 
    border-radius: 12px;
}

/* Question Area */
.question-box {
    flex-grow: 1; display: flex; flex-direction: column; justify-content: center;
}
.question-text {
    font-size: 1.6rem; font-weight: 800; color: var(--text-main);
    margin-bottom: 30px; line-height: 1.4; text-align: left;
}

/* Options Grid */
.options-grid {
    display: grid; gap: 15px;
    grid-template-columns: 1fr;
}
@media (min-width: 500px) {
    .options-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Re-mapped Option Cards to Match New Design --- */
.option-card {
    background: var(--card-bg); 
    border: 2px solid var(--border-color); /* Grey Border */
    border-radius: 16px; padding: 18px 22px; cursor: pointer;
    text-align: center; font-size: 1.1rem; font-weight: 700; 
    color: var(--text-main);
    transition: all 0.1s; 
    box-shadow: 0 2px 0 var(--border-color); /* Subtle shadow */
}

.option-card:hover {
    background: var(--bg); transform: none;
}
.option-card:active {
    transform: translateY(2px); box-shadow: none; border-color: transparent;
}

/* Selected State (Blue) */
.option-card.selected {
    border-color: var(--duo-blue); 
    background: rgba(28, 176, 246, 0.1); 
    color: var(--duo-blue);
    box-shadow: none;
}
/* Correct State (Green) */
.option-card.correct {
    border-color: var(--duo-green); 
    background: rgba(88, 204, 2, 0.1); 
    color: var(--duo-green);
    box-shadow: none;
}
/* Wrong State (Red) */
.option-card.wrong {
    border-color: var(--duo-red); 
    background: rgba(255, 75, 75, 0.1); 
    color: var(--duo-red);
    box-shadow: none;
}

/* Bottom Action Bar (Old - Kept for fallback, but we will use Feedback Sheet) */
.check-area {
    margin-top: auto; border-top: 2px solid var(--border-color);
    padding-top: 20px; text-align: center;
}
.check-btn {
    background: var(--duo-green); color: #fff; border: none;
    padding: 16px; border-radius: 16px;
    font-size: 1.1rem; font-weight: 800; cursor: pointer;
    box-shadow: 0 4px 0 var(--duo-green-shadow); 
    transition: all 0.1s;
    width: 100%; max-width: 400px; text-transform: uppercase; letter-spacing: 0.5px;
}
.check-btn:active { transform: translateY(4px); box-shadow: none; }
.check-btn:disabled { 
    background: var(--border-color); color: #afafaf; 
    box-shadow: none; cursor: not-allowed; transform: none; 
}

/* Arrange Sentence Specifics */
.sentence-container {
    display: flex; flex-wrap: wrap; gap: 8px; min-height: 60px;
    border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-bottom: 30px;
}
.word-pill {
    background: var(--card-bg); padding: 12px 18px; border-radius: 12px;
    border: 1px solid var(--border-color); cursor: pointer; 
    font-weight: 700; font-size: 1rem; color: var(--text-main);
    box-shadow: 0 3px 0 var(--border-color);
}
.word-pill:active { transform: translateY(3px); box-shadow: none; }

/* Media Styles */
.media-container {
    display: flex; align-items: center; gap: 20px;
    margin-bottom: 25px;
}
.q-image {
    width: 140px; height: 140px; border-radius: 16px;
    border: 2px solid var(--border-color); object-fit: cover;
}
.audio-play-btn {
    background: var(--duo-blue); color: white;
    width: 55px; height: 55px; border-radius: 16px; border: none;
    font-size: 24px; cursor: pointer;
    box-shadow: 0 4px 0 var(--duo-blue-shadow);
    transition: transform 0.1s;
    display: flex; align-items: center; justify-content: center;
}
.audio-play-btn:active { transform: translateY(4px); box-shadow: none; }

/* --- 🔥 NEW: FEEDBACK SHEET STYLES 🔥 --- */
#feedback-sheet {
    position: fixed; /* Fixed to viewport */
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    transform: translateY(110%); /* Start Hidden */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 2000;
    border: 2px solid transparent;
    max-width: 600px; /* Constrain width on Desktop */
    margin: 0 auto; /* Center on Desktop */
}

#feedback-sheet.show {
    transform: translateY(0);
}

/* Success State (Correct Answer) */
#feedback-sheet.success {
    background-color: #d7ffb8; /* Light Green */
    color: var(--duo-green-shadow);
    border-color: transparent;
}

/* Error State (Wrong Answer) */
#feedback-sheet.error {
    background-color: #ffdfe0; /* Light Red */
    color: var(--duo-red);
    border-color: transparent;
}

.feedback-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.feedback-icon-container {
    background: #fff;
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}

.feedback-title {
    font-weight: 800;
    font-size: 1.5rem;
    margin: 0;
}

.feedback-content {
    font-size: 1.1rem;
    font-weight: 600;
    color: inherit;
    margin-bottom: 10px;
}

/* Action Button inside Sheet */
#feedback-btn {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    color: white;
    background-color: var(--duo-green);
    border: none;
    box-shadow: 0 4px 0 var(--duo-green-shadow);
    cursor: pointer;
    transition: transform 0.1s;
}
#feedback-btn:active { transform: translateY(4px); box-shadow: none; }

/* Contextual Button Styles */
#feedback-btn.wrong-mode {
    background-color: var(--duo-red);
    box-shadow: 0 4px 0 var(--duo-red-shadow);
}

.instruction-text {
    color: var(--text-muted); 
    font-size: 0.85rem; 
    font-weight: 800;
    text-transform: uppercase; 
    letter-spacing: 1px; 
    margin-bottom: 20px; /* ✅ تم التعديل: مسافة مريحة للعين */
    margin-top: 5px;
}

/* --- 9. Responsive Header & Settings Modal --- */

/* Utility Classes for Responsive Visibility */
.mobile-only { display: none !important; }
.desktop-only { display: flex !important; }

@media (max-width: 600px) {
    .mobile-only { display: flex !important; }
    .desktop-only { display: none !important; }
    
    /* Adjust Topbar padding for mobile */
    .topbar { padding: 10px 15px; }
    
    /* Resize Stats for mobile to fit better */
    .user-stats { gap: 8px; font-size: 0.85rem; }
}

/* Menu Button Style (Hamburger/Settings Icon) */
.menu-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.menu-btn:hover { color: var(--text-main); }

/* Header Modal (Dropdown Style) */
.header-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 2000;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
    backdrop-filter: blur(2px);
}
.header-modal-overlay.show { opacity: 1; pointer-events: auto; }

.header-modal-content {
    position: absolute;
    top: 60px; /* Below header */
    right: 20px;
    width: 250px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    gap: 15px;
    transform: translateY(-10px);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.header-modal-overlay.show .header-modal-content {
    transform: translateY(0);
}

/* Profile Info inside Modal */
.modal-profile-info {
    display: flex; align-items: center; gap: 10px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 5px;
}
.modal-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--duo-blue); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 1.2rem;
}

/* Modal Buttons */
.modal-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: all 0.2s;
    text-decoration: none; /* For links */
    font-size: 0.95rem;
}
.modal-btn:hover {
    background: var(--bg);
    color: var(--text-main);
    border-color: var(--text-muted);
}
.modal-btn.logout {
    color: var(--duo-red);
    border-color: rgba(255, 75, 75, 0.3);
}
.modal-btn.logout:hover {
    background: rgba(255, 75, 75, 0.1);
    border-color: var(--duo-red);
}

/* --- Header & Topbar Cleanups --- */
.user-stats {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-right: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    font-weight: 800;
    /* تصحيح اسم المتغير */
    color: var(--text-main); 
    text-decoration: none;
    transition: transform 0.2s;
    font-size: 0.95rem;
}

.stat-item:hover { transform: scale(1.1); }
.stat-item.hearts { color: #ff4b4b; }
.stat-item.gems { color: #1cb0f6; }
.stat-item.leaderboard { color: #ffc800; }

.stat-icon {
    font-size: 1.3rem;
    margin-right: 6px;
}

.menu-trigger-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    /* تصحيح اسم المتغير */
    color: var(--text-main);
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}
.menu-trigger-btn:hover { opacity: 0.7; }

/* --- Professional Sidebar (Off-Canvas) --- */
.side-menu-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px); /* زيادة الضبابية قليلاً */
}

.side-menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

.side-menu-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100%;
    
    /* تصحيح الخلفية لتأخذ من متغيرات الثيم */
    background: var(--bg); 
    color: var(--text-main);
    
    z-index: 9999;
    box-shadow: -5px 0 15px rgba(0,0,0,0.2);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color); /* إضافة حد لجمالية أكثر */
}

/* تخصيص الخلفية للوضع الفاتح لضمان التباين */
body.light-mode .side-menu-drawer {
    background: #ffffff;
    box-shadow: -5px 0 15px rgba(0,0,0,0.05);
}

.side-menu-overlay.open .side-menu-drawer {
    right: 0;
}

/* 1. Sidebar Header (Profile) */
.side-menu-header {
    padding: 20px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.profile-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
}

.nav-avatar-circle {
    width: 45px; height: 45px;
    background: var(--duo-blue);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 18px;
    border: 2px solid var(--border-color);
    text-transform: uppercase;
}

.close-menu-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}
.close-menu-btn:hover { color: var(--text-main); }

/* 2. Sidebar Body (Scrollable Links) */
.side-menu-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
}

.side-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main); /* تصحيح اللون */
    text-decoration: none;
    transition: background 0.2s;
    border-left: 4px solid transparent;
}

.side-link:hover {
    background: var(--card-bg); /* استخدام لون الكارد عند التحويم */
    border-left-color: var(--duo-blue);
}

/* تحسين الهوفر في الوضع الفاتح */
body.light-mode .side-link:hover {
    background: #f0f0f0;
}

.side-link-icon {
    width: 30px;
    font-size: 1.2rem;
    text-align: center;
    margin-right: 10px;
}

/* 3. Sidebar Footer (Settings & Logout) */
.side-menu-footer {
    padding: 15px 20px;
    border-top: 2px solid var(--border-color);
    background: inherit; /* ليرث نفس لون الخلفية */
}

.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-main);
    padding: 10px 0;
}
.theme-toggle-row:hover { opacity: 0.8; }