/* ============================================================
   SaaS Admin UI – Premium Edition (Core UI Only)
   CLEAN VERSION (NO SIDEBAR CODE)
============================================================ */

/* ---------------------------
   THEME TOKENS (LIGHT MODE)
---------------------------- */
:root {
    --bg-body: #f5f5f9;
    --bg-surface: #ffffff;
    --bg-soft: #f3f4f6;
    --bg-soft-strong: #e5e7eb;

    --text-main: #111827;
    --text-muted: #6b7280;
    --text-soft: #9ca3af;

    --border-subtle: #e5e7eb;

    --accent: #8b5cf6;
    --accent-strong: #7c3aed;
    --accent-soft: rgba(139, 92, 246, 0.14);
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #ec4899);

    --radius: 12px;
    --radius-lg: 16px;

    --shadow-soft: 0 10px 30px rgba(15,23,42,0.06);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 34px rgba(0,0,0,0.14);
}

/* ---------------------------
   DARK MODE
---------------------------- */
body.dark-mode {
    --bg-body: #020617;
    --bg-surface: #0f172a;
    --bg-soft: #1e293b;
    --text-main: #f4f4f5;
    --text-muted: #cbd5e1;
    --border-subtle: #334155;
    --accent-soft: rgba(168, 85, 247, 0.25);
    --shadow-soft: 0 14px 40px rgba(0,0,0,0.55);
}

/* ---------------------------
   GLOBAL RESET
---------------------------- */
body {
    margin: 0;
    font-family: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial;
    background: var(--bg-body);
    color: var(--text-main);
    transition: background .25s, color .25s;
}

.layout-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.layout-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    min-height: 100vh;
}

.layout-content {
    flex: 1;
    padding: 32px 40px;
}

@media (max-width:900px){
    .layout-content { padding: 20px; }
}

/* ============================================================
   TOPBAR
============================================================ */
.topbar {
    height: 64px;
    background: var(--bg-surface);
    padding: 12px 26px;
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(8px);
}

.topbar-left {
    display: flex;
    flex-direction: column;
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   CARDS
============================================================ */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-subtle);
    transition: transform .15s, box-shadow .15s;
}

.card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* ============================================================
   TABLES
============================================================ */
.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.table th {
    background: #fafbff;
    padding: 10px 12px;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.table tr:hover td {
    background: #f6f6fb;
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
    padding: 8px 18px;
    border-radius: 999px;
    font-size: .85rem;
    cursor: pointer;
    background: var(--bg-soft);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: box-shadow .15s, transform .15s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(0,0,0,.12);
}

.btn.primary {
    background: var(--accent-gradient);
    color: white;
}

.btn.ghost {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
}

/* ============================================================
   FORMS (Modern SaaS)
============================================================ */
.form-page-wrapper { max-width: 900px; margin: 0 auto; }

.form-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 26px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(280px,1fr));
    gap: 24px 32px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }

.form-field label {
    font-size: .88rem;
    font-weight: 600;
}

.form-field input,
.form-field select,
.form-field textarea {
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: white;
    font-size: .9rem;
    transition: border .2s, box-shadow .2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-actions {
    margin-top: 24px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================================
   DASHBOARD
============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(230px,1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    transition: .2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(0,0,0,0.18);
}

.stat-label {
    color: var(--text-muted);
    font-size: .8rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

/* ============================================================
   NOTIFICATIONS (Toast + Panel)
============================================================ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    min-width: 240px;
    max-width: 360px;
    padding: 14px 18px;
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    animation: toast-in 0.35s ease forwards;
    cursor: pointer;
    opacity: 0;
}

.toast-success { background: linear-gradient(135deg,#22c55e,#16a34a); }
.toast-error   { background: linear-gradient(135deg,#dc2626,#b91c1c); }
.toast-warning { background: linear-gradient(135deg,#f59e0b,#d97706); }
.toast-info    { background: linear-gradient(135deg,#3b82f6,#2563eb); }

/* ============================================================
   MODALS
============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(4px);
    z-index: 200;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(900px, 92%);
    background: var(--bg-surface);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    z-index: 201;
}

.close-btn {
    font-size: 24px;
    border: none;
    background: none;
    cursor: pointer;
}

/* ================================
   COLLAPSIBLE SIDEBAR SUPPORT
================================ */

/* Collapsed state */
.sidebar.collapsed {
    width: 70px;
}

.layout-main.collapsed {
    margin-left: 70px;
}

/* Hide text when collapsed */
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-footer span:first-child {
    display: none;
}

/* Chevron hidden when collapsed */
.sidebar.collapsed .nav-chevron {
    display: none;
}

/* Toggle Button */
.sidebar-toggle {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: #fff;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 18px;
    opacity: 0.8;
}

.sidebar-toggle:hover {
    opacity: 1;
}

/* Center icons more in collapsed mode */
.sidebar.collapsed .nav-icon {
    margin-right: 0;
}

/* MAIN CONTENT ALIGNMENT FIX v18 */
.layout-main {
    margin-left: 72px;
    transition: margin-left .25s ease;
}

.sidebar:hover ~ .layout-main {
    margin-left: 240px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    padding: 8px 16px;
    color: white;
    border-radius: 8px;
}

.data-table {
    width: 100%;
    background: white;
    border-radius: 10px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.avatar-sm {
    height: 40px;
    width: 40px;
    border-radius: 50%;
}

.avatar-placeholder {
    height: 40px;
    width: 40px;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.role-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    color: white;
}

.role-admin { background: #ef4444; }
.role-staff { background: #3b82f6; }
.role-instructor { background: #22c55e; }

/* Active + open helpers */
.nav-item.active {
    background: #f97316;
    color: #fff;
}

/* Main content margin fix for new sidebar */
.main-content {
    margin-left: 230px; /* match sidebar width */
    padding: 24px;
    width: calc(100% - 230px);
    min-height: 100vh;
    background: #f6f7fb;
}

/* mobile fix */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
        width: 100%;
    }
}


/* PAGE HEADER */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 5px 25px 5px;
    margin-bottom: 10px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    color: #1e1e2d;
}

.page-subtitle {
    margin-top: 3px;
    font-size: 14px;
    color: #666;
}

.role-pill {
    padding: 6px 14px;
    background: #f0f0f7;
    border-radius: 25px;
    font-size: 13px;
    color: #555;
    margin-right: 15px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
}
