/* ==========================================
   نظام الدروس التفاعلية - تصميم احترافي
   ========================================== */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;
    --secondary: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 4px 12px rgba(0,0,0,.08);
    --shadow-md: 0 8px 24px rgba(0,0,0,.10);
    --shadow-lg: 0 20px 40px rgba(0,0,0,.12);
    --transition: all .3s cubic-bezier(.4,0,.2,1);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Tajawal', 'Tahoma', 'Segoe UI', system-ui, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    direction: rtl;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ==========================================
   Typography
   ========================================== */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; color: var(--gray-900); }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

/* ==========================================
   Layout Containers
   ========================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

.container-narrow {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ==========================================
   Top Navigation (Dashboard)
   ========================================== */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    height: 68px;
    gap: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--gray-900);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(79,70,229,.3);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--gray-100);
    border-radius: 50px;
    font-size: .9rem;
    font-weight: 600;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(79,70,229,.2);
}

.btn:hover {
    background: var(--primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79,70,229,.35);
}

.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-block { width: 100%; }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; }
.btn-sm { padding: 7px 14px; font-size: .85rem; }

.btn-success { background: var(--success); box-shadow: 0 2px 6px rgba(16,185,129,.2); }
.btn-success:hover { background: #059669; box-shadow: 0 6px 16px rgba(16,185,129,.35); }

.btn-danger { background: var(--danger); box-shadow: 0 2px 6px rgba(239,68,68,.2); }
.btn-danger:hover { background: #dc2626; box-shadow: 0 6px 16px rgba(239,68,68,.35); }

.btn-warning { background: var(--warning); color: #fff; box-shadow: 0 2px 6px rgba(245,158,11,.2); }
.btn-warning:hover { background: #d97706; color: #fff; }

.btn-outline {
    background: transparent;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-300);
    box-shadow: none;
}
.btn-outline:hover { background: var(--gray-100); color: var(--gray-900); box-shadow: none; }

.btn-ghost { background: transparent; color: var(--gray-700); box-shadow: none; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); box-shadow: none; }

/* ==========================================
   Landing Page (الواجهة الرئيسية للطلاب)
   ========================================== */
.landing {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.landing::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(255,255,255,.15), transparent 70%);
    border-radius: 50%;
    animation: float 20s ease-in-out infinite;
}

.landing::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255,255,255,.1), transparent 70%);
    border-radius: 50%;
    animation: float 25s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -30px) scale(1.1); }
}

.landing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    position: relative;
    z-index: 10;
}

.landing-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-weight: 800;
    font-size: 1.2rem;
}

.landing-logo .logo-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,.2);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    border: 1px solid rgba(255,255,255,.3);
}

.landing-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    background: rgba(255,255,255,.15);
    backdrop-filter: blur(10px);
    border: 1.5px solid rgba(255,255,255,.35);
    color: #fff;
    border-radius: 50px;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
}

.landing-login-btn:hover {
    background: rgba(255,255,255,.25);
    color: #fff;
    transform: translateY(-2px);
}

/* Hero */
.landing-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    position: relative;
    z-index: 5;
}

.hero-content {
    max-width: 1100px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.hero-text { color: #fff; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255,255,255,.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 50px;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.hero-text h1 {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 20px;
    line-height: 1.2;
    font-weight: 800;
}

.hero-text h1 span {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-text p {
    font-size: 1.15rem;
    color: rgba(255,255,255,.9);
    margin-bottom: 30px;
    line-height: 1.7;
}

.hero-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hero-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.95);
    font-weight: 500;
}

.hero-feature .check {
    width: 24px;
    height: 24px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    flex-shrink: 0;
}

/* Student Login Card */
.login-card {
    background: rgba(255,255,255,.98);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px 36px;
    box-shadow: 0 30px 60px rgba(0,0,0,.25);
    border: 1px solid rgba(255,255,255,.5);
}

.login-card h2 {
    color: var(--gray-900);
    margin-bottom: 8px;
    font-size: 1.5rem;
    text-align: center;
}

.login-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 28px;
    font-size: .95rem;
}

.login-card .form-group { margin-bottom: 18px; }

.login-card label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: .9rem;
}

.login-card input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--gray-50);
}

.login-card input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(79,70,229,.1);
}

.login-card .btn { margin-top: 8px; }

.login-card .hint {
    text-align: center;
    color: var(--gray-500);
    font-size: .85rem;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--gray-200);
}

/* ==========================================
   Forms (General)
   ========================================== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: .9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
    transition: var(--transition);
    color: var(--gray-800);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79,70,229,.1);
}

.form-group textarea { resize: vertical; min-height: 80px; }

/* ==========================================
   Cards
   ========================================== */
.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}

.card-form {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-100);
}

.card-form h2 {
    margin-bottom: 24px;
    color: var(--gray-900);
}

/* ==========================================
   Alerts
   ========================================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: .92rem;
}

.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ==========================================
   Stats Grid
   ========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin: 20px 0 30px;
}

.stat-card {
    background: #fff;
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
}

.stat-card .num {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-card .lbl {
    color: var(--gray-500);
    font-size: .9rem;
    font-weight: 500;
}

/* ==========================================
   Assignment Cards
   ========================================== */
.assignments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.assignment-card {
    background: #fff;
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.assignment-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.assignment-card h3 {
    color: var(--gray-900);
    font-size: 1.1rem;
    margin: 0;
}

.assignment-card .meta {
    color: var(--gray-500);
    font-size: .85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.assignment-card .actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==========================================
   Status Badges
   ========================================== */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 50px;
    font-size: .8rem;
    font-weight: 700;
    width: fit-content;
}

.status-open { background: #d1fae5; color: #065f46; }
.status-closed { background: #fee2e2; color: #991b1b; }
.status-done { background: #dbeafe; color: #1e40af; }
.status-pending { background: #fef3c7; color: #92400e; }

/* ==========================================
   Tables
   ========================================== */
.table-wrap {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

table th {
    background: var(--gray-50);
    color: var(--gray-700);
    font-weight: 700;
    padding: 14px 16px;
    text-align: right;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid var(--gray-200);
}

table td {
    padding: 14px 16px;
    text-align: right;
    border-bottom: 1px solid var(--gray-100);
    font-size: .92rem;
    color: var(--gray-700);
}

table tr:hover td { background: var(--gray-50); }
table tr:last-child td { border-bottom: none; }

/* ==========================================
   Auth Pages (Login for teacher/admin)
   ========================================== */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(79,70,229,.3), transparent 70%);
    border-radius: 50%;
}

.auth-page::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(6,182,212,.25), transparent 70%);
    border-radius: 50%;
}

.auth-card {
    background: #fff;
    border-radius: 24px;
    padding: 44px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 30px 60px rgba(0,0,0,.4);
    position: relative;
    z-index: 5;
}

.auth-card .auth-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin: 0 auto 20px;
    box-shadow: 0 10px 30px rgba(79,70,229,.4);
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.auth-card .auth-sub {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 28px;
    font-size: .92rem;
}

.auth-card .back-link {
    display: block;
    text-align: center;
    margin-top: 22px;
    color: var(--gray-500);
    font-size: .9rem;
}

.auth-card .back-link:hover { color: var(--primary); }

/* ==========================================
   Badges (Gamification)
   ========================================== */
.badge-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 18px;
    margin: 6px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-radius: var(--radius);
    color: #fff;
    min-width: 90px;
    box-shadow: 0 4px 12px rgba(245,158,11,.3);
}

.badge-item .b-icon { font-size: 2rem; margin-bottom: 4px; }
.badge-item small { font-weight: 700; font-size: .75rem; text-align: center; }

/* ==========================================
   Upload Area
   ========================================== */
.upload-area {
    border: 2.5px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    background: var(--gray-50);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 20px;
}

.upload-area:hover, .upload-area.drag {
    background: #eef2ff;
    border-color: var(--primary);
}

.upload-area .icon { font-size: 3rem; margin-bottom: 10px; }
.upload-area input[type=file] { display: none; }
.upload-area p { color: var(--gray-600); margin: 4px 0; }
.upload-area .hint { color: var(--gray-400); font-size: .85rem; }

/* ==========================================
   Modal
   ========================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

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

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 { margin-bottom: 20px; }

/* ==========================================
   Progress Bar
   ========================================== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 50px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width .5s ease;
}

/* ==========================================
   Utilities
   ========================================== */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 900px) {
    .hero-content {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }
    .hero-text h1 { font-size: 2.2rem; }
    .hero-features { align-items: flex-start; }
    .login-card { padding: 30px 24px; }
}

@media (max-width: 600px) {
    .container { padding: 16px 12px; }
    .hero-text h1 { font-size: 1.7rem; }
    .hero-text p { font-size: 1rem; }
    .login-card { padding: 24px 20px; border-radius: 18px; }
    .card-form { padding: 22px 18px; border-radius: 16px; }
    .auth-card { padding: 30px 22px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-card .num { font-size: 1.6rem; }
    .landing-header { padding: 16px 20px; }
    .assignments-grid { grid-template-columns: 1fr; }
    .topbar-inner { height: 60px; padding: 0 12px; }
    .brand { font-size: 1rem; }
    .user-chip { padding: 6px 10px; font-size: .8rem; }
}

/* Loader */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: inline-block;
}

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