@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;900&display=swap');

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

:root {
    --bg: #080818;
    --bg2: #0e0e24;
    --bg3: #12122e;
    --card: #141430;
    --card2: #1a1a40;
    --purple: #7c3aed;
    --purple2: #8b5cf6;
    --purple3: #a78bfa;
    --gold: #f59e0b;
    --gold2: #fbbf24;
    --green: #10b981;
    --red: #ef4444;
    --cyan: #06b6d4;
    --text: #f1f5f9;
    --text2: #94a3b8;
    --text3: #64748b;
    --border: rgba(124,58,237,0.2);
    --border2: rgba(124,58,237,0.1);
    --glow: 0 0 40px rgba(124,58,237,0.3);
    --glow2: 0 0 20px rgba(124,58,237,0.15);
    --radius: 16px;
    --radius2: 12px;
    --bottom-nav-h: 64px;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(124,58,237,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6,182,212,0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

body > * { position: relative; z-index: 1; }
a { text-decoration: none; color: inherit; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 3px; }

/* ===== NAVBAR ===== */
.navbar {
    background: rgba(8,8,24,0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
}
.navbar .logo {
    font-size: 1.3rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo span { color: var(--purple3); }
.nav-links { display: flex; align-items: center; gap: 1.2rem; }
.nav-links a { color: var(--text2); font-weight: 600; font-size: .88rem; transition: color .2s; }
.nav-links a:hover { color: var(--text); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 22px;
    border-radius: var(--radius2);
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    border: none;
    transition: all .25s;
    white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--purple), #5b21b6); color: #fff; box-shadow: 0 4px 20px rgba(124,58,237,0.3); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(124,58,237,0.5); }
.btn-gold { background: linear-gradient(135deg, var(--gold), #d97706); color: #000; font-weight: 900; box-shadow: 0 4px 20px rgba(245,158,11,0.3); }
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(245,158,11,0.5); }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--purple2); color: var(--purple3); background: rgba(124,58,237,0.08); }
.btn-green { background: linear-gradient(135deg, var(--green), #059669); color: #fff; }
.btn-green:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(16,185,129,0.4); }
.btn-red { background: linear-gradient(135deg, var(--red), #dc2626); color: #fff; }
.btn-red:hover { transform: translateY(-1px); }
.btn-cyan { background: linear-gradient(135deg, var(--cyan), #0891b2); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: .82rem; border-radius: 8px; }
.btn-full { width: 100%; }

/* ===== HERO ===== */
.hero { padding: 80px 1.5rem 60px; text-align: center; }
.hero-badge {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(124,58,237,0.15); border: 1px solid rgba(124,58,237,0.3);
    border-radius: 50px; padding: 6px 16px; font-size: .85rem;
    color: var(--purple3); font-weight: 700; margin-bottom: 1.5rem;
}
.hero h1 { font-size: 2.8rem; font-weight: 900; line-height: 1.25; margin-bottom: 1.2rem; }
.hero h1 .highlight {
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero p { color: var(--text2); font-size: 1.05rem; margin-bottom: 2.5rem; max-width: 500px; margin-left: auto; margin-right: auto; }
.hero-btns { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 2.5rem; }
.hero-stats { display: flex; gap: 2rem; justify-content: center; flex-wrap: wrap; }
.hero-stat .val { font-size: 1.8rem; font-weight: 900; color: var(--gold2); }
.hero-stat .lbl { color: var(--text2); font-size: .85rem; }

/* ===== HOW IT WORKS ===== */
.how-section { padding: 4rem 1.5rem; max-width: 1100px; margin: 0 auto; }
.section-header { text-align: center; margin-bottom: 2.5rem; }
.section-header h2 { font-size: 1.9rem; font-weight: 900; margin-bottom: .5rem; }
.section-header p { color: var(--text2); }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.2rem; }
.step-card {
    background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius);
    padding: 1.8rem 1.3rem; text-align: center; transition: transform .3s, border-color .3s;
}
.step-card:hover { transform: translateY(-5px); border-color: var(--border); }
.step-num {
    width: 48px; height: 48px; background: linear-gradient(135deg, var(--purple), #5b21b6);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 900; margin: 0 auto 1rem;
    box-shadow: 0 0 20px rgba(124,58,237,0.4);
}
.step-card h3 { margin-bottom: .4rem; font-size: 1rem; }
.step-card p { color: var(--text2); font-size: .88rem; }

/* ===== CARDS ===== */
.card { background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius); padding: 1.5rem; transition: border-color .2s; }
.card:hover { border-color: var(--border); }

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-wrapper { display: flex; min-height: calc(100vh - 60px); }

/* SIDEBAR — desktop only */
.sidebar {
    width: 230px;
    background: var(--bg2);
    border-left: 1px solid var(--border2);
    padding: 1.5rem 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}
.sidebar-logo {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border2);
    margin-bottom: 1rem;
    font-size: 1.05rem; font-weight: 900;
    display: flex; align-items: center; gap: 8px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 1.5rem; color: var(--text2);
    font-weight: 600; font-size: .9rem;
    transition: all .2s; cursor: pointer;
    border-right: 3px solid transparent; text-decoration: none;
}
.nav-item:hover { color: var(--text); background: rgba(124,58,237,0.08); border-right-color: rgba(124,58,237,0.4); }
.nav-item.active { color: var(--text); background: rgba(124,58,237,0.12); border-right-color: var(--purple2); }
.nav-item .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-bottom { margin-top: auto; padding: 1rem 0; border-top: 1px solid var(--border2); }

.main-content { flex: 1; padding: 1.8rem; overflow-x: hidden; max-width: calc(100vw - 230px); }
.page-title { font-size: 1.5rem; font-weight: 900; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 10px; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius2);
    padding: 1.2rem; transition: all .25s;
}
.stat-card:hover { border-color: var(--border); transform: translateY(-2px); }
.stat-icon { font-size: 1.6rem; margin-bottom: .5rem; }
.stat-label { color: var(--text2); font-size: .82rem; margin-bottom: .3rem; }
.stat-val { font-size: 1.7rem; font-weight: 900; }
.stat-val.gold { color: var(--gold2); }
.stat-val.green { color: var(--green); }
.stat-val.purple { color: var(--purple3); }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 50px; font-size: .78rem; font-weight: 700; }
.badge-green { background: rgba(16,185,129,.12); color: var(--green); border: 1px solid rgba(16,185,129,.2); }
.badge-red { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.2); }
.badge-yellow { background: rgba(245,158,11,.12); color: var(--gold2); border: 1px solid rgba(245,158,11,.2); }
.badge-purple { background: rgba(124,58,237,.12); color: var(--purple3); border: 1px solid rgba(124,58,237,.2); }
.badge-cyan { background: rgba(6,182,212,.12); color: var(--cyan); border: 1px solid rgba(6,182,212,.2); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.3rem; }
.form-label { display: block; margin-bottom: 7px; color: var(--text2); font-size: .88rem; font-weight: 600; }
.form-control {
    width: 100%; background: var(--bg3); border: 1.5px solid var(--border);
    border-radius: var(--radius2); padding: 13px 15px; color: var(--text);
    font-family: 'Cairo', sans-serif; font-size: 1rem; transition: all .2s; direction: rtl;
}
.form-control:focus { outline: none; border-color: var(--purple2); box-shadow: 0 0 0 3px rgba(124,58,237,0.15); }
.form-control::placeholder { color: var(--text3); }

/* ===== AUTH ===== */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 24px;
    padding: 2.5rem; width: 100%; max-width: 430px; box-shadow: var(--glow);
    animation: scaleIn .4s ease;
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-card h2 { font-size: 1.6rem; margin-bottom: .4rem; font-weight: 900; }
.auth-card .subtitle { color: var(--text2); margin-bottom: 2rem; font-size: .9rem; }
.auth-switch { text-align: center; margin-top: 1.3rem; color: var(--text2); font-size: .88rem; }
.auth-switch a { color: var(--purple3); font-weight: 700; }

/* ===== ALERTS ===== */
.alert { padding: 13px 16px; border-radius: var(--radius2); margin-bottom: 1.2rem; font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25); color: var(--red); }
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.25); color: var(--green); }
.alert-info { background: rgba(124,58,237,.1); border: 1px solid rgba(124,58,237,.25); color: var(--purple3); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
thead tr { border-bottom: 2px solid var(--border); }
th { padding: 12px 15px; color: var(--text2); font-size: .82rem; font-weight: 700; text-align: right; }
td { padding: 14px 15px; border-bottom: 1px solid var(--border2); font-size: .88rem; vertical-align: middle; }
tbody tr:hover td { background: rgba(124,58,237,0.04); }
tbody tr:last-child td { border-bottom: none; }

/* ===== SECTION TITLE ===== */
.section-title {
    font-size: 1.05rem; font-weight: 900; margin-bottom: 1.2rem;
    display: flex; align-items: center; gap: 10px; color: var(--text);
}
.section-title::before { content: ''; width: 4px; height: 18px; background: linear-gradient(var(--purple), var(--cyan)); border-radius: 2px; display: inline-block; }

/* ===== RADIO GROUP ===== */
.radio-group { display: flex; flex-direction: column; gap: .7rem; }
.radio-item {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    color: var(--text2); font-size: .92rem; padding: 11px 14px;
    border-radius: 10px; border: 1.5px solid var(--border2); transition: all .2s;
}
.radio-item:hover { border-color: var(--border); color: var(--text); background: rgba(124,58,237,0.06); }
.radio-item input { accent-color: var(--purple); width: 17px; height: 17px; }

/* ===== MISSION ===== */
.mission-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 20px;
    padding: 2.5rem; text-align: center; max-width: 520px; margin: 0 auto; box-shadow: var(--glow2);
}
.mission-reward { font-size: 2.5rem; font-weight: 900; color: var(--gold2); margin: 1rem 0; text-shadow: 0 0 20px rgba(245,158,11,0.4); }
.mission-question { font-size: 1.5rem; font-weight: 900; letter-spacing: 3px; color: var(--text); margin: 1.5rem 0; padding: 1rem; background: var(--bg3); border-radius: var(--radius2); }
.mission-timer { color: var(--text2); font-size: .88rem; margin-top: 1rem; }

/* ===== SUCCESS ===== */
.success-wrap { text-align: center; padding: 3rem 1rem; }
.success-circle {
    width: 90px; height: 90px; background: rgba(16,185,129,0.1); border: 2px solid rgba(16,185,129,0.3);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem; margin: 0 auto 1.5rem; animation: popIn .5s ease;
}
.success-wrap h2 { font-size: 1.6rem; font-weight: 900; margin-bottom: .5rem; }
.success-wrap p { color: var(--text2); margin-bottom: 1.5rem; }

/* ===== WHEEL ===== */
.wheel-wrap { position: relative; width: 340px; height: 340px; }
#wheel-canvas { border-radius: 50%; box-shadow: 0 0 60px rgba(124,58,237,0.5); cursor: pointer; }
.wheel-pointer { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 2rem; filter: drop-shadow(0 0 8px rgba(245,158,11,0.8)); z-index: 10; }

/* ===== ANIMATIONS ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes popIn { 0% { transform: scale(0); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 20px rgba(124,58,237,0.4); } 50% { box-shadow: 0 0 40px rgba(124,58,237,0.7); } }

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: rgba(14,14,36,0.97);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 300;
    padding: 0 4px;
}
.mobile-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text3);
    font-size: .65rem;
    font-weight: 700;
    padding: 8px 4px;
    border-radius: 12px;
    transition: all .2s;
    text-decoration: none;
}
.mobile-bottom-nav a .mob-icon { font-size: 1.4rem; line-height: 1; }
.mobile-bottom-nav a.active,
.mobile-bottom-nav a:hover { color: var(--purple3); background: rgba(124,58,237,0.12); }
.mobile-bottom-nav a.active .mob-icon { filter: drop-shadow(0 0 6px rgba(124,58,237,0.7)); }

/* ============================================================
   MOBILE RESPONSIVE  (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {

    /* Hide desktop sidebar */
    .sidebar { display: none !important; }

    /* Show bottom nav */
    .mobile-bottom-nav { display: flex; }

    /* Add padding so content doesn't hide behind bottom nav */
    .main-content {
        max-width: 100vw;
        padding: 1rem 1rem calc(var(--bottom-nav-h) + 1rem);
    }

    /* Navbar tweaks */
    .navbar { padding: 0 1rem; height: 56px; }
    .navbar .logo { font-size: 1.15rem; }
    .navbar .logo img { height: 32px; width: 32px; }
    /* Hide nav-links text links on mobile, keep buttons */
    .nav-links a:not(.btn) { display: none; }

    /* Hero */
    .hero { padding: 50px 1rem 40px; }
    .hero h1 { font-size: 1.9rem; }
    .hero p { font-size: .95rem; }
    .hero-btns { flex-direction: column; align-items: center; }
    .hero-btns .btn { width: 100%; max-width: 300px; }
    .hero-stats { gap: 1.2rem; }
    .hero-stat .val { font-size: 1.4rem; }

    /* Stats grid — 2 columns on mobile */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: .8rem; }
    .stat-val { font-size: 1.4rem; }
    .stat-icon { font-size: 1.3rem; }
    .stat-card { padding: 1rem; }

    /* Page title */
    .page-title { font-size: 1.2rem; margin-bottom: 1rem; }

    /* Cards full width */
    .card { padding: 1.1rem; border-radius: var(--radius2); }

    /* Auth page */
    .auth-card { padding: 2rem 1.3rem; border-radius: 20px; }
    .auth-card h2 { font-size: 1.4rem; }

    /* Mission card */
    .mission-card { padding: 1.8rem 1.2rem; border-radius: 16px; }
    .mission-reward { font-size: 2rem; }
    .mission-question { font-size: 1.2rem; letter-spacing: 2px; }

    /* Buttons full-width in some contexts */
    .success-wrap .btn { width: 100%; max-width: 280px; }

    /* Quick action cards — 1 column */
    .dashboard-wrapper .main-content > div[style*="grid"] {
        grid-template-columns: 1fr !important;
    }

    /* Admin two-col grid → one col */
    div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Form controls bigger touch targets */
    .form-control { padding: 14px 15px; font-size: 1rem; }
    .btn { padding: 13px 20px; }
    .btn-sm { padding: 9px 14px; font-size: .82rem; }

    /* Steps grid */
    .steps-grid { grid-template-columns: 1fr 1fr; }
}

/* Very small phones */
@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
    .steps-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.6rem; }
}
