:root {
    --primary-color: 210 79% 46%; /* #2563eb */
    --secondary-color: 217 19% 35%; /* #475569 */
    --success-color: 142 76% 36%; /* #16a34a */
    --warning-color: 43 96% 56%; /* #eab308 */
    --info-color: 199 89% 48%; /* #0ea5e9 */
    --background: 210 11% 98%; /* #f8fafc */
    --surface: 0 0% 100%; /* #ffffff */
    --border: 214 13% 91%; /* #e2e8f0 */
    --text-primary: 222 84% 5%; /* #0f172a */
    --text-secondary: 215 16% 47%; /* #64748b */
    --text-muted: 215 16% 47%; /* #64748b - same as secondary in light mode */
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
    --primary-color: 210 79% 56%; /* #3b82f6 */
    --secondary-color: 217 19% 45%; /* #64748b */
    --success-color: 142 76% 46%; /* #22c55e */
    --warning-color: 43 96% 66%; /* #fbbf24 */
    --info-color: 199 89% 58%; /* #38bdf8 */
    --background: 222 84% 5%; /* #0f172a */
    --surface: 215 28% 17%; /* #1e293b */
    --border: 215 14% 34%; /* #475569 */
    --text-primary: 210 40% 95%; /* #e2e8f0 - slightly less bright than pure white */
    --text-secondary: 215 20% 70%; /* #a1a9b8 - lighter for better visibility */
    --text-muted: 215 20% 75%; /* #a8b3c7 - lighter for better visibility */
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--text-primary));
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

/* Container optimizations for mobile */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

@media (max-width: 480px) {
    .container-fluid {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

/* Header Styles */
.dashboard-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%);
    color: white;
    border-radius: 0.75rem;
    margin: 1rem 0;
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-lg);
}

/* Dark mode header - even darker and more modern */
[data-theme="dark"] .dashboard-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

.dashboard-header h1 {
    font-weight: 600;
    display: flex;
    align-items: center;
}

.dashboard-header .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

.dashboard-header .btn {
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.dashboard-header .btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Tab Navigation */
.dashboard-tabs {
    border-bottom: 2px solid hsl(var(--border));
    margin-bottom: 2rem;
}

.dashboard-tabs .nav-link {
    border: none;
    border-radius: 0.5rem 0.5rem 0 0;
    padding: 1rem 1.5rem;
    font-weight: 500;
    color: hsl(var(--text-secondary));
    transition: all 0.3s ease;
    margin-right: 0.5rem;
}

.dashboard-tabs .nav-link:hover {
    background-color: hsl(var(--background));
    color: hsl(var(--primary-color));
}

.dashboard-tabs .nav-link.active {
    background-color: hsl(var(--primary-color));
    color: white;
    border-bottom: 2px solid hsl(var(--primary-color));
}

/* Card Styles */
.card {
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s ease;
    margin-bottom: 1.5rem;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    background-color: hsl(var(--surface));
    border-bottom: 1px solid hsl(var(--border));
    border-radius: 0.75rem 0.75rem 0 0 !important;
    padding: 1rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* Chart Card */
.chart-card {
    min-height: 600px;
}

.chart-card.main-chart {
    min-height: 950px;
}

.chart-card.metric-chart {
    min-height: 500px;
    max-height: 600px;
    overflow: hidden;
}

.chart-controls {
    background-color: hsl(var(--background));
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid hsl(var(--border));
}

/* Metric Cards */
.metric-card {
    background: linear-gradient(135deg, hsl(var(--surface)) 0%, hsl(var(--background)) 100%);
    border: 1px solid hsl(var(--border));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 0rem; /* Reduced bottom margin */
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    color: hsl(var(--text-primary));
}

.metric-card .card-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--text-secondary));
    margin-bottom: 0.5rem;
}

/* Form Styles */
.form-control {
    border: 1px solid hsl(var(--border));
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    border-color: hsl(var(--primary-color));
    box-shadow: 0 0 0 0.2rem hsla(var(--primary-color) / 0.25);
}

.form-label {
    font-weight: 500;
    color: hsl(var(--text-primary));
    margin-bottom: 0.5rem;
}

/* Button Styles */
.btn {
    border-radius: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background-color: hsl(var(--primary-color) / 0.9);
    border-color: hsl(var(--primary-color) / 0.9);
    transform: translateY(-1px);
}

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

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

.btn-danger {
    background-color: hsl(0 84% 60%); /* #ef4444 */
    border-color: hsl(0 84% 60%);
}

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

.table th {
    background-color: hsl(var(--background));
    border-bottom: 2px solid hsl(var(--border));
    font-weight: 600;
    color: hsl(var(--text-primary));
    padding: 1rem 0.75rem;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid hsl(var(--border));
}

.table-striped > tbody > tr:nth-of-type(even) > td {
    background-color: hsl(var(--background) / 0.5);
}

/* Status Indicators */
.status-good {
    color: hsl(var(--success-color));
    font-weight: 600;
}

.status-warning {
    color: hsl(var(--warning-color));
    font-weight: 600;
}

.status-bad {
    color: hsl(0 84% 60%);
    font-weight: 600;
}

/* Form Check Styles */
.form-check-input:checked {
    background-color: hsl(var(--primary-color));
    border-color: hsl(var(--primary-color));
}

.form-check-label {
    font-weight: 500;
    color: hsl(var(--text-primary));
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-header .col-md-4 {
        margin-top: 1rem;
        text-align: left !important;
    }

    .dashboard-tabs .nav-link {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .metric-card {
        margin-bottom: 0.5rem;
    }

    .chart-card {
        min-height: 400px;
    }

    .table-responsive {
        font-size: 0.875rem;
    }
}

/* Hamburger menu styles */
.mobile-menu-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 1.2rem;
    cursor: pointer;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: var(--card-bg);
    padding: 1rem;
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.mobile-menu-section {
    margin-bottom: 1.5rem;
}

.mobile-menu-section h3 {
    color: white;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-menu-item {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
    color: white;
    text-decoration: none;
    text-align: left;
    transition: all 0.2s ease;
}

.mobile-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
}

.mobile-menu-item.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Mobile optimizations - much more compact header */
@media (max-width: 576px) {
    /* Show hamburger menu */
    .mobile-menu-toggle {
        display: block;
    }

    /* Hide original buttons and tabs on mobile */
    .dashboard-header .col-md-4,
    .dashboard-tabs {
        display: none !important;
    }

    /* Much more compact header */
    .dashboard-header {
        padding: 0.5rem; /* Even smaller padding */
        margin: 0.1rem 0 0.25rem 0; /* Much smaller margins */
        position: relative;
    }

    .dashboard-header h1 {
        font-size: 1rem; /* Smaller font size */
        margin-bottom: 0.1rem; /* Smaller margin */
        padding-right: 3rem; /* Space for hamburger */
    }

    .dashboard-header h1 i {
        font-size: 0.9rem; /* Smaller icon */
        margin-right: 0.4rem;
    }

    .dashboard-header p {
        font-size: 0.75rem; /* Smaller subtitle */
        margin-bottom: 0 !important;
    }

    /* Keep metric charts at good height */
    .chart-card.metric-chart {
        min-height: 400px;
        max-height: 450px;
        margin-bottom: 1rem;
    }

    /* Main chart section mobile styling - ensure it doesn't overlap */
    .main-chart-section {
        margin-bottom: 2rem !important;
        clear: both !important;
        position: relative;
        z-index: 1;
        overflow: hidden; /* Prevent overflow */
    }

    /* Main chart should fill card properly and have proper spacing */
    .chart-card.main-chart {
        height: auto; /* Auto height to follow content */
        min-height: auto; /* Remove fixed min-height */
        margin-bottom: 1rem !important; /* Reduce excessive spacing */
        clear: both; /* Ensure it clears floating elements */
        position: relative;
        z-index: 1;
    }

    /* Ensure main chart card body is properly sized */
    .main-chart .card-body {
        height: auto !important; /* Auto height to follow chart content */
        min-height: 330px !important; /* Increased minimum height for mobile to accommodate labels */
        overflow: hidden; /* Clip content to card boundaries */
        padding: 0.75rem !important; /* Padding to keep chart within bounds */
        position: relative;
    }

    /* Mobile-specific height override for main chart container */
    #trendsChart {
        height: 280px !important; /* Height for mobile with space for labels */
    }

    /* Reduce side margins for small charts to use mobile space better */
    .metric-chart .card-body {
        padding: 0.5rem 0.5rem; /* Ultra minimal horizontal padding for maximum chart space */
    }

    .metric-chart .card-header {
        padding: 0.75rem 0.1rem; /* Ultra minimal horizontal padding */
    }

    /* Optimize chart width for mobile with compact Y-axis */
    .metric-chart canvas {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Better mobile container spacing */
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Remove any top margin from body to eliminate header space */
    body {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* Y-axis labels are now visible on mobile with compact styling */

    /* Force proper spacing between sections */
    .row:has(.main-chart) {
        margin-top: 1rem !important; /* Reduce gap above main chart */
        clear: both;
    }

    /* Ensure metric cards don't overlap main chart */
    .metric-card {
        position: relative;
        z-index: 1;
    }

    .main-chart {
        position: relative;
        z-index: 2;
    }
}

/* Chart Container - only apply to metric charts, not main chart */
.metric-chart canvas {
    max-height: 400px;
}

/* Main chart card styling to ensure proper clipping */
.main-chart.card {
    overflow: hidden; /* Clip all content to card boundaries */
    border-radius: 0.375rem; /* Ensure proper border radius */
}

/* Main chart container responsive styling */
.main-chart-container {
    height: 280px; /* Increased mobile height to accommodate labels */
    margin-bottom: 0.5rem; /* Space for bottom labels */
    position: relative;
    overflow: hidden; /* Ensure chart stays within bounds */
}

/* Ensure chart canvas respects card boundaries */
.main-chart-container canvas {
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Desktop main chart styling - ensure it fills container properly */
@media (min-width: 577px) {
    .main-chart .card-body {
        height: 700px !important; /* Much taller height for desktop */
        min-height: 700px !important;
        padding: 1rem !important; /* Uniform padding for desktop */
        overflow: hidden; /* Ensure clipping on desktop too */
    }

    .main-chart-container {
        height: 650px; /* Much taller desktop height to fill container */
        margin-bottom: 1rem; /* Space for bottom labels */
    }

    #trendsChart {
        height: 650px !important; /* Much taller height for desktop to fill container */
    }
}

/* Mobile chart canvas optimizations */
@media (max-width: 576px) {
    /* Keep metric charts at good height - they were good before */
    .metric-chart canvas {
        max-height: 350px;
    }

    /* Ensure main chart fills the card properly */
    .main-chart canvas {
        width: 100% !important;
        height: auto !important;
        min-height: 350px; /* Minimum height for mobile visibility */
    }
}

/* Small chart containers - reduce bottom margin and whitespace */
.metric-chart {
    padding-bottom: 0 !important;
}

.metric-chart canvas {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    display: block !important;
    height: 100% !important;
}

.metric-chart .card-body {
    padding-bottom: 0.25rem !important;
    height: calc(100% - 60px); /* Account for header */
    overflow: hidden;
}

/* Remove extra spacing from chart containers */
.chart-container {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Main chart section styling */
.main-chart-section {
    clear: both;
    margin-top: 1rem; /* Reduce top margin */
    margin-bottom: 1rem; /* Reduce bottom margin */
}

/* Mobile spacing improvements */
@media (max-width: 576px) {
    /* Ensure metric cards don't float over main chart */
    .metric-card {
        position: relative;
        z-index: 2; /* Higher z-index to stay above main chart */
        margin-bottom: 1rem;
        clear: both; /* Ensure proper flow */
    }

    /* Add spacing after metric card rows but not excessive */
    .row:has(.metric-card) {
        margin-bottom: 1rem !important; /* Normal spacing */
        clear: both;
        position: relative;
        z-index: 2;
    }

    /* Specific spacing for metric card rows */
    .row.mb-2:has(.metric-card) {
        margin-bottom: 0.5rem !important; /* Small gap between first and second row */
        clear: both;
        position: relative;
        z-index: 2;
    }

    .row.mb-4:has(.metric-card) {
        margin-bottom: 1.5rem !important; /* Moderate gap after second row */
        clear: both;
        position: relative;
        z-index: 2;
    }

    /* Individual metric charts section - ensure proper spacing */
    .row:has(.metric-chart) {
        margin-top: 1rem !important; /* Reduce gap above small charts */
        clear: both;
    }

    /* Ensure metric chart cards use full available width */
    .metric-chart {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Main chart specific mobile styling */
    .main-chart {
        position: relative !important;
        z-index: 2 !important;
    }
}

/* Loading and Empty States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid hsl(var(--border));
    border-radius: 50%;
    border-top-color: hsl(var(--primary-color));
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Alert Styles */
.alert {
    border-radius: 0.5rem;
    border: none;
    padding: 1rem 1.5rem;
}

.alert-success {
    background-color: hsl(var(--success-color) / 0.1);
    color: hsl(var(--success-color));
    border-left: 4px solid hsl(var(--success-color));
}

.alert-warning {
    background-color: hsl(var(--warning-color) / 0.1);
    color: hsl(var(--warning-color));
    border-left: 4px solid hsl(var(--warning-color));
}

.alert-danger {
    background-color: hsl(0 84% 60% / 0.1);
    color: hsl(0 84% 60%);
    border-left: 4px solid hsl(0 84% 60%);
}

/* Utilities */
.text-primary {
    color: hsl(var(--primary-color)) !important;
}

.text-success {
    color: hsl(var(--success-color)) !important;
}

.text-warning {
    color: hsl(var(--warning-color)) !important;
}

.text-info {
    color: hsl(var(--info-color)) !important;
}

.text-purple {
    color: rgb(168, 85, 247) !important;
}

.text-muted {
    color: hsl(var(--text-muted)) !important;
}

/* Chart styling for dark mode */
[data-theme="dark"] .card {
    background-color: hsl(var(--surface));
}

[data-theme="dark"] canvas {
    background-color: hsl(var(--surface)) !important;
}

/* Ensure chart containers have proper background */
[data-theme="dark"] .chart-card {
    background-color: hsl(var(--surface));
}

[data-theme="dark"] .chart-card .card-body {
    background-color: hsl(var(--surface));
}

/* Fix headers in dark mode */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .card-title {
    color: hsl(var(--text-primary)) !important;
}

/* Data Manager dark mode fixes */
[data-theme="dark"] .table {
    color: hsl(var(--text-primary));
    background-color: hsl(var(--surface));
}

[data-theme="dark"] .table th {
    color: hsl(var(--text-primary));
    background-color: hsl(var(--background));
    border-color: hsl(var(--border));
}

[data-theme="dark"] .table td {
    color: hsl(var(--text-primary));
    border-color: hsl(var(--border));
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(even) > td {
    background-color: hsl(var(--background));
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: hsl(var(--surface));
}

[data-theme="dark"] .form-control {
    background-color: hsl(var(--surface));
    border-color: hsl(var(--border));
    color: hsl(var(--text-primary));
}

/* Predictive Analytics dark mode fixes */
[data-theme="dark"] .analytics-container {
    background: linear-gradient(135deg, hsl(var(--background)) 0%, hsl(var(--surface)) 100%);
}

[data-theme="dark"] .analytics-status .card {
    background-color: hsl(var(--surface));
    border-color: hsl(var(--border));
}

[data-theme="dark"] .chart-container {
    background-color: hsl(var(--surface));
}

/* Fix card data values in dark mode - keep colors visible */
[data-theme="dark"] .text-primary {
    color: #60a5fa !important; /* Light blue for primary values */
}

[data-theme="dark"] .text-success {
    color: #4ade80 !important; /* Light green for positive values */
}

[data-theme="dark"] .text-danger {
    color: #f87171 !important; /* Light red for negative values */
}

[data-theme="dark"] .text-warning {
    color: #fbbf24 !important; /* Light yellow for warning values */
}

[data-theme="dark"] .text-info {
    color: #38bdf8 !important; /* Light cyan for info values */
}

[data-theme="dark"] .text-muted {
    color: hsl(var(--text-secondary)) !important;
}

/* Fix prediction table in dark mode */
[data-theme="dark"] #predictive-analytics .table,
[data-theme="dark"] #predictive-analytics .table-responsive .table {
    color: hsl(var(--text-primary)) !important;
    background-color: hsl(var(--surface)) !important;
}

[data-theme="dark"] #predictive-analytics .table th,
[data-theme="dark"] #predictive-analytics .table-responsive .table th {
    color: hsl(var(--text-primary)) !important;
    background-color: hsl(var(--background)) !important;
    border-color: hsl(var(--border)) !important;
}

[data-theme="dark"] #predictive-analytics .table td,
[data-theme="dark"] #predictive-analytics .table-responsive .table td {
    color: hsl(var(--text-primary)) !important;
    background-color: hsl(var(--surface)) !important;
    border-color: hsl(var(--border)) !important;
}

[data-theme="dark"] #predictive-analytics .table-primary > td,
[data-theme="dark"] #predictive-analytics .table-responsive .table-primary > td {
    background-color: hsl(var(--primary) / 0.2) !important;
    border-color: hsl(var(--border)) !important;
}

[data-theme="dark"] #predictive-analytics .table tbody tr,
[data-theme="dark"] #predictive-analytics .table-responsive .table tbody tr {
    background-color: hsl(var(--surface)) !important;
}

[data-theme="dark"] .form-control:focus {
    background-color: hsl(var(--surface));
    border-color: hsl(var(--primary-color));
    color: hsl(var(--text-primary));
    box-shadow: 0 0 0 0.2rem hsla(var(--primary-color) / 0.25);
}

[data-theme="dark"] .form-control::placeholder {
    color: hsl(var(--text-secondary));
}

[data-theme="dark"] .form-select {
    background-color: hsl(var(--surface));
    border-color: hsl(var(--border));
    color: hsl(var(--text-primary));
}

[data-theme="dark"] .form-label {
    color: hsl(var(--text-primary));
}

/* Additional dark mode improvements */
[data-theme="dark"] .btn-outline-primary {
    color: hsl(var(--primary-color));
    border-color: hsl(var(--primary-color));
}

[data-theme="dark"] .btn-outline-primary:hover {
    background-color: hsl(var(--primary-color));
    color: hsl(var(--background));
}

[data-theme="dark"] .btn-outline-secondary {
    color: hsl(var(--text-secondary));
    border-color: hsl(var(--border));
}

[data-theme="dark"] .btn-outline-danger {
    color: hsl(0 84% 60%);
    border-color: hsl(0 84% 60%);
}

[data-theme="dark"] .alert {
    background-color: hsl(var(--surface));
    border-color: hsl(var(--border));
    color: hsl(var(--text-primary));
}

[data-theme="dark"] .bg-light {
    background-color: hsl(var(--surface)) !important;
    color: hsl(var(--text-primary)) !important;
}

/* Fix any remaining dark text issues */
[data-theme="dark"] .text-dark {
    color: hsl(var(--text-primary)) !important;
}

/* Fix header subtitle text in dark mode */
[data-theme="dark"] .dashboard-header .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Fix dropdown menu text in dark mode */
[data-theme="dark"] .dropdown-menu {
    background-color: hsl(var(--surface));
    border-color: hsl(var(--border));
}

[data-theme="dark"] .dropdown-header {
    color: hsl(var(--text-primary)) !important;
}

[data-theme="dark"] .dropdown-item {
    color: hsl(var(--text-primary));
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: hsl(var(--background));
    color: hsl(var(--text-primary));
}

[data-theme="dark"] .dropdown-divider {
    border-color: hsl(var(--border));
}

[data-theme="dark"] small {
    color: hsl(var(--text-muted)) !important;
}

.bg-light {
    background-color: hsl(var(--background)) !important;
}

/* Formula Reference Styles */
.formula-group {
    background-color: hsl(var(--background) / 0.5);
    border-radius: 0.5rem;
    padding: 0.75rem;
    border: 1px solid hsl(var(--border));
}

.formula-item {
    padding: 0.5rem;
    border-radius: 0.25rem;
    background-color: hsl(var(--surface));
    border: 1px solid hsl(var(--border) / 0.5);
    transition: all 0.2s ease;
}

.formula-item:hover {
    background-color: hsl(var(--background));
    border-color: hsl(var(--primary-color) / 0.3);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.formula-item strong {
    color: hsl(var(--text-primary));
    font-weight: 600;
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.95rem;
}

.formula-item code {
    background-color: hsl(var(--primary-color) / 0.1);
    color: hsl(var(--primary-color));
    padding: 0.2rem 0.4rem;
    border-radius: 0.2rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    font-weight: 500;
    display: block;
    margin: 0.15rem 0;
    border: 1px solid hsl(var(--primary-color) / 0.2);
}

.formula-item small {
    color: hsl(var(--text-secondary));
    font-style: italic;
    line-height: 1.3;
    font-size: 0.8rem;
}

/* Formula section headers */
.formula-group h6 {
    margin-bottom: 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid hsl(var(--border));
    font-size: 1rem;
}

/* Special styling for the warning alert */
.alert-info .formula-item {
    background-color: transparent;
    border: none;
    padding: 0.25rem 0;
}

.alert-info .formula-item:hover {
    background-color: transparent;
    transform: none;
    box-shadow: none;
}

.alert-info code {
    background-color: hsl(var(--info-color) / 0.1);
    color: hsl(var(--info-color));
    border-color: hsl(var(--info-color) / 0.2);
}

/* Enhanced formula explanations */
.formula-item strong {
    font-size: 1rem;
    color: hsl(var(--primary-color));
}

.formula-item small strong {
    color: hsl(var(--text-primary));
    font-weight: 600;
}

/* Action guide styling */
.formula-item small {
    line-height: 1.5;
}

.formula-item ul {
    margin: 0.5rem 0;
    padding-left: 1rem;
}

.formula-item li {
    margin-bottom: 0.25rem;
}

/* Pro tips section */
.alert-info .row .col-md-4 {
    margin-bottom: 1rem;
}

.alert-info .row .col-md-4 strong {
    color: hsl(var(--info-color));
    display: block;
    margin-bottom: 0.25rem;
}

/* Color coding for different metric types */
.text-success .formula-group {
    border-left: 4px solid hsl(var(--success-color));
}

.text-warning .formula-group {
    border-left: 4px solid hsl(var(--warning-color));
}

.text-danger .formula-group {
    border-left: 4px solid hsl(0 84% 60%);
}

.text-info .formula-group {
    border-left: 4px solid hsl(var(--info-color));
}

.text-primary .formula-group {
    border-left: 4px solid hsl(var(--primary-color));
}

/* Compact formulas tab styling */
#formulas .card-body {
    padding: 0.5rem;
}

#formulas .card-header {
    padding: 0.5rem 1rem;
}

#formulas .formula-group {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

#formulas .formula-item {
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.25rem;
}

#formulas .formula-item strong {
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
}

#formulas .formula-item code {
    font-size: 0.75rem;
    padding: 0.15rem 0.3rem;
    margin: 0.1rem 0;
}

#formulas .formula-item small {
    font-size: 0.75rem;
    line-height: 1.2;
}

#formulas h6 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.2rem;
}
