:root {
    /* Brand Colors */
    --primary-color: #00AE51;
    /* Start of gradient (Green) */
    --secondary-color: #0071BC;
    /* End of gradient (French Blue) */
    --danger-color: #ed1c24;
    /* Accent Red */
    --neutral-dark: #595450;
    /* Davy's Grey */
    --text-color: #212529;
    --background-color: #f8f9fa;
    /* Gradient (optional) */
    --primary-gradient: linear-gradient(to right, #00AE51, #0071BC);
    /* Sidebar */
    --sidebar-width: 220px;
    --sidebar-bg: #ffffff;
    --sidebar-hover-bg: #f0fdf4;
    --sidebar-border-color: #00AE51;
    --btn-text-color: #ffffff;
    /* Card and KPI styles */
    --kpi-card-bg: #ffffff;
    --kpi-card-border: #e9ecef;
    --kpi-card-text: #495057;
    --kpi-value-text: #212529;
    --primary-icon-color: #0d6efd;
    --success-icon-color: #198754;
    --warning-icon-color: #fd7e14;
    --danger-icon-color: #dc3545;
}

/* Reset default body layout */
body {
    margin: 0;
    height: 100%;
    font-family: 'Segoe UI', sans-serif;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    border-right: 1px solid #dee2e6;
    border-top-right-radius: 30px;
    border-bottom-right-radius: 30px;
    padding-top: 1rem;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    background-color: var(--sidebar-bg);
    overflow-y: scroll;
}

/* Show sidebar when toggled */
.sidebar.show-sidebar {
    transform: translateX(0);
}

.sidebar .bi {
    fill: currentColor;
    color: var(--primary-color);
}

/* Sidebar links */
.sidebar-links {
    margin: 2rem 1rem;
}

.sidebar-links a, .sidebar-links button.btn-link {
    padding: 0.75rem 1rem;
    color: var(--text-color);
    font-weight: 500;
    text-decoration: none;
    border-left: 4px solid transparent;
    transition: all 0.2s ease-in-out;
    border-radius: 0.375rem;
}

.sidebar-links a i, .sidebar-links button.btn-link i {
    font-size: 1.2rem;
    transition: color 0.2s ease;
}

.sidebar-links a:hover, .sidebar-links button.btn-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--primary-color);
    border-left: 4px solid var(--sidebar-border-color);
    transition: all 0.15s ease-in-out;
}

.sidebar-links a.active, .sidebar-links button.btn-link.active {
    background-color: var(--sidebar-hover-bg);
    color: var(--primary-color);
    border-left: 4px solid var(--sidebar-border-color);
}

.sidebar-heading {
    font-size: 0.75rem;
    font-weight: bold;
    color: #6c757d; /* Darker gray for better WCAG contrast */
    text-transform: uppercase;
    padding: 0 1rem;
    margin-top: 1rem;
}

.sidebar-divider {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Ensure the chevron icon has a smooth transition */
.sidebar-links .btn[data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform 0.2s ease-in-out;
}

/* State 1: When the menu is COLLAPSED.
  The '.collapsed' class is present on the button.
  We ensure the chevron points DOWN (0 degrees rotation).
*/
.sidebar-links .btn[data-bs-toggle="collapse"].collapsed .bi-chevron-down {
    transform: rotate(0deg);
}

/* State 2: When the menu is EXPANDED.
  The '.collapsed' class is removed.
  We rotate the chevron to point UP (-180 degrees).
*/
.sidebar-links .btn[data-bs-toggle="collapse"]:not(.collapsed) .bi-chevron-down {
    transform: rotate(-180deg);
}



/* Main wrapper (topbar + content) */
.container-wrapper {
    margin-left: 0;
    height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Shift content when sidebar is visible */
.container-wrapper.shifted {
    margin-left: var(--sidebar-width);
}

/* Topbar */
.topbar {
    height: 64px;
    background-color: #ffffff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 500;
}

.brand-name {
    font-weight: 600;
    font-size: 15px;
    background: linear-gradient(90deg, rgba(0, 113, 188, 1), rgba(0, 166, 81, 1));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}


/* Main content */
#mainContent {
    padding: 1.5rem;
    background-color: var(--background-color);
}

/* Toggle button style */
#toggleSidebar {
    border: 0;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--secondary-color) !important;
    border-color: var(--secondary-color) !important;
    color: var(--btn-text-color) !important;
}

.menu-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: 120px;
}

#toast-container {
    position: fixed;
    top: 70px;
    /* leave space for navbar */
    right: 20px;
    z-index: 1080;
}

.toast {
    min-width: 250px;
    margin-bottom: 1rem;
}

/* Card styles for KPIs */
.dashboard-kpi-card {
    background-color: var(--kpi-card-bg);
    border: 1px solid var(--kpi-card-border);
    border-radius: .75rem;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.dashboard-kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
}

.kpi-icon {
    font-size: 2.5rem;
    line-height: 1;
    opacity: 0.8;
}

.kpi-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--kpi-card-text);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--kpi-value-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-change-indicator {
    font-size: 1.2rem;
    font-weight: bold;
}

.kpi-change-indicator .bi {
    font-size: 1.5rem;
    vertical-align: middle;
}

/* User Profile Dropdown Styling */
.user-profile-trigger {
    padding: 5px 8px;
    border-radius: 50px;
    transition: background-color 0.2s ease;
}

.user-profile-trigger:hover {
    background-color: #f8f9fa;
}

.avatar-wrapper img {
    object-fit: cover;
    background-color: #f0fdf4;
    /* Light green tint to match your brand */
    padding: 2px;
}

/* Make dropdown look more modern */
.dropdown-menu {
    border-radius: 12px;
    min-width: 200px;
}

.dropdown-item {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.dropdown-item i {
    font-size: 1.1rem;
}

.avatar-initials {
    width: 36px;
    /* Slightly smaller looks more elegant in a thin header */
    height: 36px;
    background: linear-gradient(135deg, #00AE51, #0071BC);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 50%;
    /* Add a very subtle drop shadow */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Prevents the responsive wrapper from clipping dropdowns vertically */
.table-responsive {
    overflow: inherit;
}

.sticky-thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}

@media (max-width: 991.98px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Optional: Add a subtle inner shadow to hint at scrollable content */
        background: linear-gradient(to right, white 30%, rgba(255, 255, 255, 0)), linear-gradient(to right, rgba(255, 255, 255, 0), white 70%) 0 100%, radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)), radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)) 0 100%;
        background-repeat: no-repeat;
        background-color: white;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-position: 0 0, 100%, 0 0, 100%;
        background-attachment: local, local, scroll, scroll;
    }
}

/* Improve data table row hover interactions */
.table-hover tbody tr {
    transition: background-color 0.2s ease-in-out;
}
.table-hover tbody tr:hover {
    background-color: #f8f9fa;
    cursor: pointer;
}