/* =================================================================
   EduPlus Admin — Design System
   Tokens: Indigo/slate professional palette with a teal accent.
   Font: Inter (UI) — clean, high-legibility for dense admin screens.
   ================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Palette */
    --color-primary: #4f46e5;      /* indigo */
    --color-primary-dark: #4338ca;
    --color-primary-light: #eef2ff;
    --color-accent: #0d9488;       /* teal */
    --color-ink: #111827;          /* near-black text */
    --color-slate: #475569;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-bg: #f4f6fb;
    --color-surface: #ffffff;
    --color-sidebar: #14162b;
    --color-sidebar-hover: #1f2242;
    --color-sidebar-active: #4f46e5;
    --color-success: #16a34a;
    --color-success-bg: #dcfce7;
    --color-warning: #d97706;
    --color-warning-bg: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-bg: #fee2e2;
    --color-info-bg: #e0f2fe;
    --color-info: #0369a1;

    /* Category accents (stat icons) */
    --bg-indigo: #4f46e5;
    --bg-teal: #0d9488;
    --bg-amber: #d97706;
    --bg-rose: #e11d48;
    --bg-violet: #7c3aed;
    --bg-sky: #0284c7;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
    --shadow-md: 0 4px 14px rgba(17, 24, 39, 0.08);
    --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);

    --sidebar-width: 268px;
    --sidebar-collapsed-width: 76px;
    --topbar-height: 68px;

    --transition: all 0.2s ease;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--color-bg);
    color: var(--color-ink);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* =================================================================
   Buttons
   ================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-light { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.3); }
.btn-light:hover { background: rgba(255,255,255,0.25); }
.btn-block { width: 100%; justify-content: center; }

/* =================================================================
   APP SHELL / SIDEBAR
   ================================================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: #cbd0e6;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.brand-link { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand-mark {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.brand-text { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.brand-text em { font-style: normal; color: #9d9fff; font-weight: 600; }

.sidebar-toggle-btn {
    background: transparent; border: none; color: #9199b8;
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.sidebar-search {
    margin: 14px 16px;
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    flex-shrink: 0;
}
.sidebar-search i { color: #6b7290; font-size: 13px; }
.sidebar-search input {
    background: transparent; border: none; outline: none;
    color: #e5e7ff; font-size: 13px; width: 100%;
}
.sidebar-search input::placeholder { color: #6b7290; }

.sidebar-nav { overflow-y: auto; flex: 1; padding: 4px 12px 24px; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.nav-item { margin-bottom: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #b6bad4;
    font-size: 13.5px; font-weight: 500;
    transition: var(--transition);
    position: relative;
}
.nav-link:hover { background: var(--color-sidebar-hover); color: #fff; }
.nav-link.active { background: var(--color-sidebar-active); color: #fff; }
.nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-label { flex: 1; white-space: nowrap; }
.nav-caret { font-size: 10px; transition: transform 0.2s ease; opacity: 0.6; }

.nav-item.has-submenu.open > .nav-link .nav-caret { transform: rotate(90deg); }
.nav-item.has-submenu.active > .nav-link { background: rgba(79,70,229,0.15); color: #fff; }

.submenu {
    display: none;
    padding: 4px 0 4px 30px;
    position: relative;
}
.submenu li { position: relative; }
.submenu-link {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    color: #9199b8;
    border-radius: 8px;
    transition: var(--transition);
    border-left: 2px solid rgba(255,255,255,0.08);
    margin-left: 4px;
    padding-left: 14px;
}
.submenu-link:hover { color: #fff; border-left-color: var(--color-accent); }
.submenu-link.active { color: #fff; border-left-color: var(--color-accent); background: rgba(13,148,136,0.12); font-weight: 600; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 35;
}

/* Collapsed state (desktop) */
.app-shell.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .sidebar-search,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-caret { display: none; }
.app-shell.sidebar-collapsed .submenu { display: none !important; }
.app-shell.sidebar-collapsed .nav-link { justify-content: center; }
.app-shell.sidebar-collapsed .main-area { margin-left: var(--sidebar-collapsed-width); }
.app-shell.sidebar-collapsed .sidebar-toggle-btn i { transform: rotate(180deg); }

/* =================================================================
   MAIN AREA / TOPBAR
   ================================================================= */
.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    transition: margin-left 0.2s ease;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-burger {
    display: none;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    align-items: center; justify-content: center;
    color: var(--color-slate);
}

.topbar-search {
    flex: 1;
    max-width: 420px;
    display: flex; align-items: center; gap: 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
}
.topbar-search i { color: var(--color-muted); font-size: 13px; }
.topbar-search input { border: none; outline: none; background: transparent; font-size: 13.5px; width: 100%; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.topbar-icon-btn {
    position: relative;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-slate);
    transition: var(--transition);
}
.topbar-icon-btn:hover { background: var(--color-primary-light); color: var(--color-primary); }
.badge-dot {
    position: absolute; top: 8px; right: 9px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-danger);
    border: 2px solid var(--color-surface);
}

.topbar-user {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px 6px 6px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    cursor: pointer;
}
.topbar-user:hover { background: var(--color-bg); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 13px; }
.user-meta small { font-size: 11px; color: var(--color-muted); }
.topbar-user > i.fa-chevron-down { font-size: 10px; color: var(--color-muted); }

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 200px;
    padding: 8px;
    z-index: 50;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 8px; font-size: 13.5px; color: var(--color-slate);
}
.user-dropdown a:hover { background: var(--color-bg); }
.user-dropdown a.text-danger { color: var(--color-danger); }
.dropdown-divider { height: 1px; background: var(--color-border); margin: 6px 0; }

/* =================================================================
   DB notice banner
   ================================================================= */
.db-notice {
    margin: 16px 24px 0;
    background: var(--color-warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.db-notice code { background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 4px; }
.db-notice-sep { opacity: 0.5; }

/* =================================================================
   CONTENT
   ================================================================= */
.content { padding: 24px; flex: 1; }

.content-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.content-header h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--color-muted); }
.breadcrumb i { font-size: 11px; }

.admin-footer {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
    padding: 16px 24px; border-top: 1px solid var(--color-border);
    font-size: 12px; color: var(--color-muted);
}

/* Welcome banner */
.welcome-banner {
    background: linear-gradient(120deg, var(--color-primary), #6d28d9);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px; flex-wrap: wrap;
    margin-bottom: 22px;
    box-shadow: var(--shadow-md);
}
.welcome-banner h2 { margin: 0 0 6px; font-size: 20px; }
.welcome-banner p { margin: 0; opacity: 0.85; font-size: 13.5px; }
.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Stat grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px; flex-shrink: 0;
}
.bg-indigo { background: var(--bg-indigo); }
.bg-teal { background: var(--bg-teal); }
.bg-amber { background: var(--bg-amber); }
.bg-rose { background: var(--bg-rose); }
.bg-violet { background: var(--bg-violet); }
.bg-sky { background: var(--bg-sky); }

.stat-body { display: flex; flex-direction: column; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { font-size: 12.5px; color: var(--color-muted); font-weight: 500; }

/* Card grids */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.grid-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 22px; }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 22px;
}
.grid-2col .card, .grid-3col .card { margin-bottom: 0; }
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}
.card-header h3 {
    margin: 0; font-size: 14.5px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.card-header h3 i { color: var(--color-primary); font-size: 13px; }
.card-body { padding: 18px 20px; }

.activity-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 0; font-size: 13px; color: var(--color-slate);
    border-bottom: 1px dashed var(--color-border);
}
.activity-list li:last-child { border-bottom: none; }
.activity-list time { margin-left: auto; font-size: 11.5px; color: var(--color-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.muted-note { font-size: 12px; color: var(--color-muted); margin: 10px 0 0; }

.status-list { display: flex; flex-direction: column; gap: 10px; }
.status-list li { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
}
.pill-success { background: var(--color-success-bg); color: var(--color-success); }
.pill-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.pill-neutral { background: #f1f5f9; color: var(--color-slate); }
.pill-danger { background: var(--color-danger-bg); color: var(--color-danger); }

.mt-3 { margin-top: 18px; margin-bottom: 10px; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted); }
.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-list li { display: flex; justify-content: space-between; font-size: 12.5px; }
.kv-list li span { color: var(--color-muted); }

.empty-state { font-size: 13px; color: var(--color-muted); }
.empty-state a { color: var(--color-primary); font-weight: 600; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.quick-action {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; color: var(--color-slate);
    transition: var(--transition);
}
.quick-action i { color: var(--color-primary); }
.quick-action:hover { background: var(--color-primary-light); border-color: var(--color-primary); color: var(--color-primary); }

/* Placeholder module page */
.placeholder-card { text-align: center; }
.placeholder-body { padding: 56px 24px; }
.placeholder-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--color-primary-light); color: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; margin: 0 auto 18px;
}
.placeholder-body h2 { margin: 0 0 8px; font-size: 19px; }
.placeholder-body p { margin: 0 auto; max-width: 460px; color: var(--color-slate); font-size: 13.5px; }
.placeholder-meta { display: flex; justify-content: center; gap: 10px; margin: 18px 0 6px; flex-wrap: wrap; }

/* =================================================================
   AUTH / LOGIN
   ================================================================= */
.auth-body {
    background: linear-gradient(135deg, #14162b, #2a1f5c 60%, #0d9488);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .brand-mark {
    width: 54px; height: 54px; margin: 0 auto 14px;
    font-size: 22px;
}
.login-brand h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
.login-brand h1 em { font-style: normal; color: var(--color-primary); }
.login-brand p { margin: 0; font-size: 13px; color: var(--color-muted); }

.alert {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    font-size: 12.5px; margin-bottom: 16px;
}
.alert-danger { background: var(--color-danger-bg); color: #991b1b; }
.alert-info { background: var(--color-info-bg); color: var(--color-info); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--color-slate); }
.input-icon {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    transition: var(--transition);
}
.input-icon:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.input-icon i { color: var(--color-muted); font-size: 13px; }
.input-icon input { border: none; outline: none; width: 100%; font-size: 13.5px; }

.form-row-between { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; font-size: 12.5px; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; color: var(--color-slate); }
.link-muted { color: var(--color-primary); font-weight: 600; }

/* Error page */
.error-page { text-align: center; color: #fff; }
.error-code { font-size: 96px; font-weight: 800; opacity: 0.9; line-height: 1; }
.error-page h1 { font-size: 22px; margin: 8px 0; }
.error-page p { opacity: 0.8; margin-bottom: 20px; }

/* =================================================================
   Responsive
   ================================================================= */
@media (max-width: 1100px) {
    .grid-3col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 992px) {
    .grid-2col, .grid-3col { grid-template-columns: 1fr; }
    .topbar-search { display: none; }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 60;
        width: var(--sidebar-width) !important;
    }
    .app-shell.sidebar-mobile-open .sidebar { transform: translateX(0); }
    .app-shell.sidebar-mobile-open .sidebar-overlay { display: block; }
    .main-area { margin-left: 0 !important; }
    .topbar-burger { display: flex; }
    .app-shell.sidebar-collapsed .brand-text,
    .app-shell.sidebar-collapsed .nav-label { display: block; }
}

@media (max-width: 640px) {
    .content { padding: 16px; }
    .welcome-banner { padding: 20px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .user-meta { display: none; }
    .db-notice { margin: 16px; }
}

@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
}
