/*
 * Style Sheet — Smart Library System
 * Tech UI / SaaS Design Language
 * Dark sidebar · Indigo accent · Glassmorphism · Glow effects
 */

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

/* ─────────────────────────────────────────────
   CSS CUSTOM PROPERTIES — DESIGN TOKENS
───────────────────────────────────────────── */
:root {
    /* Brand Colors */
    --indigo-50:  #eef2ff;
    --indigo-100: #e0e7ff;
    --indigo-400: #818cf8;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;
    --violet-500: #8b5cf6;
    --violet-600: #7c3aed;
    --cyan-400:   #22d3ee;
    --cyan-500:   #06b6d4;
    --emerald-400:#34d399;
    --emerald-500:#10b981;
    --amber-400:  #fbbf24;
    --rose-400:   #fb7185;
    --rose-500:   #f43f5e;

    /* Light Theme Surfaces */
    --bg-page:    #f1f5f9;
    --bg-surface: #ffffff;
    --bg-card:    #ffffff;
    --bg-input:   #f8fafc;
    --border:     #e2e8f0;
    --border-light: rgba(0,0,0,0.06);

    /* Light Theme Text */
    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-muted:     #94a3b8;
    --text-inverse:   #ffffff;

    /* Sidebar (always dark) */
    --sb-bg:          #0c0f1d;
    --sb-surface:     #111827;
    --sb-border:      rgba(255,255,255,0.06);
    --sb-text:        #94a3b8;
    --sb-text-hover:  #e2e8f0;
    --sb-active-bg:   rgba(99,102,241,0.18);
    --sb-active-text: #a5b4fc;
    --sb-active-border:#6366f1;
    --sb-glow:        rgba(99,102,241,0.25);
    --sb-width:       260px;

    /* Topbar */
    --topbar-bg:     rgba(255,255,255,0.85);
    --topbar-border: rgba(226,232,240,0.8);
    --topbar-height: 64px;

    /* Accent */
    --primary:        #6366f1;
    --primary-dark:   #4f46e5;
    --primary-light:  #a5b4fc;
    --primary-glow:   rgba(99,102,241,0.3);
    --primary-rgb:    99, 102, 241;

    /* Semantic */
    --success:  #10b981;
    --warning:  #f59e0b;
    --danger:   #f43f5e;
    --info:     #06b6d4;

    /* Shadows & Effects */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:  0 10px 40px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);
    --shadow-glow: 0 0 24px rgba(99,102,241,0.25);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 20px rgba(0,0,0,0.06);

    /* Misc */
    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}



/* ─────────────────────────────────────────────
   BASE STYLES
───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Sarabun', 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
    background-color: var(--bg-page);
    color: var(--text-primary);
    transition: background-color var(--transition), color var(--transition);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .font-heading {
    font-family: 'Kanit', 'Inter', sans-serif;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* ─────────────────────────────────────────────
   LAYOUT STRUCTURE
───────────────────────────────────────────── */
#wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ─────────────────────────────────────────────
   SIDEBAR — Tech Dark Navigation
───────────────────────────────────────────── */
#sidebar {
    width: var(--sb-width);
    min-width: var(--sb-width);
    background-color: var(--sb-bg);
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(99,102,241,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 90%, rgba(139,92,246,0.06) 0%, transparent 60%);
    color: var(--sb-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: margin var(--transition), width var(--transition);
    border-right: 1px solid var(--sb-border);
    position: relative;
    overflow: hidden;
}

/* Decorative vertical accent line */
#sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent 0%, var(--indigo-500) 40%, var(--violet-500) 70%, transparent 100%);
    opacity: 0.4;
    pointer-events: none;
}

#sidebar.collapsed { margin-left: calc(-1 * var(--sb-width)); }

/* ── Sidebar Brand ── */
.sidebar-brand {
    padding: 0 1.25rem;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--sb-border);
    position: relative;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--indigo-500), var(--violet-600));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    margin-right: 0.75rem;
    flex-shrink: 0;
    box-shadow: 0 0 16px rgba(99,102,241,0.4);
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.sidebar-brand-name {
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.sidebar-brand-sub {
    font-size: 10px;
    color: var(--sb-text);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
    margin-top: 1px;
}

/* ── Sidebar Menu ── */
.sidebar-menu {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-menu li { padding: 0.15rem 0.75rem; }

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.85rem;
    color: var(--sb-text);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-size: 14px;
    font-weight: 400;
    position: relative;
    gap: 0.75rem;
    text-decoration: none;
}

.sidebar-menu li a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: transform var(--transition);
    color: var(--sb-text);
}

.sidebar-menu li a:hover {
    color: var(--sb-text-hover);
    background-color: rgba(255,255,255,0.05);
}

.sidebar-menu li a:hover .nav-icon {
    transform: scale(1.15);
    color: var(--indigo-400);
}

.sidebar-menu li.active a {
    color: var(--sb-active-text);
    background-color: var(--sb-active-bg);
    font-weight: 500;
    box-shadow: 0 0 20px var(--sb-glow);
}

.sidebar-menu li.active a::before {
    content: '';
    position: absolute;
    left: -0.85rem;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 3px;
    background: linear-gradient(to bottom, var(--indigo-400), var(--violet-500));
    border-radius: 0 3px 3px 0;
}

.sidebar-menu li.active a .nav-icon {
    color: var(--indigo-400);
}

.menu-header {
    padding: 1.25rem 1.5rem 0.4rem !important;
    font-size: 10px !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.22) !important;
    pointer-events: none;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--sb-border);
    flex-shrink: 0;
}

.sidebar-footer-inner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--indigo-600), var(--violet-600));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-footer-text { line-height: 1.2; }
.sidebar-footer-label {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    display: block;
}
.sidebar-footer-value {
    font-size: 11.5px;
    color: var(--indigo-400);
    font-weight: 600;
    font-family: 'Kanit', sans-serif;
}

/* ─────────────────────────────────────────────
   TOPBAR — Glassmorphism Navigation Bar
───────────────────────────────────────────── */
#content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: all var(--transition);
}

#topbar {
    height: var(--topbar-height);
    background-color: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--topbar-border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 999;
    transition: background-color var(--transition), border-color var(--transition);
}

.topbar-brand {
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-brand .brand-dot {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, var(--indigo-500), var(--violet-500));
    border-radius: 50%;
    display: inline-block;
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(99,102,241,0); }
}

/* Sidebar Toggle Button */
#sidebarToggle {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

#sidebarToggle:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 12px var(--primary-glow);
}

/* Theme Toggle Button */
#theme-toggle-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
}

#theme-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

/* User Profile Dropdown */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.75rem 0.4rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
}

.topbar-user-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
    color: inherit;
}

.topbar-user-btn .user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-user-btn .user-role-badge {
    font-size: 10px;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dropdown Menu */
.dropdown-menu {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0.5rem;
    min-width: 200px;
    animation: dropdownSlide 0.18s ease-out;
}

@keyframes dropdownSlide {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
    border-radius: var(--radius-sm);
    color: var(--text-secondary) !important;
    font-size: 14px;
    padding: 0.55rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all var(--transition);
}

.dropdown-item:hover {
    background: rgba(var(--primary-rgb), 0.08) !important;
    color: var(--primary) !important;
}

.dropdown-item.text-danger:hover {
    background: rgba(244,63,94,0.08) !important;
    color: var(--danger) !important;
}

.dropdown-divider {
    border-color: var(--border);
    margin: 0.4rem 0;
}

.dropdown-header-section {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

/* ─────────────────────────────────────────────
   MAIN CONTENT AREA
───────────────────────────────────────────── */
#content {
    flex-grow: 1;
    padding: 1.75rem 2rem;
    overflow-y: auto;
    animation: pageEnter 0.3s ease-out;
}

@keyframes pageEnter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: pageEnter 0.35s ease-out; }

/* Page Header */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header-title {
    font-family: 'Kanit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header-title .title-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--indigo-500), var(--violet-600));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 0 20px var(--primary-glow);
    flex-shrink: 0;
}

.page-breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.page-breadcrumb .sep { opacity: 0.4; }

/* ─────────────────────────────────────────────
   CARD COMPONENTS — SaaS Style
───────────────────────────────────────────── */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    transition: transform var(--transition), box-shadow var(--transition),
                background-color var(--transition), border-color var(--transition);
    overflow: hidden;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(var(--primary-rgb), 0.2);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1.1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-header-title {
    font-family: 'Kanit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.card-header-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* ── Stat Cards ── */
.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: default;
}

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

.stat-card .stat-body {
    padding: 1.5rem;
    position: relative;
    z-index: 2;
    color: #fff;
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.82;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-family: 'Kanit', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-card .stat-desc {
    font-size: 12.5px;
    opacity: 0.75;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.stat-card .stat-bg-icon {
    position: absolute;
    right: -8px;
    bottom: -12px;
    font-size: 5.5rem;
    opacity: 0.12;
    transform: rotate(-10deg);
    z-index: 1;
    transition: transform var(--transition), opacity var(--transition);
}

.stat-card:hover .stat-bg-icon {
    opacity: 0.18;
    transform: rotate(-5deg) scale(1.05);
}

/* Gradients */
.grad-indigo  { background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); }
.grad-violet  { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); }
.grad-cyan    { background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%); }
.grad-emerald { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }
.grad-amber   { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.grad-rose    { background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%); }

/* Legacy Gradient Aliases */
.bg-gradient-primary  { background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); }
.bg-gradient-success  { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }
.bg-gradient-info     { background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%); }
.bg-gradient-warning  { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.bg-gradient-danger   { background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%); }
.bg-gradient-purple   { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); }

/* ── Card Stat (Legacy) ── */
.card-stat {
    border: none;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-lg);
}

.card-stat .card-body { padding: 1.5rem; color: #ffffff; z-index: 2; position: relative; }

.card-stat .stat-icon {
    position: absolute;
    right: -10px;
    bottom: -10px;
    font-size: 5.5rem;
    color: rgba(255,255,255,0.12);
    transform: rotate(-15deg);
    z-index: 1;
    transition: transform var(--transition);
}

.card-stat:hover .stat-icon { transform: rotate(-8deg) scale(1.08); }

/* ─────────────────────────────────────────────
   TABLES — Tech Style
───────────────────────────────────────────── */
.table {
    color: var(--text-primary);
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    font-family: 'Kanit', sans-serif;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    background-color: rgba(var(--primary-rgb), 0.04);
    border-bottom: 1px solid var(--border) !important;
    padding: 12px 16px;
    white-space: nowrap;
}

.table td {
    padding: 13px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 14px;
}

.table tbody tr {
    transition: background-color var(--transition);
}

.table tbody tr:hover td {
    background-color: rgba(var(--primary-rgb), 0.03);
}

.table tbody tr:last-child td { border-bottom: none; }

/* DataTables overrides */
.dataTables_wrapper { color: var(--text-primary); }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.85rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-secondary) !important;
    margin: 0 2px;
    padding: 4px 12px !important;
    font-size: 13px;
    transition: all var(--transition);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    box-shadow: 0 0 10px var(--primary-glow);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(135deg, var(--indigo-500), var(--violet-600)) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
    box-shadow: 0 0 12px var(--primary-glow);
}

/* ─────────────────────────────────────────────
   FORMS & INPUTS — Clean Tech Style
───────────────────────────────────────────── */
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control,
.form-select {
    background-color: var(--bg-input);
    border: 1.5px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 14px;
    transition: all var(--transition);
    box-shadow: none;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
    outline: none;
}

.form-control:focus::placeholder { opacity: 0.5; }

.input-group-text {
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
}

/* ─────────────────────────────────────────────
   BUTTONS — SaaS Premium Style
───────────────────────────────────────────── */
.btn {
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.25rem;
    font-weight: 600;
    font-size: 14px;
    font-family: 'Kanit', sans-serif;
    transition: all var(--transition);
    border: 1.5px solid transparent;
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--indigo-500), var(--indigo-600));
    border-color: var(--indigo-600);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--indigo-600), var(--indigo-700));
    border-color: var(--indigo-700);
    color: #fff;
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.45);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: linear-gradient(135deg, var(--emerald-500), #047857);
    border-color: #047857;
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.btn-success:hover {
    box-shadow: 0 4px 16px rgba(16,185,129,0.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, var(--rose-500), #be123c);
    border-color: #be123c;
    color: #fff;
    box-shadow: 0 2px 8px rgba(244,63,94,0.3);
}

.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(244,63,94,0.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, var(--amber-400), #d97706);
    border-color: #d97706;
    color: #fff;
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}

.btn-warning:hover {
    box-shadow: 0 4px 16px rgba(245,158,11,0.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-info {
    background: linear-gradient(135deg, var(--cyan-500), #0891b2);
    border-color: #0891b2;
    color: #fff;
}

.btn-info:hover { transform: translateY(-1px); color: #fff; }

.btn-outline-primary {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 14px var(--primary-glow);
}

.btn-sm { padding: 0.35rem 0.85rem; font-size: 13px; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 16px; }

/* ─────────────────────────────────────────────
   BADGES — Pill Style
───────────────────────────────────────────── */
.badge {
    font-size: 11px;
    font-weight: 600;
    font-family: 'Kanit', sans-serif;
    padding: 0.3em 0.7em;
    border-radius: 100px;
    letter-spacing: 0.02em;
}

.badge-indigo {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--indigo-400);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
}

.badge-emerald {
    background: rgba(16,185,129,0.12);
    color: var(--emerald-400);
    border: 1px solid rgba(16,185,129,0.2);
}

.badge-rose {
    background: rgba(244,63,94,0.12);
    color: var(--rose-400);
    border: 1px solid rgba(244,63,94,0.2);
}

.badge-amber {
    background: rgba(245,158,11,0.12);
    color: var(--amber-400);
    border: 1px solid rgba(245,158,11,0.2);
}

.badge-cyan {
    background: rgba(6,182,212,0.12);
    color: var(--cyan-400);
    border: 1px solid rgba(6,182,212,0.2);
}

/* ─────────────────────────────────────────────
   LOGIN PAGE — Glassmorphism
───────────────────────────────────────────── */
.login-bg {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.12) 0%, transparent 55%),
        linear-gradient(135deg, #060912 0%, #0c0f1d 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.login-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0);
    background-size: 28px 28px;
    pointer-events: none;
}

.login-card {
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    color: #ffffff;
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    position: relative;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--indigo-500), var(--violet-500), var(--cyan-500));
}

.login-card-body { padding: 2.5rem; }

.login-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--indigo-500), var(--violet-600));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    margin: 0 auto 1.5rem;
    box-shadow: 0 0 30px rgba(99,102,241,0.45);
}

.login-title {
    font-family: 'Kanit', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    color: #fff;
    margin-bottom: 0.35rem;
}

.login-subtitle {
    font-size: 13.5px;
    text-align: center;
    color: rgba(255,255,255,0.5);
    margin-bottom: 2rem;
}

.login-card .form-control {
    background: rgba(255,255,255,0.05);
    border: 1.5px solid rgba(255,255,255,0.1);
    color: #ffffff;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.login-card .form-control::placeholder { color: rgba(255,255,255,0.35); }

.login-card .form-control:focus {
    background: rgba(255,255,255,0.08);
    border-color: var(--indigo-400);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
    color: #fff;
}

.login-card .form-label {
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.login-card .btn-primary {
    background: linear-gradient(135deg, var(--indigo-500), var(--violet-600));
    border: none;
    padding: 0.75rem;
    font-size: 15px;
    letter-spacing: 0.03em;
    box-shadow: 0 4px 20px rgba(99,102,241,0.4);
    width: 100%;
    justify-content: center;
    margin-top: 0.5rem;
}

.login-card .btn-primary:hover {
    box-shadow: 0 6px 28px rgba(99,102,241,0.55);
    transform: translateY(-2px);
}

.login-card .input-group-text {
    background: rgba(255,255,255,0.05);
    border: 1.5px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
}

.login-shell {
    min-height: calc(100vh - var(--topbar-height) - 72px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.25rem, 3vw, 2.25rem);
    background:
        linear-gradient(135deg, rgba(99,102,241,0.08), transparent 34%),
        radial-gradient(ellipse at 88% 16%, rgba(6,182,212,0.16), transparent 36%),
        radial-gradient(ellipse at 10% 88%, rgba(16,185,129,0.12), transparent 32%),
        #eef4fb;
}

.legacy-login-layout {
    display: none !important;
}

.login-panel {
    width: min(1120px, 100%);
    min-height: 610px;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
    background: var(--bg-card);
    border: 1px solid rgba(var(--primary-rgb), 0.14);
    border-radius: 20px;
    box-shadow: 0 24px 70px rgba(15,23,42,0.12);
    overflow: hidden;
}

.login-visual {
    position: relative;
    display: flex;
    align-items: flex-start;
    min-height: 100%;
    padding: clamp(2rem, 5vw, 3.25rem);
    color: #fff;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(15,23,42,0.95), rgba(49,46,129,0.92)),
        linear-gradient(120deg, #0f172a, #312e81 50%, #0e7490);
}

.login-visual::before,
.login-visual::after {
    content: '';
    position: absolute;
    border: 1px solid rgba(255,255,255,0.12);
    pointer-events: none;
}

.login-visual::before {
    width: 360px;
    height: 360px;
    right: -120px;
    top: -120px;
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
}

.login-visual::after {
    inset: 22px;
    border-radius: 16px;
    opacity: 0.28;
}

.login-visual-content {
    position: relative;
    z-index: 2;
    max-width: 520px;
    margin-top: clamp(0.35rem, 2vw, 1.2rem);
}

.login-brand-mark {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    margin-bottom: 1.6rem;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--amber-400), var(--emerald-400));
    color: #0f172a;
    font-size: 1.7rem;
    box-shadow: 0 18px 38px rgba(15,23,42,0.22);
}

.login-kicker {
    margin: 0 0 0.65rem;
    color: rgba(255,255,255,0.68);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-heading {
    margin: 0;
    color: #fff;
    font-size: clamp(1.7rem, 3vw, 2.55rem);
    line-height: 1.18;
}

.login-copy {
    margin: 1rem 0 0;
    max-width: 440px;
    color: rgba(255,255,255,0.72);
    font-size: 1rem;
}

.login-copy,
.login-feature-list {
    display: none;
}

.login-feature-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 2.35rem;
}

.login-feature {
    min-height: 96px;
    padding: 0.9rem;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 14px;
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(12px);
}

.login-feature span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    margin-bottom: 0.65rem;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    color: var(--cyan-400);
}

.login-feature strong {
    display: block;
    color: rgba(255,255,255,0.9);
    font-size: 0.82rem;
    line-height: 1.25;
}

.login-visual-icon {
    position: absolute;
    right: -18px;
    bottom: -26px;
    color: rgba(255,255,255,0.08);
    font-size: clamp(10rem, 22vw, 16rem);
    transform: rotate(-10deg);
}

.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vw, 3rem);
    background:
        linear-gradient(180deg, rgba(248,250,252,0.92), rgba(255,255,255,1));
}

.login-form-card {
    width: min(100%, 420px);
}

.login-form-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.login-form-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    color: #fff;
    background: linear-gradient(135deg, var(--indigo-500), var(--cyan-500));
    box-shadow: 0 14px 28px rgba(var(--primary-rgb), 0.25);
    flex-shrink: 0;
}

.login-form-head h2 {
    margin: 0;
    font-size: 1.55rem;
}

.login-form-head p {
    margin: 0.2rem 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.login-field {
    margin-bottom: 1rem;
}

.login-field .form-label {
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.82rem;
    margin-bottom: 0.45rem;
}

.login-input-wrap {
    position: relative;
}

.login-input-wrap > i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 2;
}

.login-input-wrap .form-control {
    min-height: 48px;
    padding-left: 2.75rem;
    border-radius: 12px;
    background: #fff;
    border-color: #dbe3ef;
    box-shadow: 0 1px 0 rgba(15,23,42,0.02);
}

.login-input-wrap .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
}

.login-submit {
    width: 100%;
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin-top: 0.4rem;
    border: 0;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: 0 16px 30px rgba(var(--primary-rgb), 0.27);
}

.login-register {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.login-register a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
}

.login-copy,
.login-feature-list {
    display: none !important;
}

@media (max-width: 991.98px) {
    .login-shell {
        align-items: flex-start;
        padding: 1rem;
    }

    .login-panel {
        min-height: auto;
        grid-template-columns: 1fr;
    }

    .login-visual {
        min-height: auto;
        padding: 2rem;
    }

    .login-feature-list {
        grid-template-columns: 1fr;
        margin-top: 1.5rem;
    }

    .login-feature {
        min-height: auto;
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .login-feature span {
        margin-bottom: 0;
        flex-shrink: 0;
    }
}

@media (max-width: 575.98px) {
    .login-shell {
        padding: 0.75rem;
    }

    .login-panel {
        border-radius: 16px;
    }

    .login-visual,
    .login-form-panel {
        padding: 1.35rem;
    }

    .login-brand-mark {
        width: 52px;
        height: 52px;
        margin-bottom: 1.15rem;
        border-radius: 15px;
        font-size: 1.35rem;
    }

    .login-heading {
        font-size: 1.45rem;
    }

    .login-copy {
        font-size: 0.92rem;
    }

    .login-form-head {
        align-items: flex-start;
        margin-bottom: 1.4rem;
    }

    .login-form-icon {
        width: 46px;
        height: 46px;
    }
}

/* ─────────────────────────────────────────────
   IMAGES
───────────────────────────────────────────── */
.img-cover {
    width: 52px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
}

.img-cover-lg {
    width: 140px;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.img-avatar {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid rgba(var(--primary-rgb), 0.3);
}

.img-avatar-lg {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
}

/* ─────────────────────────────────────────────
   FOOTER
───────────────────────────────────────────── */
footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition);
}

footer .footer-brand {
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 13px;
    background: linear-gradient(135deg, var(--indigo-400), var(--violet-500));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─────────────────────────────────────────────
   UTILITIES & MISC
───────────────────────────────────────────── */

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Glow Divider */
.glow-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0.4;
    border: none;
    margin: 1.5rem 0;
}

/* Status indicator dots */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.active  { background: var(--emerald-400); box-shadow: 0 0 6px rgba(52,211,153,0.6); }
.status-dot.warning { background: var(--amber-400);   box-shadow: 0 0 6px rgba(251,191,36,0.6); }
.status-dot.danger  { background: var(--rose-400);    box-shadow: 0 0 6px rgba(251,113,133,0.6); }
.status-dot.muted   { background: var(--text-muted); }

/* Glass Card */
.glass-card {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
}

/* Colored info boxes */
.info-box {
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 14px;
}

.info-box.info-primary {
    background: rgba(var(--primary-rgb), 0.07);
    border-color: rgba(var(--primary-rgb), 0.2);
    color: var(--indigo-400);
}

.info-box.info-success {
    background: rgba(16,185,129,0.07);
    border-color: rgba(16,185,129,0.2);
    color: var(--emerald-400);
}

.info-box.info-danger {
    background: rgba(244,63,94,0.07);
    border-color: rgba(244,63,94,0.2);
    color: var(--rose-400);
}

.info-box.info-warning {
    background: rgba(245,158,11,0.07);
    border-color: rgba(245,158,11,0.2);
    color: var(--amber-400);
}

/* Transition helper */
.transition-colors {
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 992px) {
    #content { padding: 1.25rem; }
}

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        margin-left: calc(-1 * var(--sb-width));
        z-index: 1050;
    }

    #sidebar.show {
        margin-left: 0;
        box-shadow: 4px 0 30px rgba(0,0,0,0.4);
    }

    #content-wrapper { width: 100%; }
    #content { padding: 1rem; }

    .page-header-title { font-size: 1.2rem; }
    .stat-card .stat-value { font-size: 1.75rem; }

    footer { flex-direction: column; gap: 0.35rem; text-align: center; padding: 0.85rem 1rem; }
}

@media (max-width: 480px) {
    #topbar { padding: 0 1rem; }
    .topbar-user-btn .user-name,
    .topbar-user-btn .user-role-badge { display: none; }
}
