@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&family=Amiri:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
    --bg-dark: #080b11;
    --bg-panel: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);
    
    --primary-grad: linear-gradient(135deg, #0d9488 0%, #10b981 100%);
    --primary-solid: #0d9488;
    --primary-light: rgba(13, 148, 136, 0.15);
    
    --accent-gold: #fbbf24;
    --accent-gold-grad: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    
    --danger-red: #ef4444;
    --danger-grad: linear-gradient(135deg, #dc2626 0%, #f87171 100%);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
    --font-sans: 'Outfit', 'Inter', sans-serif;
    --font-arabic: 'Amiri', serif;
    --sidebar-bg: rgba(10, 15, 26, 0.85);
    --bg-card-sub: rgba(255, 255, 255, 0.02);
    --bg-ayah-box: rgba(17, 24, 39, 0.5);
}

body.light-theme {
    --bg-dark: #f8fafc;
    --bg-panel: rgba(255, 255, 255, 0.75);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-light: rgba(15, 23, 42, 0.15);
    
    --primary-light: rgba(13, 148, 136, 0.08);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --sidebar-bg: rgba(241, 245, 249, 0.85);
    --bg-card-sub: rgba(15, 23, 42, 0.03);
    --bg-ayah-box: rgba(255, 255, 255, 0.6);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-solid);
}

/* Layout Framework */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 2.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Typography & Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-grad);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
}

.brand-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.brand-name {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

/* Sidebar Navigation */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
    border: 1px solid transparent;
}

.nav-item a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active a {
    color: var(--text-primary);
    background: var(--primary-light);
    border-color: rgba(16, 185, 129, 0.2);
}

.nav-item a svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Status Widget in Sidebar */
.user-status-card {
    background: var(--bg-card-sub);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem;
    margin-top: auto;
}

.user-status-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--primary-solid);
    object-fit: cover;
}

.user-streak {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 0.9rem;
}

.streak-icon {
    width: 16px;
    height: 16px;
    fill: var(--accent-gold);
}

/* Dashboard Cards & Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    transition: transform var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.card:hover {
    transform: translateY(-4px);
    border-color: rgba(16, 185, 129, 0.25);
}

.card-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Sections & Tabs */
.app-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.app-section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Button UI */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: var(--primary-grad);
    color: white;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
    background: var(--danger-grad);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-1px);
}

/* Gamified Map (The Path of Light) */
.map-container {
    background: rgba(10, 15, 26, 0.5);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    padding: 3rem;
    position: relative;
    overflow: hidden;
    min-height: 550px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.map-svg-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.map-nodes-layer {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4.5rem;
    z-index: 2;
}

.map-node {
    width: 68px;
    height: 68px;
    background: rgba(17, 24, 39, 0.9);
    border: 2px solid var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 15px rgba(0,0,0,0.4);
}

.map-node:hover {
    transform: scale(1.15);
    border-color: var(--primary-solid);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.4);
}

.map-node.completed {
    background: var(--primary-grad);
    border-color: #10b981;
}

.map-node.active {
    border-color: var(--accent-gold);
    animation: pulseActive 2s infinite;
}

@keyframes pulseActive {
    0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(251, 191, 36, 0); }
    100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

.map-node-label {
    position: absolute;
    bottom: -28px;
    white-space: nowrap;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(8px);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 600;
}

.node-arabic {
    font-family: var(--font-arabic);
    font-size: 1.4rem;
    color: white;
}

/* Audio Reciter Tool */
.reciter-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.reciter-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ayah-box {
    background: var(--bg-ayah-box);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 2.5rem;
    text-align: center;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
}

.ayah-text-arabic {
    font-family: var(--font-arabic);
    font-size: 2.5rem;
    line-height: 4.5rem;
    direction: rtl;
    color: var(--text-primary);
}

.ayah-text-translation {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-style: italic;
}

.recording-controls-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    background: var(--bg-panel);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 2rem;
}

.waveform-canvas {
    width: 100%;
    height: 80px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.rec-btn-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--danger-red);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
    transition: all 0.3s ease;
    border: none;
    color: white;
}

.rec-btn-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(239, 68, 68, 0.5);
}

.rec-btn-circle.recording {
    background: var(--primary-solid);
    animation: recordingPulse 1.5s infinite;
    box-shadow: 0 4px 20px rgba(13, 148, 136, 0.4);
}

@keyframes recordingPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.rec-btn-circle svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.feedback-badge-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.feedback-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: var(--bg-card-sub);
    border: 1px solid var(--border-color);
}

.feedback-score {
    font-weight: 700;
}

.score-perfect { color: #10b981; }
.score-warn { color: #fbbf24; }
.score-error { color: #ef4444; }

/* Writing Canvas Tab */
.canvas-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.canvas-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.canvas-board-wrapper {
    background: #0f172a;
    border-radius: 20px;
    border: 2px solid var(--border-light);
    overflow: hidden;
    position: relative;
    height: 400px;
    box-shadow: inset 0 4px 20px rgba(0,0,0,0.5);
}

.canvas-board {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: block;
}

.canvas-overlay-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-arabic);
    font-size: 7rem;
    opacity: 0.05;
    pointer-events: none;
    user-select: none;
    color: white;
    transition: opacity 0.3s ease;
}

/* Matching Wizard */
.wizard-container {
    max-width: 700px;
    margin: 0 auto;
}

.wizard-step {
    display: none;
}

.wizard-step.active {
    display: block;
    animation: fadeIn 0.4s ease forwards;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin: 2rem 0;
}

.option-card {
    background: var(--bg-card-sub);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-solid);
}

.option-card.selected {
    background: var(--primary-light);
    border-color: var(--primary-solid);
    box-shadow: 0 0 15px rgba(13, 148, 136, 0.2);
}

.teachers-results {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.teacher-card {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 1.5rem;
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
}

.teacher-info h3 {
    margin-bottom: 0.25rem;
}

.teacher-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Digital Detox Panel */
.detox-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
}

.blocked-apps-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.app-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card-sub);
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    border-radius: 14px;
}

.app-info-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-icon-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
}

/* Switch UI */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-image: var(--primary-grad);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Detox Locking Screen Overlay Simulation */
.detox-lock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.95);
    backdrop-filter: blur(25px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.detox-lock-overlay.active {
    display: flex;
}

.lock-modal-box {
    max-width: 580px;
    width: 100%;
    background: rgba(17, 24, 39, 0.8);
    border: 2px solid var(--danger-red);
    border-radius: 28px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.15);
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scaleUp {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.lock-title {
    font-size: 2.2rem;
    font-weight: 800;
    background: var(--danger-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.lock-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2rem;
}

.challenge-box {
    background: rgba(0,0,0,0.25);
    border-radius: 18px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255,255,255,0.04);
}

.lock-timer {
    font-size: 2.5rem;
    font-weight: 700;
    margin-top: 1rem;
    font-family: monospace;
}

/* Footer & Global Components */
.app-footer {
    margin-top: auto;
    padding-top: 3rem;
    padding-bottom: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Modal UI */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.active {
    display: flex;
}

.modal-card {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: scaleUp 0.25s ease-out;
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Mobile bottom navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 72px;
    background: rgba(10, 15, 26, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 1rem;
}

body.light-theme .mobile-bottom-nav {
    background: rgba(241, 245, 249, 0.9);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 0.2s ease;
    padding: 0.5rem;
    flex-grow: 1;
}

.mobile-nav-item svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

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

/* RESPONSIVE MEDIA QUERIES */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    
    .sidebar {
        display: none !important; /* Hide sidebar on mobile */
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 1.5rem;
        padding-bottom: 90px; /* Space for mobile nav */
    }
    
    .mobile-bottom-nav {
        display: flex;
    }
    
    .reciter-layout {
        grid-template-columns: 1fr;
    }
    
    .detox-layout {
        grid-template-columns: 1fr;
    }
    
    .section-title {
        font-size: 1.6rem;
    }
    
    .canvas-board-wrapper {
        height: 320px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .map-container {
        padding: 1.5rem;
        min-height: 480px;
    }
    
    .map-node {
        width: 58px;
        height: 58px;
    }
    
    .map-nodes-layer {
        gap: 3.5rem;
    }
    
    .teacher-card {
        grid-template-columns: 60px 1fr;
        gap: 1rem;
    }
    
    .teacher-card button {
        grid-column: span 2;
        width: 100%;
        margin-top: 0.5rem;
    }
}
