/* Modern Color Palette & Variables with Glassmorphism */
:root {
    /* Primary & Secondary Colors */
    --primary-color: #325199;
    --primary-hover: #243c73;
    --secondary-color: #007CFF;
    --secondary-hover: #0062cc;

    /* Backgrounds (Frosted Glass & Grey tones) */
    --main-bg-color: #f0f2f5;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.45);
    --glass-blur: blur(12px);
    --sidebar-bg-color: rgba(255, 255, 255, 0.75);
    --card-bg-color: rgba(255, 255, 255, 0.65);

    /* Text Colors */
    --text-main: #333333;
    --text-muted: #666666;
    --text-light: #ffffff;

    /* Status Colors (Pastel/Soft but defined) */
    --success-color: #00b588;
    --warning-color: #ff9f1c;
    --danger-color: #ea4335;
    --info-color: #007CFF;

    /* Spacing & Borders */
    --border-radius: 16px;
    --card-shadow: 0 8px 32px 0 rgba(50, 81, 153, 0.05);
}

/* Base Styles with Fixed Radial Gradient */
body {
    background: radial-gradient(at 0% 0%, rgba(50, 81, 153, 0.05) 0px, transparent 50%),
                radial-gradient(at 50% 0%, rgba(0, 124, 255, 0.04) 0px, transparent 50%),
                radial-gradient(at 100% 0%, rgba(240, 242, 245, 1) 0px, transparent 50%);
    background-color: var(--main-bg-color);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Red Hat Text', sans-serif;
    font-weight: 400;
    overflow-x: hidden;
}

/* Typography Rules */
/* Titles: Medium */
h1, h2, h3, h4, h5, h6, .modal-title, .fw-bold, .font-weight-bold, .text-main {
    font-weight: 500 !important;
}

/* Major Highlights: Semi-Bold */
.h1, .h2, .h3, .font-weight-bold.text-gray-800, .avatar-circle, .badge, .btn, .nav-link, .text-xs.font-weight-bold {
    font-weight: 600 !important;
}

/* Table items & small notes: Light */
table, .table, td, .finance-table, .small-font, .client-name, .col-truncate, .text-muted.small {
    font-weight: 300 !important;
}
.table th {
    font-weight: 500 !important; /* Headers are Medium for legibility */
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(50, 81, 153, 0.15);
    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;
    width: 210px;
    background: var(--sidebar-bg-color);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    margin-left: -210px;
    transition: margin 0.3s ease-in-out;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.03);
    z-index: 1000;
    flex-shrink: 0;
    min-width: 210px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    overflow: hidden;
}

#sidebar-wrapper .sidebar-heading {
    padding: 1.5rem 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    position: relative;
    flex-shrink: 0;
}

#sidebar-wrapper .list-group {
    padding: 0.5rem;
    gap: 0.25rem;
    flex-grow: 1;
    overflow-y: auto;
    margin: 0;
}

/* Custom Scrollbar for Menu */
#sidebar-wrapper .list-group::-webkit-scrollbar {
    width: 4px;
}
#sidebar-wrapper .list-group::-webkit-scrollbar-thumb {
    background: rgba(50, 81, 153, 0.1);
    border-radius: 4px;
}

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

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

#sidebar-wrapper .list-group-item:hover {
    background-color: rgba(0, 124, 255, 0.05);
    color: var(--secondary-color);
}

#sidebar-wrapper .list-group-item.active {
    background-color: var(--primary-color) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(50, 81, 153, 0.2);
}

/* User Footer Section */
.sidebar-footer {
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.02);
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.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-size: 1rem;
    box-shadow: 0 4px 10px rgba(50, 81, 153, 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;
    padding: 0.6rem 0.9rem 0.6rem 0.7rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--glass-border);
    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;
    }
    #page-content-wrapper {
        margin-left: 210px;
        width: calc(100% - 210px);
    }
    #wrapper.toggled #sidebar-wrapper {
        margin-left: -210px;
    }
    #wrapper.toggled #page-content-wrapper {
        margin-left: 0;
        width: 100%;
    }
}

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

/* Frosted Glass Cards overriding standard card classes */
.card, .section-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--card-shadow) !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    overflow: hidden;
}

.card:hover, .section-card:hover {
    box-shadow: 0 12px 40px 0 rgba(50, 81, 153, 0.08) !important;
    border-color: rgba(50, 81, 153, 0.15) !important;
}

/* Modern Glass Modals */
.modal-content {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(50, 81, 153, 0.12);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* General Input Styling */
.form-control, .form-select {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    color: var(--text-main);
    transition: all 0.2s ease-in-out;
}

.form-control:focus, .form-select:focus {
    background: #fff;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 124, 255, 0.15);
}

/* Primary buttons style */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    border-radius: 10px;
    transition: all 0.2s ease-in-out;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: 0 4px 12px rgba(50, 81, 153, 0.25) !important;
}

.btn-secondary {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    border-radius: 10px;
}

.btn-secondary:hover {
    background-color: #5a6268 !important;
    border-color: #5a6268 !important;
}

.btn-warning {
    background-color: var(--warning-color) !important;
    border-color: var(--warning-color) !important;
    color: #fff !important;
    border-radius: 10px;
}

.btn-danger {
    background-color: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
    border-radius: 10px;
}

.btn-success {
    background-color: var(--success-color) !important;
    border-color: var(--success-color) !important;
    border-radius: 10px;
}

/* Transparent premium tables with glass backdrop */
.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table th {
    color: var(--primary-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    padding: 12px 8px;
}

.table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04) !important;
    padding: 12px 8px;
    color: #444;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 124, 255, 0.02) !important;
}

/* Sticky Header for Finance Table */
.finance-table thead th {
    position: sticky;
    top: 0;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Editable Input for Expenses in Grid */
.editable-input {
    border-bottom: 1px dashed rgba(0, 0, 0, 0.1) !important;
    background-color: rgba(0, 0, 0, 0.02) !important;
    padding: 2px 4px;
    transition: all 0.2s;
    cursor: text;
}

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

/* Custom Truncation for Finance Columns */
.col-truncate {
    max-width: 140px;
    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;
}

/* Alert Boxes style updates */
.alert {
    border-radius: 12px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}
.alert-success {
    background-color: rgba(0, 181, 136, 0.1);
    color: var(--success-color);
}
.alert-danger {
    background-color: rgba(234, 67, 53, 0.1);
    color: var(--danger-color);
}
.alert-warning {
    background-color: rgba(255, 159, 28, 0.1);
    color: var(--warning-color);
}
.alert-info {
    background-color: rgba(0, 124, 255, 0.1);
    color: var(--info-color);
}

/* Custom search box wrapper styling */
.search-box-wrapper {
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 2px 12px;
    transition: all 0.2s ease-in-out;
}
.search-box-wrapper:focus-within {
    border-color: var(--secondary-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 124, 255, 0.15);
}

/* Dropdown menu items active/hover adjustments */
.dropdown-menu {
    border: 1px solid var(--glass-border) !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: 0 10px 30px rgba(50, 81, 153, 0.08) !important;
    border-radius: 12px !important;
}

.dropdown-item {
    font-weight: 300 !important;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: rgba(0, 124, 255, 0.05) !important;
    color: var(--secondary-color) !important;
}

/* Bank accounts mini statement styling */
.delta-badge {
    font-size: 0.75rem;
    font-weight: 600 !important;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.delta-positive {
    background-color: rgba(0, 181, 136, 0.1);
    color: var(--success-color);
}
.delta-negative {
    background-color: rgba(234, 67, 53, 0.1);
    color: var(--danger-color);
}
.delta-neutral {
    background-color: rgba(108, 117, 125, 0.1);
    color: #6c757d;
}
.mini-extrato-container {
    max-height: 250px;
    overflow-y: auto;
}