/* ==================================================
   Mini App Style v2.0.0 — Glassmorphism Aurora
   ترم بهمن ۱۴۰۴
   ================================================== */

:root {
    --bg-1: #0f0c29;
    --bg-2: #302b63;
    --bg-3: #24243e;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-strong: rgba(255, 255, 255, 0.14);
    --text-1: #f8fafc;
    --text-2: #cbd5e1;
    --text-3: #94a3b8;
    --accent: #a78bfa;
    --accent-2: #f472b6;
    --accent-3: #38bdf8;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-glow: 0 8px 32px rgba(167, 139, 250, 0.25);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.25);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Vazirmatn', 'Vazir', 'Tahoma', sans-serif;
}

[data-theme="light"] {
    --bg-1: #e0e7ff;
    --bg-2: #f3e8ff;
    --bg-3: #fce7f3;
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(255, 255, 255, 0.7);
    --glass-strong: rgba(255, 255, 255, 0.75);
    --text-1: #1e1b4b;
    --text-2: #4c1d95;
    --text-3: #6d28d9;
    --accent: #7c3aed;
    --accent-2: #db2777;
    --accent-3: #0284c7;
}

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

html, body {
    font-family: var(--font);
    background: var(--bg-1);
    color: var(--text-1);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ==================================================
   Aurora Background
   ================================================== */
.aurora-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
    background-size: 300% 300%;
    animation: aurora-shift 18s ease infinite;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    pointer-events: none;
}

.blob-1 {
    width: 480px; height: 480px;
    background: radial-gradient(circle, #a78bfa, transparent 70%);
    top: -100px; right: -120px;
    animation: blob-float 22s ease-in-out infinite;
}

.blob-2 {
    width: 420px; height: 420px;
    background: radial-gradient(circle, #f472b6, transparent 70%);
    bottom: 80px; left: -100px;
    animation: blob-float 26s ease-in-out infinite reverse;
}

.blob-3 {
    width: 360px; height: 360px;
    background: radial-gradient(circle, #38bdf8, transparent 70%);
    top: 40%; left: 50%;
    animation: blob-float 30s ease-in-out infinite;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

@keyframes aurora-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes blob-float {
    0%, 100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(60px, -40px) scale(1.1); }
    66% { transform: translate(-40px, 30px) scale(0.95); }
}

/* ==================================================
   Glass Effect
   ================================================== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-card);
}

/* ==================================================
   Header
   ================================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 20px 12px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    color: white;
    animation: pulse-glow 3s ease infinite;
}

.logo-badge svg {
    width: 22px; height: 22px;
}

.title-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.title-main {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-1);
}

.title-sub {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    color: var(--text-1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
}

.icon-btn:hover, .icon-btn:active {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.icon-btn svg {
    width: 18px; height: 18px;
}

.icon-moon { display: block; }
.icon-sun { display: none; }

[data-theme="light"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: block; }

.badge-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: var(--accent-2);
    border-radius: 50%;
    border: 2px solid var(--bg-1);
    display: none;
}

.badge-dot.show { display: block; animation: ping 1.5s ease infinite; }

@keyframes ping {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.7; }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 8px 32px rgba(167,139,250,0.25); }
    50% { box-shadow: 0 8px 32px rgba(167,139,250,0.5); }
}

.header-user {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-2);
}

.header-user .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--glass-strong);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.header-user .chip-avatar {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-3), var(--accent));
}

/* ==================================================
   Body
   ================================================== */
.app-body {
    padding: 20px 16px 100px;
    max-width: 600px;
    margin: 0 auto;
}

.page {
    animation: page-in 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes page-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

[hidden] { display: none !important; }

/* ==================================================
   Cards
   ================================================== */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.card-title {
    font-size: 14px;
    color: var(--text-3);
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.card-value {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.card-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(167,139,250,0.2), rgba(244,114,182,0.2));
    color: var(--accent);
}

.card-icon svg { width: 22px; height: 22px; }

/* ==================================================
   Buttons
   ================================================== */
.btn {
    padding: 14px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    box-shadow: 0 4px 20px rgba(167, 139, 250, 0.4);
}

.btn-primary:hover, .btn-primary:active {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(167, 139, 250, 0.55);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-ghost {
    background: var(--glass-strong);
    color: var(--text-1);
    border: 1px solid var(--glass-border);
}

.btn-ghost:hover {
    background: var(--accent);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
}

/* ==================================================
   Inputs
   ================================================== */
.input-group {
    margin-bottom: 14px;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 6px;
    font-weight: 500;
}

.input, .select, .textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 15px;
    transition: var(--transition);
}

.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.15);
}

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 16px center;
    background-size: 18px;
    padding-left: 44px;
}

/* ==================================================
   Auth Page
   ================================================== */
.welcome-card {
    text-align: center;
    padding: 30px 24px;
}

.welcome-card .emoji {
    font-size: 56px;
    margin-bottom: 14px;
    display: block;
    filter: drop-shadow(0 6px 14px rgba(167,139,250,0.5));
}

.welcome-card h2 {
    font-size: 22px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.welcome-card p {
    color: var(--text-2);
    font-size: 14px;
    margin-bottom: 20px;
}

.deadline-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 30px;
    color: var(--warning);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 24px;
}

/* ==================================================
   Dashboard
   ================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.progress-bar {
    height: 8px;
    background: var(--glass-strong);
    border-radius: 30px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 30px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-1);
    margin: 20px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 4px; height: 18px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    border-radius: 2px;
}

.chart-wrap {
    position: relative;
    height: 220px;
    margin-top: 8px;
}

/* ==================================================
   Course List
   ================================================== */
.search-bar {
    position: sticky;
    top: 80px;
    z-index: 50;
    margin-bottom: 12px;
}

.chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 8px;
    scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.filter-chip {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 20px;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.filter-chip.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    border-color: transparent;
}

.course-list { display: flex; flex-direction: column; gap: 10px; }

.course-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    cursor: pointer;
}

.course-item:hover {
    border-color: var(--accent);
    transform: translateX(-4px);
}

.course-item.selected {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(167,139,250,0.18), rgba(244,114,182,0.12));
}

.course-check {
    width: 26px; height: 26px;
    border-radius: 8px;
    border: 2px solid var(--text-3);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.course-item.selected .course-check {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

.course-item.selected .course-check::after {
    content: '✓';
    color: white;
    font-weight: 800;
    font-size: 16px;
}

.course-info { flex: 1; min-width: 0; }

.course-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-3);
}

.course-meta span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.section-tag {
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--glass-strong);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-3);
}

.selected-counter {
    position: sticky;
    bottom: 80px;
    z-index: 50;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow-glow);
}

.counter-text { font-size: 13px; color: var(--text-2); }
.counter-text strong {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 18px;
    font-weight: 800;
}

/* ==================================================
   Profile
   ================================================== */
.profile-header {
    text-align: center;
    padding: 24px;
}

.avatar-circle {
    width: 88px; height: 88px;
    border-radius: 50%;
    margin: 0 auto 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    font-weight: 800;
    box-shadow: var(--shadow-glow);
    border: 3px solid var(--glass-border);
    overflow: hidden;
}

.avatar-circle img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 4px;
}

.profile-role {
    font-size: 13px;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(167, 139, 250, 0.15);
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 14px;
}

.info-row:last-child { border-bottom: none; }

.info-label { color: var(--text-3); }
.info-value {
    color: var(--text-1);
    font-weight: 600;
    font-feature-settings: "tnum";
}

/* ==================================================
   Bottom Nav
   ================================================== */
.bottom-nav {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 580px;
    padding: 8px;
    border-radius: var(--radius-lg);
    display: flex;
    gap: 4px;
    z-index: 90;
}

.nav-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-3);
    font-family: var(--font);
    font-size: 11px;
    padding: 10px 4px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
}

.nav-btn svg { width: 22px; height: 22px; }

.nav-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    box-shadow: var(--shadow-glow);
}

.nav-btn:not(.active):hover {
    color: var(--accent);
    background: var(--glass-strong);
}

/* ==================================================
   Toast & Notifications
   ================================================== */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 14px 22px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-1);
    font-size: 14px;
    font-weight: 600;
    z-index: 999;
    opacity: 0;
    transition: var(--transition);
    box-shadow: var(--shadow-glow);
}

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

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.warning { border-color: var(--warning); color: var(--warning); }

.notif-panel {
    position: fixed;
    top: 70px;
    left: 12px;
    right: 12px;
    z-index: 200;
    padding: 16px;
    border-radius: var(--radius-lg);
    animation: slide-down 0.3s ease;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes slide-down {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.notif-header h3 {
    font-size: 16px;
    color: var(--text-1);
    font-weight: 700;
}

.notif-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notif-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--glass-strong);
    border-right: 3px solid var(--accent);
}

.notif-item.success { border-color: var(--success); }
.notif-item.warning { border-color: var(--warning); }
.notif-item.info { border-color: var(--accent-3); }

.notif-item h4 {
    font-size: 13px;
    color: var(--text-1);
    margin-bottom: 4px;
}

.notif-item p {
    font-size: 12px;
    color: var(--text-3);
}

.notif-item time {
    font-size: 11px;
    color: var(--text-3);
    display: block;
    margin-top: 4px;
}

/* ==================================================
   Admin
   ================================================== */
.admin-tabs {
    display: flex;
    gap: 6px;
    background: var(--glass-strong);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.admin-tab {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--text-3);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.admin-tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
}

.admin-panel { animation: page-in 0.4s ease; }

.user-row {
    padding: 12px 0;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.user-row:last-child { border-bottom: none; }

.user-info-block { flex: 1; min-width: 0; }

.user-name { color: var(--text-1); font-weight: 600; margin-bottom: 2px; }

.user-meta {
    font-size: 11px;
    color: var(--text-3);
    display: flex;
    gap: 10px;
}

.role-badge {
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.role-badge.admin {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
}

.role-badge.user {
    background: var(--glass-strong);
    color: var(--text-2);
}

/* ==================================================
   Utilities
   ================================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-3);
}

.empty-state .emoji {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.6;
}

.skeleton {
    background: linear-gradient(90deg, var(--glass-strong) 25%, var(--glass-bg) 50%, var(--glass-strong) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--glass-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

.text-muted { color: var(--text-3); }
.text-center { text-align: center; }
.text-gradient {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Responsive */
@media (min-width: 768px) {
    .app-body { padding: 30px 24px 120px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
