:root {
    --sidebar-width: 280px;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --transition-speed: 0.3s;
}

[data-bs-theme="light"] {
    --bg-body: #f8f9fa;
    --bg-surface: #ffffff;
    --border-color: #e9ecef;
    --text-main: #212529;
    --text-muted: #6c757d;
    --sidebar-bg: #ffffff;
    --sidebar-text: #495057;
    --sidebar-hover: #f1f3f5;
    --sidebar-active-bg: rgba(67, 97, 238, 0.1);
    --sidebar-active-text: #4361ee;
    --primary-color: #4361ee;
    --table-header-bg: #f8f9fa;
    --table-border: #e9ecef;
    --card-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
}

[data-bs-theme="dark"] {
    --bg-body: #0f111a;
    --bg-surface: #161925;
    --border-color: #2a2e3f;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --sidebar-bg: #161925;
    --sidebar-text: #94a3b8;
    --sidebar-hover: rgba(255,255,255,0.05);
    --sidebar-active-bg: #4361ee;
    --sidebar-active-text: #ffffff;
    --primary-color: #4361ee;
    --table-header-bg: #1a1e2d;
    --table-border: #2a2e3f;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Typography & General Classes */
a { text-decoration: none; }
.text-muted { color: var(--text-muted) !important; }

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

.sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    min-height: 100vh;
    transition: all var(--transition-speed);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
}

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

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar ul.components {
    padding: 1.5rem 1rem;
}

.sidebar a {
    padding: 0.8rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    border-radius: 10px;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.sidebar a i {
    width: 24px;
    text-align: center;
    margin-right: 12px;
    font-size: 1.1rem;
}

.sidebar a:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-active-text);
}

.sidebar a.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.main-content {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    padding: 0 1.5rem !important;
}

/* Cards */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Tables (Completely Redesigned) */
.table-responsive {
    border-radius: 0 0 12px 12px;
}

.table {
    margin-bottom: 0;
    color: var(--text-main);
    border-collapse: separate;
    border-spacing: 0;
}

.table > :not(caption) > * > * {
    padding: 1rem 1.5rem;
    background-color: transparent;
    border-bottom: 1px solid var(--table-border);
    color: var(--text-main);
}

.table thead th {
    background-color: var(--table-header-bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--table-border);
    white-space: nowrap;
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background-color: rgba(67, 97, 238, 0.03);
}

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

/* Badges */
.badge {
    padding: 0.4rem 0.8rem;
    font-weight: 500;
    border-radius: 6px;
}
.badge-active { background-color: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-warning { background-color: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-danger { background-color: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-inactive { background-color: rgba(107, 114, 128, 0.15); color: #6b7280; }

/* Forms */
.form-control, .form-select {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 8px;
    padding: 0.6rem 1rem;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-surface);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.15);
    color: var(--text-main);
}

/* Modals */
.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}
.modal-header, .modal-footer {
    border-color: var(--border-color);
}
.modal-title {
    color: var(--text-main);
}
.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
[data-bs-theme="light"] .btn-close {
    filter: none;
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
        position: fixed;
        z-index: 1040;
        box-shadow: 0 0 20px rgba(0,0,0,0.1);
    }
    .sidebar.active {
        margin-left: 0;
    }
}
