/* ============================= */
/* THEME VARIABLES               */
/* ============================= */
:root {
    --bg:          #f0f4ff;
    --card:        #ffffff;
    --text:        #1e293b;
    --muted:       #64748b;
    --primary:     #6366f1;
    --primary-2:   #3b82f6;
    --sidebar-bg:  #1e1b4b;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: linear-gradient(135deg,#6366f1,#3b82f6);
    --topbar-bg:   rgba(255,255,255,0.85);
    --border:      #e5e7eb;
    --shadow:      0 4px 24px rgba(99,102,241,0.08);
}

body.dark {
    --bg:          #0b1120;
    --card:        #1e293b;
    --text:        #e2e8f0;
    --muted:       #94a3b8;
    --sidebar-bg:  #0f0e2a;
    --topbar-bg:   rgba(15,23,42,0.85);
    --border:      rgba(255,255,255,0.08);
    --shadow:      0 4px 24px rgba(0,0,0,0.3);
}

/* ============================= */
/* GLOBAL                        */
/* ============================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}

.wrapper { display: flex; min-height: 100vh; }

/* ============================= */
/* SIDEBAR                       */
/* ============================= */
.sidebar {
    /* width: 260px; */
    width: 245px;
    min-height: 100vh;
    background: var(--sidebar-bg);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    position: relative;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar.collapsed { width: 76px; }

/* LOGO */
.logo-box {
    display: flex;
    align-items: center;
    gap: 12px;
    /* margin-bottom: 36px; */
    margin-bottom: -8px;
    /* padding: 0 8px; */
    padding: 0 30px;
    overflow: hidden;
    white-space: nowrap;
}

/* .logo-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg,#6366f1,#3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
} */

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
    transition: opacity 0.3s, width 0.3s;
    overflow: hidden;
}

/* Sidebar logo */
.logo-img {
    max-width: 100px;
    height: auto;
}

/* Header logo */
.header-logo-img {
    width: 90%;
    height: 90px;
    object-fit: contain;
}

/* Optional: sidebar alignment */
.sidebar-logo {
    border-bottom: 1px solid #eee;
}

.sidebar.collapsed .logo-text {
    opacity: 0;
    width: 0;
}

/* MENU SECTION LABEL */
.menu-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.25);
    text-transform: uppercase;
    padding: 0 12px;
    margin: 20px 0 8px;
    transition: opacity 0.3s;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .menu-label { opacity: 0; }

/* MENU */
.menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar a i {
    font-size: 18px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.sidebar a span {
    transition: opacity 0.3s;
    overflow: hidden;
}

.sidebar.collapsed a span { opacity: 0; width: 0; }
.sidebar.collapsed a { justify-content: center; padding: 12px; }

.sidebar a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar a:hover i { transform: scale(1.15); }

.sidebar a.active {
    background: linear-gradient(135deg,#6366f1,#3b82f6);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99,102,241,0.35);
}

.sidebar a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: #fff;
    border-radius: 0 4px 4px 0;
    opacity: 0.7;
}

/* TOOLTIP when collapsed */
.sidebar.collapsed a::after {
    content: attr(data-title);
    position: absolute;
    left: 76px;
    background: #1e1b4b;
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 999;
}

.sidebar.collapsed a:hover::after { opacity: 1; }

/* SIDEBAR BOTTOM */
.sidebar-bottom {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ============================= */
/* MAIN                          */
/* ============================= */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: all 0.3s ease;
}

/* PAGE CONTENT */
.page-content {
    padding: 24px;
    flex: 1;
}

/* ============================= */
/* TOPBAR                        */
/* ============================= */
.topbar {
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    /* padding: 14px 24px; */
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 200;
}

.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }
.topbar-sub   { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* TOPBAR ACTIONS */
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

.topbar-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

/* NOTIFICATION */
.notif-wrap { position: relative; }

.notif-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 7px; height: 7px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--card);
    animation: pulse 1.5s infinite;
}

/* DIVIDER */
.topbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

/* AVATAR */
.avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg,#6366f1,#3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
}

.avatar:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

/* DROPDOWN */
.topbar .dropdown-menu {
    border-radius: 14px;
    padding: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    background: var(--card);
    min-width: 180px;
    z-index: 9999 !important;
}

.topbar .dropdown-item {
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.15s;
}

.topbar .dropdown-item:hover { background: var(--bg); }
.topbar .dropdown-item.text-danger { color: #ef4444 !important; }
.topbar .dropdown-item.text-danger:hover { background: #fef2f2; }

/* PROFILE INFO */
.profile-info { line-height: 1.2; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text); }
.profile-role { font-size: 11px; color: var(--muted); }

/* ============================= */
/* CARDS                         */
/* ============================= */
.card-premium {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-premium:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(99,102,241,0.12);
}

/* STAT CARDS */
.stat-card {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: 0.2s;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.purple { background: #ede9fe; color: #6366f1; }
.stat-icon.blue   { background: #dbeafe; color: #3b82f6; }
.stat-icon.green  { background: #dcfce7; color: #22c55e; }
.stat-icon.orange { background: #ffedd5; color: #f97316; }

body.dark .stat-icon.purple { background: rgba(99,102,241,0.15); }
body.dark .stat-icon.blue   { background: rgba(59,130,246,0.15); }
body.dark .stat-icon.green  { background: rgba(34,197,94,0.15);  }
body.dark .stat-icon.orange { background: rgba(249,115,22,0.15); }

.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ============================= */
/* TABLE                         */
/* ============================= */
.table {
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
}

.table thead th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
}

.table tbody td {
    font-size: 14px;
    color: var(--text);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: rgba(99,102,241,0.03); }

/* ============================= */
/* FORMS                         */
/* ============================= */
.premium-input {
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 14px;
    background: var(--card);
    color: var(--text);
    transition: 0.2s;
    width: 100%;
}

.premium-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    display: block;
}

/* ============================= */
/* BUTTONS                       */
/* ============================= */
.btn { border-radius: 10px; font-size: 14px; font-weight: 500; transition: 0.2s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg,#6366f1,#3b82f6);
    border: none;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(99,102,241,0.4);
    color: #fff;
}

/* ============================= */
/* BADGES                        */
/* ============================= */
.badge-active   { background: #dcfce7; color: #16a34a; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-inactive { background: #fee2e2; color: #dc2626; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

body.dark .badge-active   { background: rgba(22,163,74,0.15);  color: #4ade80; }
body.dark .badge-inactive { background: rgba(220,38,38,0.15);  color: #f87171; }

/* ============================= */
/* TOASTER                       */
/* ============================= */
#toasterContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 320px;
    max-width: 400px;
}

.toaster-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 14px;
    color: #fff;
    position: relative;
    overflow: hidden;
    animation: toastIn 0.35s ease forwards;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.toaster-item.success { background: linear-gradient(135deg,#10b981,#059669); }
.toaster-item.error   { background: linear-gradient(135deg,#ef4444,#dc2626); }
.toaster-item.warning { background: linear-gradient(135deg,#f59e0b,#d97706); }
.toaster-item.info    { background: linear-gradient(135deg,#3b82f6,#2563eb); }

.toast-icon  { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.toast-body  { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 2px; font-size: 14px; }
.toast-msg   { opacity: 0.92; font-size: 13px; line-height: 1.4; }

.toast-close {
    background: none; border: none;
    color: #fff; opacity: 0.7;
    cursor: pointer; font-size: 16px;
    padding: 0; flex-shrink: 0;
}

.toast-close:hover { opacity: 1; }

.toast-progress {
    position: absolute;
    bottom: 0; left: 0;
    height: 3px; width: 100%;
    background: rgba(255,255,255,0.35);
    border-radius: 0 0 14px 14px;
    animation: toastProgress 3.5s linear forwards;
}

/* ============================= */
/* ANIMATIONS                    */
/* ============================= */
@keyframes fadeIn {
    from { opacity:0; transform: translateY(10px); }
    to   { opacity:1; transform: translateY(0); }
}

@keyframes pulse {
    0%   { transform: scale(1);   opacity: 1; }
    70%  { transform: scale(1.6); opacity: 0; }
    100% { opacity: 0; }
}

@keyframes toastIn {
    from { opacity:0; transform: translateX(50px); }
    to   { opacity:1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity:1; transform: translateX(0); }
    to   { opacity:0; transform: translateX(50px); }
}

@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ============================= */
/* MISC                          */
/* ============================= */
.text-muted { color: var(--muted) !important; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h4 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.4); }


/* STAT CARDS */
.stat-card {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 20px;
    transition: 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.08);
}

.stat-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.purple { background: #ede9fe; color: #6366f1; }
.stat-icon.blue   { background: #dbeafe; color: #3b82f6; }
.stat-icon.green  { background: #dcfce7; color: #22c55e; }
.stat-icon.orange { background: #ffedd5; color: #f97316; }

body.dark .stat-icon.purple { background: rgba(99,102,241,0.15); }
body.dark .stat-icon.blue   { background: rgba(59,130,246,0.15); }
body.dark .stat-icon.green  { background: rgba(34,197,94,0.15);  }
body.dark .stat-icon.orange { background: rgba(249,115,22,0.15); }

.stat-trend {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.stat-trend.up   { background: #dcfce7; color: #16a34a; }
.stat-trend.down { background: #fee2e2; color: #dc2626; }

body.dark .stat-trend.up   { background: rgba(22,163,74,0.15);  color: #4ade80; }
body.dark .stat-trend.down { background: rgba(220,38,38,0.15);  color: #f87171; }

.stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
}

.stat-bar {
    height: 4px;
    background: var(--border);
    border-radius: 10px;
    margin-top: 16px;
    overflow: hidden;
}

.stat-bar-fill { height: 100%; border-radius: 10px; }
.stat-bar-fill.purple { background: linear-gradient(90deg,#6366f1,#818cf8); }
.stat-bar-fill.blue   { background: linear-gradient(90deg,#3b82f6,#60a5fa); }
.stat-bar-fill.green  { background: linear-gradient(90deg,#22c55e,#4ade80); }
.stat-bar-fill.orange { background: linear-gradient(90deg,#f97316,#fb923c); }

/* ACTIVITY FEED */
.activity-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}

.activity-item:last-child { border-bottom: none; }

.act-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

.act-dot.green  { background: #22c55e; }
.act-dot.blue   { background: #3b82f6; }
.act-dot.orange { background: #f97316; }
.act-dot.red    { background: #ef4444; }

.act-text { font-size: 12px; color: var(--muted); flex: 1; line-height: 1.5; }
.act-time { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ROW AVATAR */
.row-av {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: #ede9fe;
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

/* SETTINGS */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size:14px; font-weight:600; color:var(--text); margin-bottom:3px; }
.setting-desc  { font-size:12px; color:var(--muted); }

/* TOGGLE */
.toggle-switch { position:relative; display:inline-block; width:46px; height:26px; flex-shrink:0; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider { position:absolute; cursor:pointer; inset:0; background:#e2e8f0; border-radius:34px; transition:0.3s; }
.toggle-slider::before { content:''; position:absolute; width:20px; height:20px; left:3px; bottom:3px; background:white; border-radius:50%; transition:0.3s; box-shadow:0 2px 4px rgba(0,0,0,0.15); }
.toggle-switch input:checked + .toggle-slider { background:#6366f1; }
.toggle-switch input:checked + .toggle-slider::before { transform:translateX(20px); }

/* THEME SWITCHER */
.theme-switcher { display:flex; gap:6px; }
.theme-opt { padding:7px 14px; border-radius:10px; font-size:13px; font-weight:500; cursor:pointer; transition:0.2s; border:1px solid var(--border); color:var(--muted); display:flex; align-items:center; gap:6px; }
.theme-opt:hover { border-color:#6366f1; color:#6366f1; }
.theme-opt.active { background:#6366f1; color:#fff; border-color:#6366f1; }

/* ── Settings ─────────────────────────────────── */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-wrap: wrap;
}

.setting-row:last-child { border-bottom: none; }

.setting-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}

.setting-desc {
    font-size: 12px;
    color: var(--muted);
}

/* THEME OPTION PILLS */
.theme-opt {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--card);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.theme-opt:hover {
    border-color: #6366f1;
    color: #6366f1;
}

.theme-opt.active {
    background: #6366f1;
    color: #fff !important;
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

/* TOGGLE SWITCH */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #e2e8f0;
    border-radius: 34px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider { background: #6366f1; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

body.dark .toggle-slider { background: #334155; }


/* ── DARK MODE — triggered by both class names ── */
body.dark,
html.dark-early body {
    --bg:         #0b1120;
    --card:       #1e293b;
    --text:       #e2e8f0;
    --muted:      #94a3b8;
    --sidebar-bg: #0f0e2a;
    --topbar-bg:  rgba(15,23,42,0.85);
    --border:     rgba(255,255,255,0.08);
    --shadow:     0 4px 24px rgba(0,0,0,0.3);
}

html.dark-early .topbar {
    background: rgba(15,23,42,0.85);
}

html.dark-early .sidebar {
    background: linear-gradient(180deg,#0f0e2a,#1e293b);
}


.topbar-heading {
    padding-left: 14px;
    border-left: 4px solid #6366f1;
    margin-bottom: 18px;
}

/* Title */
.topbar-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

/* Subtitle */
.topbar-sub {
    font-size: 14px;
    color: #6b7280;
    margin-top: 4px;
}