:root {
    --primary-color: #4f46e5; /* Indigo 600 */
    --primary-hover: #4338ca; /* Indigo 700 */
    --secondary-color: #64748b; /* Slate 500 */
    --bg-body: #f1f5f9; /* Slate 100 */
    --bg-card: #ffffff;
    --text-main: #0f172a; /* Slate 900 */
    --text-muted: #64748b; /* Slate 500 */
    --border-color: #e2e8f0; /* Slate 200 */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 64px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 0.875rem; /* 14px base for compactness */
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #1e293b; /* Slate 800 */
    color: #fff;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.05);
    transition: width 0.3s ease;
    overflow-x: hidden;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
}

.sidebar-brand i {
    margin-right: 0.5rem;
    color: #818cf8; /* Indigo 400 */
    font-size: 1.5rem;
    min-width: 24px;
    text-align: center;
}

.sidebar-menu {
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom Scrollbar for Sidebar */
.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.2);
}


.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: #94a3b8; /* Slate 400 */
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    position: relative;
}

.nav-link:hover, .nav-link.active {
    color: #fff;
    background-color: rgba(255,255,255,0.05);
}

.nav-link.active {
    border-left-color: #818cf8;
}

.nav-link i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    min-width: 20px;
    text-align: center;
}

/* Accordion/Collapse Arrow Rotation */
.nav-link[data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform 0.3s ease;
}

.nav-link[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.nav-title {
    padding: 1.5rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569; /* Slate 600 */
    font-weight: 700;
    white-space: nowrap;
}

.sidebar-footer {
    white-space: nowrap;
}

/* Collapsed Sidebar Styles */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

/* Hide chevron in collapsed mode */
body.sidebar-collapsed .bi-chevron-down {
    display: none !important;
}

/* Submenu links padding reset in collapsed mode */
.submenu-link {
    padding-left: 3rem;
}

body.sidebar-collapsed .submenu-link {
    padding-left: 0; /* Override padding */
    justify-content: center;
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-title {
    display: none;
    opacity: 0;
}

body.sidebar-collapsed .sidebar-brand {
    padding: 0;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-brand i {
    margin-right: 0;
}

body.sidebar-collapsed .nav-link {
    padding: 0.75rem 0;
    justify-content: center;
}

body.sidebar-collapsed .nav-link i {
    margin-right: 0;
}

body.sidebar-collapsed .sidebar-footer {
    padding: 1rem 0.5rem !important;
}

body.sidebar-collapsed .sidebar-footer .btn {
    padding: 0.5rem;
}

body.sidebar-collapsed .sidebar-footer .btn i {
    margin: 0;
}

/* Badge Fix for Collapsed Sidebar */
body.sidebar-collapsed .nav-link .badge {
    position: absolute;
    top: 10px;
    left: 50%;
    margin: 0 !important;
    margin-left: 6px !important;
    padding: 0.25em 0.4em;
    font-size: 0.65rem !important;
    min-width: 1.2em;
    border-radius: 10px;
    box-shadow: 0 0 0 2px #1e293b;
    z-index: 10;
}

/* Mobile Sidebar behavior - unchanged mostly but ensure it works */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width); /* Always full width on mobile when shown */
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important; /* Never margin on mobile */
    }

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width); /* Reset width if class persists */
    }
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.page-content {
    padding: 2rem;
    flex: 1;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.25rem;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom-width: 1px;
    background-color: #f8fafc;
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    color: var(--text-main);
    border-bottom-color: var(--border-color);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 0.375rem;
}

/* Buttons */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

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