/* ============================
   AppFormation — UI v2
   ============================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --orange: #f97316;
    --orange-dark: #ea580c;
    --sidebar-w: 230px;
    --topbar-h: 68px;
    --text: #1e1b4b;
    --muted: #94a3b8;
    --border: #f1f5f9;
    --bg: #f4f6fb;
    --r: 20px;
    --ease: cubic-bezier(.4, 0, .2, 1);
    --t: all .28s var(--ease);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ────────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: #fff;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    padding: 28px 18px;
    border-right: 1px solid var(--border);
    z-index: 200;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 40px;
    padding: 0 6px;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--orange));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(99, 102, 241, .35);
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: 13px;
    text-decoration: none;
    color: var(--muted);
    font-size: .88rem;
    font-weight: 500;
    transition: var(--t);
    border: none;
    background: transparent;
    width: 100%;
    cursor: pointer;
    text-align: left;
}

.sidebar-link i {
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: rgba(99, 102, 241, .07);
    color: var(--primary);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, .15), rgba(99, 102, 241, .06));
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.logout-btn {
    color: #ef4444 !important;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, .09) !important;
    color: #ef4444 !important;
}

/* ── MAIN WRAP ──────────────── */

.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── TOPBAR ─────────────────── */

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1.5px solid #e8edf3;
    border-radius: 13px;
    padding: 9px 16px;
    width: 320px;
    transition: var(--t);
}

.topbar-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}

.topbar-search i {
    color: var(--muted);
    font-size: .95rem;
}

.topbar-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: .88rem;
    width: 100%;
    color: var(--text);
    font-family: inherit;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: #f8fafc;
    color: var(--muted);
    font-size: 1.05rem;
    cursor: pointer;
    transition: var(--t);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-icon-btn:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.notif-dot {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 7px;
    height: 7px;
    background: #ef4444;
    border-radius: 50%;
    border: 1.5px solid #fff;
    animation: pulse-notif 2s infinite;
}

@keyframes pulse-notif {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, .5);
    }

    50% {
        transform: scale(1.2);
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
    }
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 14px;
    background: #f8fafc;
    cursor: pointer;
    transition: var(--t);
}

.topbar-user:hover {
    background: #f1f5f9;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--orange));
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-size: .83rem;
    font-weight: 600;
    color: var(--text);
}

.user-role {
    font-size: .7rem;
    color: var(--muted);
}

.btn-pill {
    padding: 8px 18px;
    border-radius: 50px;
    font-size: .84rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--muted);
    transition: var(--t);
}

.btn-pill-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(99, 102, 241, .3);
}

.btn-pill-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, .45);
    color: #fff;
}

/* ── PAGE CONTENT ───────────── */

.alerts-wrap {
    padding: 16px 32px 0;
}

.alert-flash {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    border-radius: 13px;
    font-size: .87rem;
    font-weight: 500;
    margin-bottom: 10px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    animation: slide-down .35s var(--ease);
}

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

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

.page-content {
    padding: 28px 32px;
    flex: 1;
}

/* ── HERO BANNER ────────────── */

.hero-banner {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 45%, #f97316 100%);
    border-radius: var(--r);
    padding: 44px 48px;
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-bottom: 32px;
}

.hero-banner::before,
.hero-banner::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
}

.hero-banner::before {
    width: 260px;
    height: 260px;
    top: -80px;
    right: -60px;
}

.hero-banner::after {
    width: 180px;
    height: 180px;
    bottom: -60px;
    right: 120px;
}

.hero-eyebrow {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: .75;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.hero-banner h1 {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.22;
    max-width: 420px;
    margin-bottom: 14px;
    position: relative;
    z-index: 1;
}

.hero-banner p {
    font-size: .92rem;
    opacity: .82;
    max-width: 380px;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

.btn-hero {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 26px;
    border-radius: 50px;
    background: rgba(255, 255, 255, .95);
    color: var(--primary);
    font-weight: 700;
    font-size: .9rem;
    text-decoration: none;
    transition: var(--t);
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 22px rgba(0, 0, 0, .16);
}

.btn-hero:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .22);
    color: var(--primary);
}

/* ── SECTION HEADER ─────────── */

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

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.section-link {
    font-size: .83rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    transition: var(--t);
}

.section-link:hover {
    opacity: .7;
}

/* ── COURSE CARDS ───────────── */

.course-card {
    display: block;
    border-radius: var(--r);
    padding: 26px;
    color: #fff;
    text-decoration: none;
    height: 100%;
    position: relative;
    overflow: hidden;
    transition: var(--t);
    border: none;
}

.course-card::before {
    content: '';
    position: absolute;
    top: -36px;
    right: -36px;
    width: 130px;
    height: 130px;
    background: rgba(255, 255, 255, .1);
    border-radius: 50%;
    transition: var(--t);
}

.course-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -20px;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, .06);
    border-radius: 50%;
}

.course-card:hover {
    transform: translateY(-7px);
    color: #fff;
}

.course-card:hover::before {
    transform: scale(1.6);
}

.card-blue {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: 0 8px 28px rgba(59, 130, 246, .32);
}

.card-orange {
    background: linear-gradient(135deg, #f97316, #c2410c);
    box-shadow: 0 8px 28px rgba(249, 115, 22, .32);
}

.card-dark {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    box-shadow: 0 8px 28px rgba(30, 27, 75, .35);
}

.card-purple {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    box-shadow: 0 8px 28px rgba(139, 92, 246, .32);
}

.card-blue:hover {
    box-shadow: 0 20px 48px rgba(59, 130, 246, .44);
}

.card-orange:hover {
    box-shadow: 0 20px 48px rgba(249, 115, 22, .44);
}

.card-dark:hover {
    box-shadow: 0 20px 48px rgba(30, 27, 75, .46);
}

.card-purple:hover {
    box-shadow: 0 20px 48px rgba(139, 92, 246, .44);
}

.card-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 50px;
    background: rgba(255, 255, 255, .2);
    font-size: .69rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 14px;
    backdrop-filter: blur(4px);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 18px;
}

.card-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    opacity: .8;
    margin-bottom: 7px;
}

.card-progress-bar {
    background: rgba(255, 255, 255, .2);
    border-radius: 50px;
    height: 5px;
    overflow: hidden;
    margin-bottom: 18px;
}

.card-progress-fill {
    height: 100%;
    background: rgba(255, 255, 255, .88);
    border-radius: 50px;
    animation: grow-bar 1.1s var(--ease) both;
}

@keyframes grow-bar {
    from {
        width: 0 !important;
    }
}

.card-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.card-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    background: rgba(255, 255, 255, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .62rem;
    font-weight: 700;
    margin-left: -7px;
    transition: var(--t);
}

.card-avatar:first-child {
    margin-left: 0;
}

.card-avatar-more {
    background: rgba(255, 255, 255, .18);
}

.btn-continue {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    border-radius: 50px;
    background: rgba(255, 255, 255, .92);
    color: #1e1b4b !important;
    font-weight: 700;
    font-size: .78rem;
    text-decoration: none;
    transition: var(--t);
    border: none;
    cursor: pointer;
}

.btn-continue:hover {
    background: #fff;
    transform: scale(1.04);
}

/* ── CONTENT GRID CARDS ─────── */

.content-card {
    border-radius: var(--r);
    background: #fff;
    overflow: hidden;
    border: 1px solid #eef2f7;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: var(--t);
}

.content-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .1);
    border-color: transparent;
}

.content-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.content-thumb-media {
    width: 100%;
    aspect-ratio: 16/9;
    position: relative;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.content-thumb-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: rgba(255, 255, 255, .85);
    background: rgba(0, 0, 0, .25);
    pointer-events: none;
}

.content-thumb-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: var(--primary);
    position: relative;
    overflow: hidden;
}

.thumb-video {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: #4338ca;
}

.thumb-audio {
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    color: #be185d;
}

.thumb-article {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
}

.thumb-document {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}

.thumb-default {
    background: linear-gradient(135deg, #f0f9ff, #bae6fd);
    color: #0284c7;
}

.content-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 7px;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    width: fit-content;
}

.badge-video {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-audio {
    background: #fce7f3;
    color: #be185d;
}

.badge-article {
    background: #d1fae5;
    color: #065f46;
}

.badge-document {
    background: #fef3c7;
    color: #92400e;
}

.content-card-title {
    font-size: .97rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
}

.content-card-summary {
    font-size: .81rem;
    color: var(--muted);
    line-height: 1.55;
    flex: 1;
}

.btn-open {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 600;
    font-size: .82rem;
    text-decoration: none;
    transition: var(--t);
    align-self: flex-start;
    box-shadow: 0 4px 14px rgba(99, 102, 241, .28);
    margin-top: 6px;
}

.btn-open:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(99, 102, 241, .4);
    color: #fff;
}

/* ── FILTER TABS ────────────── */

.filter-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 26px;
}

.filter-tab {
    padding: 8px 18px;
    border-radius: 50px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--t);
    text-decoration: none;
}

.filter-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ── STAT CARDS ─────────────── */

.stat-card {
    border-radius: 17px;
    background: #fff;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid #eef2f7;
    transition: var(--t);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .08);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.si-blue {
    background: #eff6ff;
    color: #3b82f6;
}

.si-orange {
    background: #fff7ed;
    color: #f97316;
}

.si-purple {
    background: #f5f3ff;
    color: #8b5cf6;
}

.si-green {
    background: #f0fdf4;
    color: #22c55e;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: .76rem;
    color: var(--muted);
    font-weight: 500;
    margin-top: 2px;
}

/* ── WATCH LATER ────────────── */

.watch-card {
    border-radius: var(--r);
    background: #fff;
    overflow: hidden;
    border: 1px solid #eef2f7;
}

.watch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid #f8fafc;
    transition: var(--t);
    text-decoration: none;
    color: inherit;
}

.watch-item:last-child {
    border-bottom: none;
}

.watch-item:hover {
    background: #f8fafc;
}

.watch-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
    margin-right: 14px;
}

.watch-item-title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}

.watch-item-meta {
    font-size: .76rem;
    color: var(--muted);
    margin-top: 2px;
}

/* ── RECO CARD ──────────────── */

.reco-card {
    border-radius: var(--r);
    background: linear-gradient(145deg, #d9f99d, #bef264);
    padding: 30px 26px;
    position: relative;
    overflow: hidden;
    transition: var(--t);
    border: none;
}

.reco-card::before {
    content: '';
    position: absolute;
    top: -28px;
    right: -28px;
    width: 130px;
    height: 130px;
    background: rgba(255, 255, 255, .3);
    border-radius: 50%;
}

.reco-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 42px rgba(132, 204, 22, .25);
}

.reco-eyebrow {
    font-size: .71rem;
    font-weight: 700;
    color: #4d7c0f;
    margin-bottom: 8px;
    letter-spacing: .5px;
}

.reco-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1a2e05;
    line-height: 1.3;
    margin-bottom: 22px;
    position: relative;
    z-index: 1;
}

.btn-reco {
    display: block;
    text-align: center;
    padding: 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--orange), var(--orange-dark));
    color: #fff !important;
    font-weight: 700;
    font-size: .88rem;
    text-decoration: none;
    transition: var(--t);
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 16px rgba(249, 115, 22, .38);
}

.btn-reco:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(249, 115, 22, .5);
}

/* ── CARD ENTRANCE ANIMATION ── */

.card-animate {
    opacity: 0;
    animation: card-enter .5s var(--ease) forwards;
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(22px);
    }

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

.card-animate:nth-child(1) {
    animation-delay: .05s;
}

.card-animate:nth-child(2) {
    animation-delay: .10s;
}

.card-animate:nth-child(3) {
    animation-delay: .15s;
}

.card-animate:nth-child(4) {
    animation-delay: .20s;
}

.card-animate:nth-child(5) {
    animation-delay: .25s;
}

.card-animate:nth-child(6) {
    animation-delay: .30s;
}

.card-animate:nth-child(7) {
    animation-delay: .35s;
}

.card-animate:nth-child(8) {
    animation-delay: .40s;
}

/* ── EMPTY STATE ────────────── */

.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: .35;
    display: block;
}

.empty-state p {
    font-size: .93rem;
}

/* ── PROTECTION POPUP ───────── */

.content-protection-popup {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 28px;
    z-index: 9999;
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    color: #fff;
    padding: 14px 22px;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    font-size: .86rem;
    font-weight: 500;
}

/* ── WATERMARK ──────────────── */

.watermark-overlay {
    position: absolute;
    right: 12px;
    bottom: 12px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .72rem;
}

/* ── RESPONSIVE ─────────────── */

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-wrap {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-search {
        width: 180px;
    }

    .page-content {
        padding: 20px 16px;
    }

    .hero-banner {
        padding: 28px 24px;
    }

    .hero-banner h1 {
        font-size: 1.45rem;
    }
}