/* ==========================================================================
   Quiz Master - Advanced Stylesheet (Glassmorphism + Neon Glow Palette)
   ========================================================================== */

:root {
    /* Color Palette - Dark Mode */
    --bg-primary: #0f172a;
    --bg-secondary: rgba(30, 41, 59, 0.75);
    --bg-card: rgba(51, 65, 85, 0.6);
    --bg-glass: rgba(15, 23, 42, 0.65);
    
    --accent-purple: #7c3aed;
    --accent-purple-light: #8b5cf6;
    --accent-blue: #2563eb;
    --accent-gold: #f59e0b;
    --accent-gold-light: #fbbf24;
    --accent-green: #10b981;
    --accent-red: #ef4444;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(139, 92, 246, 0.4);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --radius-sm: 10px;
    --radius-md: 18px;
    --radius-lg: 28px;
    
    --shadow-glow: 0 0 25px rgba(124, 58, 237, 0.35);
    --shadow-gold: 0 0 20px rgba(245, 158, 11, 0.3);
    --shadow-card: 0 12px 30px -5px rgba(0, 0, 0, 0.35);
    --font-family: 'Tajawal', sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: rgba(255, 255, 255, 0.85);
    --bg-card: #e2e8f0;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

/* Base Reset & Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(124, 58, 237, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(37, 99, 235, 0.15) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    direction: rtl;
    padding-bottom: 80px;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--accent-purple);
    border-radius: 10px;
}

/* Canvas Confetti */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

/* Splash Screen */
#splash-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0f172a, #2e1065);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
}

.logo-icon {
    font-size: 80px;
    filter: drop-shadow(0 0 20px var(--accent-gold));
    animation: bounce 2s infinite cubic-bezier(0.28, 0.84, 0.42, 1);
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--accent-purple-light);
    border-bottom-color: var(--accent-gold);
    border-radius: 50%;
    margin: 24px auto;
    animation: rotation 1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}

/* App Header */
.app-header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s;
}

.user-summary:active {
    transform: scale(0.97);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: var(--shadow-glow);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.3px;
}

.user-level {
    font-size: 12px;
    color: var(--accent-gold);
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-btn, .icon-btn-back {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover, .icon-btn-back:hover {
    background: var(--accent-purple);
    color: white;
    border-color: transparent;
}

.icon-btn:active, .icon-btn-back:active {
    transform: scale(0.9);
}

.pwa-btn {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-light));
    border: none;
    color: #000;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    box-shadow: var(--shadow-gold);
    transition: transform 0.2s ease;
}

.pwa-btn:active {
    transform: scale(0.95);
}

/* Main View Container */
.view-page {
    padding: 18px 16px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Banner Card */
.user-banner-card {
    background: linear-gradient(135deg, var(--accent-purple), #4c1d95);
    border-radius: var(--radius-md);
    padding: 22px;
    color: white;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-glow);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-banner-card h2 {
    font-size: 1.4rem;
    font-weight: 800;
}

.xp-bar-container {
    margin-top: 16px;
}

.xp-text {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    opacity: 0.9;
}

.progress-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-light));
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Section titles */
.section-title {
    margin: 20px 0 14px 0;
}

.section-title h3 {
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Modes Grid */
.modes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.mode-card {
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    padding: 18px 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-card);
}

.mode-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
}

.mode-card:active {
    transform: scale(0.96);
}

.mode-icon {
    font-size: 34px;
}

.mode-card h4 {
    font-size: 15px;
    font-weight: 800;
}

.mode-card p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.category-card {
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    transition: all 0.25s ease;
}

.category-card:hover {
    border-color: var(--accent-purple-light);
    transform: translateY(-3px);
}

.category-card:active {
    transform: scale(0.96);
}

.cat-icon {
    font-size: 38px;
    margin-bottom: 10px;
    display: block;
}

.cat-title {
    font-weight: 800;
    font-size: 15px;
}

/* Quiz Screen & Circular Timer */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.quiz-progress-badge {
    background: var(--bg-card);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 14px;
    border: 1px solid var(--border-color);
}

.quiz-score-live {
    font-weight: 800;
    color: var(--accent-gold);
    font-size: 16px;
}

/* العداد الدائري الرقمي */
.timer-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.9);
    border: 3px solid var(--accent-gold);
    box-shadow: var(--shadow-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--accent-gold-light);
    transition: all 0.3s ease;
}

.timer-circle.warning {
    border-color: var(--accent-red);
    color: var(--accent-red);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    animation: pulse-red 0.6s infinite alternate;
}

@keyframes pulse-red {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

/* شريط وقت التحدي التنازلي */
.timer-bar-container {
    height: 6px;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.timer-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-light));
    width: 100%;
    transition: width 0.2s linear, background-color 0.3s ease;
}

.timer-bar.warning {
    background: var(--accent-red);
}

/* Question Card & Options */
.question-card {
    background: var(--bg-secondary);
    backdrop-filter: blur(16px);
    padding: 26px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.category-pill {
    display: inline-block;
    background: rgba(124, 58, 237, 0.2);
    border: 1px solid rgba(124, 58, 237, 0.4);
    color: #c4b5fd;
    padding: 5px 14px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 16px;
}

#question-text {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.6;
    margin-bottom: 24px;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    text-align: right;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--accent-purple-light);
    background: rgba(139, 92, 246, 0.15);
    transform: translateY(-2px);
}

.option-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: var(--accent-green) !important;
    color: #6ee7b7 !important;
}

.option-btn.wrong {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: var(--accent-red) !important;
    color: #fca5a5 !important;
}

/* Explanation Box */
.explanation-box {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 18px;
    border-right: 4px solid var(--accent-blue);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
    margin-top: 16px;
}

.explanation-status {
    font-weight: 800;
    font-size: 16px;
    margin-bottom: 8px;
}

#explanation-text {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 18px;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-gold {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-light));
    color: #000;
    box-shadow: var(--shadow-gold);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

/* Result Screen */
.result-card {
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    padding: 32px 22px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
}

.result-badge {
    font-size: 75px;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 15px var(--accent-gold));
}

.result-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
}

.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 24px 0;
}

.stat-box {
    background: var(--bg-card);
    padding: 14px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.stat-value {
    display: block;
    font-size: 20px;
    font-weight: 900;
    color: var(--accent-gold);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 4px;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Profile & Stats */
.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.profile-hero-card {
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    padding: 26px;
    border-radius: var(--radius-lg);
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.profile-avatar-large {
    font-size: 65px;
    margin-bottom: 10px;
}

.username-input {
    background: transparent;
    border: none;
    border-bottom: 2px dashed var(--accent-purple);
    color: var(--text-main);
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    padding: 6px;
    width: 80%;
    outline: none;
}

.username-input:focus {
    border-bottom-style: solid;
}

.profile-title {
    display: block;
    color: var(--accent-gold);
    font-size: 14px;
    font-weight: 700;
    margin-top: 8px;
}

.stats-details-list {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item strong {
    font-weight: 800;
}

/* Badges Grid */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.badge-card {
    background: var(--bg-secondary);
    padding: 14px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.4;
    filter: grayscale(100%);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.badge-card.unlocked {
    opacity: 1;
    filter: grayscale(0%);
    border-color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.08);
}

.badge-icon {
    font-size: 32px;
}

.badge-info h5 {
    font-size: 13px;
    font-weight: 800;
}

.badge-info p {
    font-size: 11px;
    color: var(--text-muted);
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.25);
    z-index: 1000;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 45%;
}

.nav-item.active {
    color: var(--accent-purple-light);
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
}

.nav-icon {
    font-size: 22px;
    transition: transform 0.2s ease;
}

.nav-label {
    font-size: 11px;
    font-weight: 800;
}

/* Keyframe Animations */
@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-16px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}