@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --grad-main: linear-gradient(135deg, #6366f1 0%, #a855f7 40%, #ec4899 70%, #f97316 100%);
    --grad-blue: linear-gradient(135deg, #3b82f6, #6366f1);
    --grad-purple: linear-gradient(135deg, #8b5cf6, #d946ef);
    --grad-orange: linear-gradient(135deg, #f97316, #f43f5e);
    --grad-soft: linear-gradient(135deg, #eef2ff 0%, #faf5ff 50%, #fff7ed 100%);
    --glass: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.8);
    --shadow-soft: 0 4px 24px rgba(99, 102, 241, 0.08);
    --shadow-hover: 0 20px 50px rgba(139, 92, 246, 0.18);
    --radius: 1rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.5rem;
}

* { box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: var(--grad-soft);
    background-attachment: fixed;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(249, 115, 22, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

main { position: relative; z-index: 1; }

/* ── Typography ── */
.gradient-text {
    background: var(--grad-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e1b4b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Navbar ── */
.nav-premium {
    background: var(--glass) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255,255,255,0.6) !important;
    box-shadow: 0 4px 30px rgba(99, 102, 241, 0.06);
}

.nav-logo {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.nav-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--grad-purple);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

/* ── Cards ── */
.card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--glass-border);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

.card-static:hover {
    transform: none;
    box-shadow: var(--shadow-soft);
}

.card-glow {
    position: relative;
    overflow: hidden;
}

.card-glow::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

/* ── Hero banners ── */
.gradient-hero {
    background: var(--grad-main);
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(99, 102, 241, 0.25);
}

.gradient-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.gradient-hero > * { position: relative; z-index: 1; }

/* ── Buttons ── */
.btn-primary, .btn-orange, .btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-decoration: none;
}

.btn-primary {
    background: var(--grad-blue);
    color: white;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.45);
    color: white;
}

.btn-orange {
    background: var(--grad-orange);
    color: white;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.35);
}

.btn-orange:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(249, 115, 22, 0.4);
    color: white;
}

.btn-ghost {
    background: rgba(255,255,255,0.8);
    color: #6366f1;
    border: 2px solid rgba(99, 102, 241, 0.2);
}

.btn-ghost:hover {
    background: white;
    border-color: #6366f1;
    transform: translateY(-2px);
}

/* ── Premium Forms ── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #4338ca;
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

.form-input,
.form-select,
.form-textarea,
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=hidden]):not([type=file]),
select,
textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    font-family: inherit;
    font-size: 0.9375rem;
    color: #1e1b4b;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(99, 102, 241, 0.12);
    border-radius: 0.875rem;
    transition: all 0.25s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}

.form-input:hover,
input:not([type=checkbox]):not([type=radio]):hover,
select:hover,
textarea:hover {
    border-color: rgba(139, 92, 246, 0.35);
    background: #fff;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15), inset 0 1px 2px rgba(0,0,0,0.04);
}

.form-textarea, textarea { min-height: 120px; resize: vertical; }

input[type=file].form-input,
input[type=file] {
    padding: 0.65rem 1rem;
    cursor: pointer;
}

input[type=file]::file-selector-button {
    padding: 0.4rem 1rem;
    margin-right: 0.75rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--grad-purple);
    color: white;
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
}

input[type=radio], input[type=checkbox] {
    width: 1.125rem !important;
    height: 1.125rem;
    accent-color: #8b5cf6;
    cursor: pointer;
}

.form-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.35rem;
}

/* ── Sidebar ── */
.sidebar-premium {
    background: var(--glass);
    backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255,255,255,0.7) !important;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.875rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.8);
    transform: translateX(4px);
    border-color: rgba(139, 92, 246, 0.15);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(168,85,247,0.12));
    border-left: none;
    border: 1px solid rgba(139, 92, 246, 0.25);
    color: #6d28d9 !important;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.1);
}

.sidebar-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: rgba(255,255,255,0.8);
}

.sidebar-link.active .sidebar-icon {
    background: var(--grad-purple);
    color: white;
}

/* Mobile bottom nav */
.mobile-nav {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 -4px 30px rgba(99, 102, 241, 0.08);
    padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
}

.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: #64748b;
    transition: color 0.2s;
    text-decoration: none;
}

.mobile-nav a.active, .mobile-nav a:hover { color: #7c3aed; }
.mobile-nav .m-icon { font-size: 1.25rem; }

/* ── Progress ── */
.progress-bar-fill {
    background: var(--grad-main);
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 999px;
    height: 100%;
}

.progress-track {
    background: rgba(99, 102, 241, 0.1);
    border-radius: 999px;
    overflow: hidden;
    height: 0.5rem;
}

/* ── Stats pills ── */
.stat-pill {
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    transition: all 0.3s ease;
}

.stat-pill:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(139, 92, 246, 0.12);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--grad-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

/* ── Rank badges ── */
.rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 700;
}

.rank-gold { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; border: 1px solid #fbbf24; }
.rank-silver { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); color: #475569; border: 1px solid #94a3b8; }
.rank-bronze { background: linear-gradient(135deg, #ffedd5, #fed7aa); color: #9a3412; border: 1px solid #fb923c; }
.rank-star { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #5b21b6; border: 1px solid #a78bfa; }

/* ── Profile avatar ── */
.profile-avatar {
    width: 7rem;
    height: 7rem;
    border-radius: 50%;
    background: var(--grad-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
    color: white;
    border: 4px solid white;
    box-shadow: 0 10px 40px rgba(139, 92, 246, 0.35);
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-lg {
    width: 6rem;
    height: 6rem;
    font-size: 2rem;
}

/* ── Leaderboard ── */
.leader-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.875rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.leader-row:hover {
    background: rgba(255,255,255,0.7);
    border-color: rgba(139, 92, 246, 0.15);
}

.leader-row.is-me {
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(236,72,153,0.08));
    border-color: rgba(139, 92, 246, 0.3);
}

.leader-rank {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.leader-rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; }
.leader-rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: white; }
.leader-rank-3 { background: linear-gradient(135deg, #fb923c, #ea580c); color: white; }
.leader-rank-n { background: rgba(99,102,241,0.1); color: #6366f1; }

/* ── Auth pages ── */
.auth-page {
    min-height: calc(100vh - 4rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 28rem;
    padding: 2.5rem;
    animation: fadeUp 0.6s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    pointer-events: none;
}

/* ── Alerts ── */
.alert {
    padding: 0.875rem 1rem;
    border-radius: 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid;
}

.alert-success { background: #ecfdf5; color: #047857; border-color: #6ee7b7; }
.alert-error { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }

table.data-table {
    width: 100%;
    border-collapse: collapse;
}

table.data-table th, table.data-table td {
    padding: 0.875rem 1.125rem;
    text-align: left;
    border-bottom: 1px solid rgba(99, 102, 241, 0.08);
}

table.data-table th {
    background: rgba(99, 102, 241, 0.06);
    font-weight: 700;
    font-size: 0.8125rem;
    color: #4338ca;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table.data-table tr:hover td {
    background: rgba(255,255,255,0.5);
}

.notes-viewer { user-select: none; -webkit-user-select: none; }

/* ── Course cards ── */
.course-card-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 1rem;
    background: var(--grad-main);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

/* ── Responsive ── */
@media (max-width: 1023px) {
    main { padding-bottom: 5rem !important; }
}

@media (max-width: 640px) {
    .gradient-hero { padding: 1.5rem !important; }
    .gradient-hero h1 { font-size: 1.5rem !important; }
    .stat-value { font-size: 1.5rem; }
    .profile-avatar { width: 5.5rem; height: 5.5rem; font-size: 2rem; }
    .auth-card { padding: 1.75rem; }
}
