/* Modern Color Palette & Variables */
:root {
    /* Primary Colors */
    --primary-color: #6C5DD3;
    /* Soft Indigo */
    --primary-hover: #5b4cc4;
    --secondary-color: #325199;
    /* Cool Gray -> Updated to Dark Blue */

    /* Backgrounds */
    --main-bg-color: #F4F7FE;
    /* Light Pastel Blue/Grey */
    --sidebar-bg-color: #FFFFFF;
    --card-bg-color: #FFFFFF;

    /* Text Colors */
    --text-main: #2f2f2f;
    /* Updated Dark Grey */
    --text-muted: #325199;
    /* Updated to Dark Blue */
    --text-light: #FFFFFF;

    /* Status Colors (Pastel/Soft) */
    --success-color: #05CD99;
    --warning-color: #FFB547;
    --danger-color: #EE5D50;
    --info-color: #3B9AE1;

    /* Spacing & Borders */
    --border-radius: 8px;
    --card-shadow: 0px 18px 40px rgba(112, 144, 176, 0.12);
}

body {
    background-color: var(--main-bg-color);
    color: var(--text-main);
    font-family: 'Red Hat Text', sans-serif;
    overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--main-bg-color);
}

::-webkit-scrollbar-thumb {
    background: #cdd5f3;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* --- Wrapper & Sidebar Layout --- */
#wrapper {
    overflow-x: hidden;
    display: flex;
    width: 100%;
}

#sidebar-wrapper {
    min-height: 100vh;
    height: 100vh;
    /* Fixed height for scrollable internal area */
    width: 210px;
    background-color: var(--sidebar-bg-color);
    margin-left: -210px;
    /* Mobile hidden by default */
    transition: margin 0.3s ease-in-out;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.02);
    z-index: 1000;
    flex-shrink: 0;
    min-width: 210px;
    display: flex;
    flex-direction: column;
    position: fixed;
    /* Fix to viewport */
    top: 0;
    left: 0;
}

#sidebar-wrapper .sidebar-heading {
    padding: 1.5rem 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    position: relative;
    flex-shrink: 0;
    /* Header doesn't shrink */
}

#sidebar-wrapper .list-group {
    padding: 0.5rem;
    gap: 0.25rem;
    flex-grow: 1;
    /* Takes available space */
    overflow-y: auto;
    /* Scrollable if content overflows */
    margin: 0;
    /* Reset margins */
}

/* Custom Scrollbar for Menu */
#sidebar-wrapper .list-group::-webkit-scrollbar {
    width: 4px;
}

#sidebar-wrapper .list-group::-webkit-scrollbar-thumb {
    background: #e0e5f2;
    border-radius: 4px;
}

#sidebar-wrapper .list-group-item {
    border: none;
    background: transparent;
    color: var(--secondary-color);
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

#sidebar-wrapper .list-group-item i {
    width: 20px;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

/* User Footer Section (Fixed at bottom by flex layout) */
.sidebar-footer {
    padding: 1rem;
    /* More breathing room */
    background-color: #f8f9fa;
    /* Slight contrast */
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    /* Don't shrink */
}

.avatar-circle {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(108, 93, 211, 0.2);
}

.user-info small {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 120px;
}

.user-info a {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.user-info a:hover {
    color: var(--danger-color);
}

/* Floating Toggle Tab */
#sidebarToggleOutside {
    position: fixed;
    top: 20px;
    left: 0;
    z-index: 1050;
    border-radius: 0 50% 50% 0;
    /* Tab shape */
    padding: 0.6rem 0.9rem 0.6rem 0.7rem;
    background: white;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.08);
    /* Softer shadow */
    border: 1px solid rgba(0, 0, 0, 0.02);
    border-left: none;
    transition: left 0.3s ease-in-out;
    cursor: pointer;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

#sidebarToggleOutside:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Inside Toggle (Collapse) */
#sidebarToggleInside {
    cursor: pointer;
    transition: color 0.2s;
}

#sidebarToggleInside:hover {
    color: var(--primary-color) !important;
}


/* --- Main Content Area --- */
#page-content-wrapper {
    width: 100%;
    min-height: 100vh;
    padding: 0;
    transition: all 0.3s ease;
}

/* Responsive Behavior */
@media (min-width: 768px) {
    #sidebar-wrapper {
        margin-left: 0;
    }

    /* Push content when sidebar is fixed and visible */
    #page-content-wrapper {
        margin-left: 210px;
        width: calc(100% - 210px);
    }

    #wrapper.toggled #sidebar-wrapper {
        margin-left: -210px;
        /* Hide on toggle */
    }

    /* Pull content back when sidebar is hidden */
    #wrapper.toggled #page-content-wrapper {
        margin-left: 0;
        width: 100%;
    }
}

.small-font {
    font-size: 0.75rem !important;
}

/* Sticky Header for Finance Table */
.finance-table thead th {
    position: sticky;
    top: 0;
    background-color: #fff;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Editable Input for Expenses */
.editable-input {
    border-bottom: 1px dashed #ced4da !important;
    background-color: #f8f9fa !important;
    padding: 2px 4px;
    transition: all 0.2s;
    cursor: text;
}

.editable-input:focus {
    border-bottom: 1px solid var(--primary-color) !important;
    background-color: #fff !important;
    box-shadow: none;
}

/* Custom Truncation for Finance Columns */
.col-truncate {
    max-width: 140px;
    /* Reduced for smaller sidebar/screens */
    width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

/* Smaller Currency Symbol */
.currency-small {
    font-size: 0.75em;
    opacity: 0.7;
    margin-right: 2px;
}