:root {
    /* Use variables from core.css */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-glow: 0 0 15px rgba(14, 165, 233, 0.3);

    --radius-lg: 1.25rem;
    --radius-md: 0.75rem;
    --radius-sm: 0.5rem;
}

[data-theme="light"] {
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-elevated: #f1f5f9;
    --bg-nav: rgba(255, 255, 255, 0.95);

    --text-main: #0f172a;
    --text-secondary: #64748b;
    --text-inverse: #ffffff;

    --border: #e2e8f0;
    --shadow-glow: 0 4px 15px rgba(14, 165, 233, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    padding-bottom: 90px;
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    min-height: 100vh;
}

html[lang="ar"] body {
    font-family: 'Cairo', sans-serif;
}

h1,
h2,
h3 {
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
}

h2 {
    font-size: clamp(1.5rem, 4vw, 1.75rem);
}

h3 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
}

p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem clamp(1rem, 5vw, 1.5rem);
    width: 100%;
}

.flex {
    display: flex;
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.hidden {
    display: none !important;
}

.w-full {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-mute {
    color: var(--text-secondary);
}

.mt-4 {
    margin-top: 1.5rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.p-4 {
    padding: 1.5rem;
}

/* Navigation */
nav.top-nav {
    background: var(--bg-nav);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem clamp(1rem, 3vw, 1.5rem);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-links {
    display: none;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .nav-links {
        display: flex;
    }
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.95rem;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: clamp(0.6rem, 2vw, 0.8rem) clamp(1.2rem, 3vw, 1.8rem);
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    white-space: nowrap;
}

.btn-primary:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: clamp(0.6rem, 2vw, 0.8rem) clamp(1.2rem, 3vw, 1.8rem);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-small {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 20px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

.btn-small.active-filter {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--bg-elevated);
    color: var(--primary);
    border-color: var(--primary);
}

/* User Badge */
.user-xp-badge {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Inputs */
.input-field {
    width: 100%;
    padding: 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    margin-bottom: 1rem;
    transition: 0.2s;
    font-size: 1rem;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Module Grid */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 30vw, 160px), 1fr));
    gap: clamp(1rem, 2vw, 1.25rem);
    margin-top: 2rem;
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: clamp(1rem, 3vw, 1.5rem);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    aspect-ratio: 1 / 1;
    min-height: 140px;
}

.module-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.module-icon {
    background: rgba(14, 165, 233, 0.1);
    color: var(--primary);
    width: clamp(48px, 15vw, 64px);
    height: clamp(48px, 15vw, 64px);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    transition: 0.3s;
}

.module-card:hover .module-icon {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.module-title {
    font-weight: 700;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    margin-top: auto;
    line-height: 1.3;
}

.module-phase {
    font-size: clamp(0.65rem, 2vw, 0.7rem);
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 5px;
    opacity: 0.7;
}

/* Profile */
.profile-header {
    text-align: center;
    padding: 2rem 0;
}

.avatar {
    width: clamp(80px, 20vw, 100px);
    height: clamp(80px, 20vw, 100px);
    background: var(--bg-card);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    border: 3px solid var(--primary);
    box-shadow: var(--shadow-lg);
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 15px;
    text-align: center;
    flex: 1;
    min-width: 120px;
}

.menu-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 2rem;
}

.menu-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1.2rem;
    border-radius: 15px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: 0.2s;
    font-weight: 600;
}

.menu-item:hover {
    transform: translateX(5px);
    border-color: var(--primary);
}

html[dir="rtl"] .menu-item:hover {
    transform: translateX(-5px);
}

.menu-item.text-danger {
    color: var(--danger);
}

/* Plan Cards */
.plan-card {
    background: var(--bg-card);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border-radius: 24px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    position: relative;
    transition: 0.3s;
}

.plan-card.featured {
    border: 2px solid var(--primary);
    background: linear-gradient(180deg, var(--bg-card), rgba(14, 165, 233, 0.05));
}

.plan-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.price {
    font-size: clamp(2rem, 5vw, 2.5rem);
    font-weight: 800;
    color: var(--text-main);
    margin: 10px 0;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    position: absolute;
    top: 20px;
    right: 20px;
}

/* Auth Box */
.auth-box {
    max-width: 420px;
    margin: 4rem auto;
    padding: clamp(2rem, 5vw, 3rem);
    background: var(--bg-card);
    border-radius: 32px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.auth-icon {
    width: 80px;
    height: 80px;
    background: rgba(14, 165, 233, 0.1);
    border-radius: 50%;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

/* Toast */
#toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 12px clamp(16px, 4vw, 24px);
    border-radius: 100px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    max-width: 90vw;
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--bg-nav);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-around;
    padding: 0.8rem clamp(0.5rem, 2vw, 1rem);
    border-top: 1px solid var(--border);
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: clamp(0.65rem, 2vw, 0.7rem);
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    padding: 0.5rem;
}

.nav-item.active {
    color: var(--primary);
    transform: translateY(-2px);
}

/* Hero */
.hero {
    text-align: center;
    padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 3vw, 1rem);
}

.hero h1 {
    max-width: 800px;
    margin: 0 auto 1.5rem;
}

.hero p {
    max-width: 600px;
    margin: 0 auto 2.5rem;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem 1rem;
    }

    nav.top-nav {
        padding: 0.75rem 1rem;
    }

    .nav-controls {
        gap: 0.5rem;
    }

    .hero {
        padding: 2rem 1rem;
    }

    .module-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    #authBtn {
        padding: 0.5rem 1rem !important;
        font-size: 0.85rem !important;
    }

    .flex.gap-4 {
        gap: 0.75rem;
    }

    .auth-box {
        margin: 2rem auto;
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .logo span {
        display: none;
    }

    .user-xp-badge {
        display: none;
    }

    .module-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .nav-controls {
        flex-wrap: nowrap;
        gap: 0.25rem;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Loader */
.loader {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}