:root {
    --bg-body: #0f1015;
    --bg-sidebar: #16171d;
    --bg-card: #1e1f26;
    --text-primary: #e0e6ed;
    --text-muted: #d1d5db;
    --border-color: #2b2d36;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    --success-gradient: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Source Sans Pro', sans-serif;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body); 
}
::-webkit-scrollbar-thumb {
    background: #4b5563; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #6b7280; 
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: radial-gradient(circle at center, #1f2937 0%, #0f1015 100%);
}

.login-box {
    width: 400px;
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
}

.login-box h3 {
    margin-bottom: 30px;
    font-weight: 300;
    letter-spacing: 1px;
}

.form-control {
    background-color: #2a2b35;
    border: 1px solid #3f4250;
    color: var(--text-primary);
}

.form-control:focus {
    background-color: #2a2b35;
    border-color: #6366f1;
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
}

.input-group-text {
    background-color: #323541;
    border: 1px solid #3f4250;
    color: var(--text-muted);
}

/* Layout */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: 240px;
    max-width: 240px;
    background: var(--bg-sidebar);
    color: var(--text-primary);
    transition: all 0.3s;
    min-height: 100vh;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

#sidebar .sidebar-header {
    padding: 18px 16px 14px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

#sidebar .sidebar-header h3 {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 2px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2px;
}

#sidebar .sidebar-header .text-muted {
    color: #ffffff !important;
}

#sidebar .sidebar-header p {
    font-size: 0.72rem;
    opacity: 0.4;
    margin: 0;
}

#sidebar ul.components {
    padding: 6px 0 10px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Thin inner scrollbar */
#sidebar ul.components::-webkit-scrollbar { width: 3px; }
#sidebar ul.components::-webkit-scrollbar-track { background: transparent; }
#sidebar ul.components::-webkit-scrollbar-thumb { background: #2b2d36; border-radius: 3px; }

/* Collapsible sidebar groups */
#sidebar .sidebar-group {
    margin: 0;
}

#sidebar .sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 6px;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

#sidebar .sidebar-group-toggle span {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #555a6e;
    transition: color 0.15s;
}

#sidebar .sidebar-group-toggle:hover span {
    color: #8b90a5;
}

#sidebar .sidebar-group-chevron {
    font-size: 0.5rem;
    color: #3e4255;
    transition: transform 0.25s ease, color 0.15s;
}

#sidebar .sidebar-group-toggle:hover .sidebar-group-chevron {
    color: #6b7090;
}

#sidebar .sidebar-group.collapsed .sidebar-group-chevron {
    transform: rotate(-90deg);
}

#sidebar .sidebar-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease;
}

#sidebar .sidebar-group.collapsed .sidebar-group-items {
    max-height: 0;
}

#sidebar ul li.nav-item a {
    padding: 7px 16px;
    font-size: 0.82rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
    color: #7c8091;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    border-left: 2px solid transparent;
    margin: 0;
}

#sidebar ul li.nav-item a span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar ul li.nav-item a:hover {
    color: #b8bdd0;
    background: rgba(255,255,255,0.025);
}

#sidebar ul li.active > a {
    color: #e0e4f0;
    background: rgba(99, 102, 241, 0.08);
    border-left-color: #6366f1;
}

#sidebar ul li.nav-item a i {
    width: 18px;
    min-width: 18px;
    text-align: center;
    margin-right: 10px;
    font-size: 0.78rem;
    opacity: 0.45;
    flex-shrink: 0;
}

#sidebar ul li.nav-item a:hover i {
    opacity: 0.7;
}

#sidebar ul li.active > a i {
    opacity: 0.9;
}

/* Sidebar footer */
#sidebar .sidebar-footer {
    padding: 10px 14px !important;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

#sidebar .sidebar-footer .btn {
    font-size: 0.78rem;
    padding: 5px 0;
    border-radius: 6px;
}

#content {
    width: 100%;
    padding: 2.5rem;
    min-height: 100vh;
    transition: all 0.3s;
    background: #0f1015;
}

/* Top Navbar */
.navbar {
    padding: 0;
    background: transparent !important;
    border-bottom: none;
    margin-bottom: 2rem !important;
}

#sidebarCollapse {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: none;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 8px;
    margin-bottom: 25px;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem;
}

.card-header h5 {
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

.card-body {
    color: var(--text-muted);
    padding: 1.5rem;
}

/* Buttons */
.btn-primary {
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4);
}

.btn-danger {
    background: var(--danger-gradient);
    border: none;
}
.btn-success {
    background: var(--success-gradient);
    border: none;
}
.btn-warning {
    background: var(--warning-gradient);
    border: none;
    color: #fff;
}

.badge.bg-warning {
    background: #b45309 !important;
    color: #fff !important;
}

.badge.bg-info {
    background: #0e7490 !important;
    color: #fff !important;
}

/* Tables */
.table {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.table>:not(caption)>*>* {
    background-color: transparent;
    border-bottom-color: var(--border-color);
    padding: 1rem 0.5rem;
}

.table-striped>tbody>tr:nth-of-type(odd)>* {
    color: var(--text-primary);
    background-color: rgba(255,255,255,0.02);
}

/* Fix for Even rows visibility */
.table-striped>tbody>tr:nth-of-type(even)>* {
    color: var(--text-primary) !important;
    background-color: transparent;
}

table.dataTable tbody tr.even {
    background-color: transparent !important;
}

table.dataTable tbody tr {
    color: var(--text-primary) !important;
}

.table-hover>tbody>tr:hover>* {
    color: #fff;
    background-color: rgba(255,255,255,0.05);
}

thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    color: #ffffff !important;
    background-color: #1f2029;
    padding: 12px !important;
    border-bottom: 2px solid var(--border-color) !important;
}

/* DataTables Overrides */
.dataTables_wrapper .dataTables_length, 
.dataTables_wrapper .dataTables_filter, 
.dataTables_wrapper .dataTables_info, 
.dataTables_wrapper .dataTables_processing, 
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-muted) !important;
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background-color: #2a2b35;
    border: 1px solid #3f4250;
    color: var(--text-primary);
    border-radius: 4px;
    padding: 4px 8px;
}

.page-item.disabled .page-link {
    background-color: #2a2b35;
    border-color: #3f4250;
    color: #6c757d;
}

.page-item.active .page-link {
    background: var(--accent-gradient);
    border-color: transparent;
}

.page-link {
    background-color: #2a2b35;
    border-color: #3f4250;
    color: var(--text-primary);
}

.page-link:hover {
    background-color: #3f4250;
    border-color: #3f4250;
    color: #fff;
}

/* SweetAlert2 Dark */
.swal2-popup {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
.swal2-title {
    color: var(--text-primary) !important;
}
.swal2-content, .swal2-html-container {
    color: var(--text-muted) !important;
}
.swal2-input, .swal2-select, .swal2-textarea {
    background-color: #2a2b35 !important;
    border: 1px solid #3f4250 !important;
    color: #fff !important;
}
.swal2-select {
    padding: 0.625rem 0.75rem !important;
    border-radius: 0.3125em !important;
    font-size: 1.125em !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px !important;
    padding-right: 32px !important;
}
.swal2-select option {
    background: #2a2b35;
    color: #fff;
}
.swal2-input:focus, .swal2-select:focus, .swal2-textarea:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
    outline: none !important;
}
.swal2-textarea {
    min-height: 80px !important;
    resize: vertical !important;
}
.swal2-input::placeholder, .swal2-textarea::placeholder {
    color: #6b7280 !important;
}
.swal2-validation-message {
    background: rgba(239, 68, 68, 0.12) !important;
    color: #fca5a5 !important;
    border: none !important;
    font-size: 0.85rem !important;
}
.swal-field-group {
    text-align: left;
    margin: 0.75rem auto;
    width: calc(100% - 2rem);
}
.swal-field-group > label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    padding-left: 2px;
}
.swal-field-group > input,
.swal-field-group > select,
.swal-field-group > textarea {
    width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}
.swal-field-group .field-hint {
    font-size: 0.7rem;
    color: #6b7280;
    margin-top: 0.2rem;
    padding-left: 2px;
}

/* ====== Loaders & Transitions ====== */

/* Top progress bar */
.top-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--accent-gradient);
    z-index: 9999;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    pointer-events: none;
}
.top-loader.loading {
    animation: topLoaderProgress 1.8s ease-in-out forwards;
}
.top-loader.done {
    width: 100% !important;
    opacity: 0;
    transition: width 0.15s ease, opacity 0.4s ease 0.15s;
}
@keyframes topLoaderProgress {
    0%   { width: 0; }
    20%  { width: 35%; }
    50%  { width: 60%; }
    80%  { width: 82%; }
    100% { width: 90%; }
}

/* Page content fade-in */
#page-content {
    opacity: 1;
    transition: opacity 0.18s ease;
}
#page-content.fade-out {
    opacity: 0;
}

/* DataTable processing overlay - modern */
.dataTables_processing {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
    margin: 0 !important;
    padding: 1rem 2rem !important;
    background: rgba(15, 16, 21, 0.92) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    color: var(--text-muted) !important;
    font-size: 0.85rem !important;
    backdrop-filter: blur(4px) !important;
    z-index: 50 !important;
    align-items: center !important;
    gap: 10px !important;
}
.dataTables_processing[style*="display: block"] {
    display: flex !important;
}
.dataTables_processing::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid #3f4250;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: dtSpin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes dtSpin {
    to { transform: rotate(360deg); }
}

/* Card body table area - relative for processing */
.card-body { position: relative; }

/* Skeleton shimmer */
.skeleton {
    background: linear-gradient(90deg, #1e1f26 25%, #2a2b35 50%, #1e1f26 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Dashboard stat skeleton */
.stat-skeleton {
    height: 42px;
    width: 70%;
    margin-top: 0.5rem;
    border-radius: 6px;
}

/* Table skeleton rows */
.table-skeleton {
    padding: 0;
}
.table-skeleton .skel-row {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}
.table-skeleton .skel-row:last-child { border-bottom: none; }
.table-skeleton .skel-cell {
    height: 16px;
    border-radius: 4px;
    flex: 1;
}
.table-skeleton .skel-cell.sm { max-width: 50px; }
.table-skeleton .skel-cell.md { max-width: 120px; }
.table-skeleton .skel-cell.lg { max-width: 200px; }

/* Button loading state */
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dtSpin 0.6s linear infinite;
}

/* Content area loading overlay (for full-card loads) */
.card-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 16, 21, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 10;
    backdrop-filter: blur(2px);
}
.card-loading-overlay .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #2b2d36;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: dtSpin 0.7s linear infinite;
}

/* Column filter banner */
.column-filter-banner {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 8px;
    color: #e0e6ed;
    font-size: 0.9rem;
}
.column-filter-banner .fa-filter {
    color: #a855f7;
}
.column-filter-banner .reset-filter-btn {
    border-color: rgba(255,255,255,0.3);
    font-size: 0.8rem;
    padding: 2px 12px;
    transition: all 0.2s;
}
.column-filter-banner .reset-filter-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #fca5a5;
}
