/* assets/css/app.css */
:root {
    /* Variables Default (Financial Dark Premium) */
    --bg-body: #0a0e17;
    --bg-gradient: radial-gradient(circle at 10% 20%, rgb(20, 30, 60) 0%, rgb(10, 14, 23) 90%);

    /* Glass Components - High Contrast */
    --glass-bg: rgba(30, 35, 55, 0.75);
    /* Darker, more opaque */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

    /* Typography - Pure White for readability */
    --text-main: #ffffff;
    --text-muted: #cbd5e0;
    /* Lighter for better contrast */

    /* Accents */
    --primary-color: #3b82f6;
    /* Modern Blue */
    --sidebar-width: 280px;
    --card-radius: 16px;
}

/* Light Theme - Fully readable now */
[data-theme="light"] {
    --bg-body: #f4f7fa;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.95);
    /* Opaque white */
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --text-main: #1a202c;
    /* Dark Text */
    --text-muted: #4a5568;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    background: var(--bg-body);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    /* Parallax feel */
    background-size: cover;
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
}

/* Glassmorphism Cards - Redefined */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--card-radius);
    color: var(--text-main);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .glass-card-hover:hover {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Inputs - High Visibility */
/* Inputs - High Visibility */
.form-control,
.form-select,
.input-group-text,
.glass-input-group {
    background-color: rgba(15, 20, 35, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: var(--text-main) !important;
    backdrop-filter: none;
    border-radius: 8px;
}

/* Glass Wrapper specific layout */
.glass-input-group {
    display: flex !important;
    align-items: center !important;
    padding: 0;
    overflow: hidden;
    /* Ensure children don't bleed */
}

/* Remove default styles from children of glass-input-group to make them seamless */
.glass-input-group .form-control,
.glass-input-group .input-group-text {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin-bottom: 0 !important;
    /* Fix potential margins */
}

/* Focus state for the wrapper */
.form-control:focus,
.form-select:focus,
.glass-input-group:focus-within {
    background-color: rgba(20, 25, 45, 0.9) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
    color: var(--text-main) !important;
}

/* Placeholders */
.form-control::placeholder {
    color: rgba(255, 255, 255, 0.4) !important;
}

[data-theme="light"] .form-control,
[data-theme="light"] .glass-input-group,
[data-theme="light"] .form-select,
[data-theme="light"] .input-group-text {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #2d3748 !important;
    /* Dark text in inputs */
}

[data-theme="light"] .form-control::placeholder {
    color: #a0aec0 !important;
}

/* Labels */
.form-label {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

/* Tables */
.table {
    color: var(--text-main);
    --bs-table-bg: transparent;
}

.table td,
.table th {
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem;
    vertical-align: middle;
    color: var(--text-main) !important;
    /* Force text color */
}

.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom-width: 2px;
}

/* Sidebar - Adaptive Theme */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    transition: transform 0.3s ease;
    background: rgba(10, 15, 30, 0.95);
    /* Default Dark */
    backdrop-filter: blur(20px);
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
    color: #ffffff;
    /* Default Dark Text */
}

/* Light Theme Sidebar Override */
[data-theme="light"] .sidebar {
    background: rgba(255, 255, 255, 0.95) !important;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.05);
    color: var(--text-main) !important;
    /* Dark Text */
}

/* Sidebar Text Colors - Default Dark */
.sidebar .nav-link,
.sidebar .brand-section h5,
.sidebar i,
.sidebar small {
    color: rgba(255, 255, 255, 0.9);
}

.sidebar .text-muted-custom,
.sidebar .nav-section-title {
    color: rgba(255, 255, 255, 0.5);
}

/* Sidebar Text Colors - Light Theme Override */
[data-theme="light"] .sidebar .nav-link,
[data-theme="light"] .sidebar .brand-section h5,
[data-theme="light"] .sidebar i {
    color: var(--text-main) !important;
}

[data-theme="light"] .sidebar .text-muted-custom,
[data-theme="light"] .sidebar .nav-section-title,
[data-theme="light"] .sidebar small {
    color: var(--text-muted) !important;
}

[data-theme="light"] .sidebar .brand-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .sidebar .nav-link:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary-color) !important;
}

[data-theme="light"] .sidebar .nav-link:hover i {
    color: var(--primary-color) !important;
}

/* Shared Sidebar Styles */
.sidebar .nav-link {
    /* Base styles handled above, keeping transition/layout */
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar .nav-link.active {
    background: linear-gradient(90deg, #3b82f6 0%, rgba(59, 130, 246, 0.1) 100%);
    color: #ffffff !important;
    border: 1px solid rgba(59, 130, 246, 0.5);
}

/* Active State in Light Mode */
[data-theme="light"] .sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    color: var(--primary-color) !important;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

[data-theme="light"] .sidebar .nav-link.active i {
    color: var(--primary-color) !important;
}

.sidebar .brand-section {
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1070;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

/* Nav Links Modern */
.nav-section-title {
    color: var(--primary-color);
    font-size: 0.75rem;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 0.8rem;
    margin-top: 0.5rem;
    padding-left: 1rem;
    display: block;
    opacity: 0.8;
}

.nav-link {
    color: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    margin-bottom: 5px;
    padding: 0.8rem 1rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
}

.nav-link i {
    font-size: 1.1rem;
    margin-right: 12px;
    transition: transform 0.3s;
    width: 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding-left: 1.25rem;
    /* Slide effect */
}

.nav-link:hover i {
    color: var(--primary-color);
    transform: scale(1.1);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(13, 110, 253, 0.2) 0%, rgba(13, 110, 253, 0.05) 100%);
    color: #fff;
    border: 1px solid rgba(13, 110, 253, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.nav-link.active i {
    color: #4facfe;
    /* Lighter blue for active icon */
}

/* Utilities */
.no-arrow::after {
    display: none !important;
}

.text-main {
    color: var(--text-main) !important;
}

.text-muted,
.text-muted-custom {
    color: var(--text-muted) !important;
}

.hover-white:hover {
    color: #fff !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

/* Dropdown Items Contrast Fix */
.dropdown-item {
    color: var(--text-main);
    transition: all 0.2s ease;
    border-radius: 8px;
    margin-bottom: 2px;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: rgba(255, 255, 255, 0.1);
    /* Subtle glass hover */
    color: #ffffff !important;
}

[data-theme="light"] .dropdown-item {
    color: #2d3748;
}

[data-theme="light"] .dropdown-item:hover,
[data-theme="light"] .dropdown-item:focus {
    background-color: #f7fafc;
    color: var(--primary-color) !important;
}

/* Modal Improvements */
.glass-modal .modal-content {
    background: rgba(20, 25, 40, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    color: var(--text-main);
}

.glass-modal .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
}

.glass-modal .modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
}

.glass-modal .modal-title {
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
}

.glass-modal .btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Modal Light Theme Overrides */
[data-theme="light"] .glass-modal .modal-content {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    color: var(--text-main);
}

[data-theme="light"] .glass-modal .modal-header,
[data-theme="light"] .glass-modal .modal-footer {
    border-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .glass-modal .btn-close-white {
    filter: none;
}

/* Tags Input (Select Multiple) Styling */
.form-select[multiple] {
    height: auto;
    min-height: 140px;
    padding: 0;
    overflow-y: auto;
    background-color: rgba(10, 15, 30, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.form-select[multiple] option {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.2s;
}

.form-select[multiple] option:hover {
    background-color: rgba(255, 255, 255, 0.05);
    padding-left: 20px;
}

.form-select[multiple] option:checked {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
    font-weight: 600;
}

/* Tags in Light Theme */
[data-theme="light"] .form-select[multiple] {
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

[data-theme="light"] .form-select[multiple] option {
    color: #4a5568;
    border-bottom: 1px solid #edf2f7;
}

[data-theme="light"] .form-select[multiple] option:hover {
    background-color: #edf2f7;
    color: #2d3748;
}

[data-theme="light"] .form-select[multiple] option:checked {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Fix Dropdown Z-Index Stacking Context */
.glass-card {
    /* Ensure z-index applies. Default is auto. */
    transform-style: preserve-3d;
    /* Sometimes helps */
}

/* When a dropdown inside requires attention, lift the whole card */
.glass-card:has(.show),
.glass-card:focus-within {
    z-index: 50;
    position: relative;
}