/* ===========================
   Dashboard Page Specific Styles
=========================== */

/* Dashboard Metric Card Custom Styles */
.dashboard-metric-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 0;
    padding: 15px;
    text-align: center;
    min-height: 120px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.dashboard-metric-card .card-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);                /* Dark text */
    margin-bottom: 5px;
}

.dashboard-metric-card .card-value {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--text-primary);
}

/* Specific Value Styling for Cards — muted shades to match dashboard metric style */
#income-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #369966;  /* Muted green */
}
#expenses-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #E54D42;  /* Muted reddish-orange */
}
#savings-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #D88D33;  /* Muted orange-brown */
}
#health-score {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--brand-purple-dark);  /* Purple for financial health */
}

/* Checklist Styling */
.allocation-checklist {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.allocation-checklist .d-flex.flex-wrap label {
    margin-right: 10px;
    color: var(--text-primary);
}
.allocation-checklist input[type="checkbox"] {
    margin-right: 5px;
    accent-color: var(--brand-purple-dark); /* Use primary purple color (#be4afc) for checkboxes */
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Row 1: Sankey 7col + Transactions 5col -- let Bootstrap handle widths naturally */

.dashboard-visualization-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 0;
    padding: 15px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.dashboard-visualization-card h6 {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.card-modern {
    background: var(--bg-primary);
    border-radius: 0;
    padding: 1rem;
    height: 350px;
    overflow: hidden;
    border: 1px solid var(--border-primary);
    width: 58.33%; /* 7/12 */
    transition: background-color 0.3s ease;
}

.stat-box {
    background: var(--bg-tertiary);
    padding: 0.5rem;
    border-radius: 0.5rem;
    width: 48%;
    margin-bottom: 0.5rem;
    transition: background-color 0.3s ease;
}

.vendor-pill {
    background-color: var(--bg-quaternary);
    padding: 0.25rem 0.75rem;
    border-radius: 0;
    display: inline-block;
    transition: background-color 0.3s ease;
}

/* Calendar button in header (primary style) */
.dashboard-calendar-btn {
    background-color: var(--brand-purple) !important;
    border: 1px solid var(--brand-purple) !important;
    color: #ffffff !important;
    padding: 0.45rem 1.4rem !important;
    white-space: nowrap;
    border-radius: 0;
    font-weight: 600 !important;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.dashboard-calendar-btn:hover {
    background-color: var(--brand-purple-hover) !important;
    border-color: var(--brand-purple-hover) !important;
}

/* Budget overview card (Row 2) - theme-aware for light/dark; fills available column height */
.dashboard-budget-overview-wrapper .card-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.dashboard-budget-overview-wrapper #dashboard-budget-burn-alerts {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.dashboard-budget-overview-wrapper #dashboard-budget-burn-alerts > .budget-overview-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    color: var(--text-primary);
}
.budget-overview-list {
    color: var(--text-primary);
}.budget-burn-row {
    margin-bottom: 10px;
}
.budget-burn-row:last-child {
    margin-bottom: 0;
}

.budget-burn-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    color: var(--text-primary);
}
.budget-burn-row-header .fw-bold,
.budget-burn-row-header span:first-child {
    color: var(--text-primary);
}

/* Budget pills: grey background + colored outline (match subcategory-expand-pill style) */
.budget-burn-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 0;
    white-space: nowrap;
    background-color: var(--bg-quaternary);
    border: 1px solid currentColor;
}
.budget-burn-badge--remaining {
    color: var(--success-green);
    border-color: var(--success-green);
}
.budget-burn-badge--over {
    color: var(--error-red);
    border-color: var(--error-red);
}

.budget-burn-spend-line {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Metric card delta/subtitle line */
.metric-card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===========================
   Mobile: dashboard section stacking order + spacing
   Order: 1. Metrics/checklist, 2. Sankey, 3. Transactions, 4. Budget, 5. Total Potential, 6. Income & Expenses Over Time
=========================== */
@media (max-width: 991px) {
    .dashboard-sections {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem;
    }
    /* Keep metric cards in 2x2 grid: force 50% width for col-6 (override global col rules) */
    .dashboard-section-metrics.row {
        gap: 0.5rem;
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
    }
    .dashboard-section-metrics > [class*="col-"]:not(.col-12) {
        flex: 0 0 calc(50% - 4px) !important;
        max-width: calc(50% - 4px) !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    /* Equal height for all four metric cards so the health card doesn’t break the 2x2 grid */
    .dashboard-section-metrics .dashboard-metric-card {
        height: 160px !important;
        min-height: 160px !important;
        display: flex !important;
        flex-direction: column !important;
        min-width: 0 !important;
    }
    .dashboard-section-metrics .dashboard-metric-card .card-body {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        overflow: visible !important;
        padding: 12px !important;
        min-width: 0 !important;
    }
    .dashboard-section-metrics .dashboard-metric-card .metric-card-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    /* Explicit 2x2 order on mobile: row1 Income, Expenses; row2 Savings, Financial Health */
    .dashboard-section-metrics > [class*="col-"]:nth-child(1) { order: 1 !important; }
    .dashboard-section-metrics > [class*="col-"]:nth-child(2) { order: 2 !important; }
    .dashboard-section-metrics > [class*="col-"]:nth-child(3) { order: 3 !important; }
    .dashboard-section-metrics > .dashboard-metric-col-health { order: 4 !important; }
    .dashboard-section-metrics > .col-12 { order: 5 !important; }
    .dashboard-section-metrics .col-6,
    .dashboard-section-metrics .col-12 {
        margin-bottom: 0;
    }
    /* Promote row2/row3 and budget wrapper to contents so section blocks become direct flex children of .dashboard-sections */
    .dashboard-section-row2.row {
        display: contents !important;
    }
    .dashboard-section-row3.row {
        display: contents !important;
    }
    .dashboard-section-total-budget-col {
        display: contents !important;
    }
    .dashboard-total-budget-inner {
        display: contents !important;
    }
    /* Global order 1–6 for mobile: Metrics, Sankey, Transactions, Budgets, Potential Savings, Income chart */
    .dashboard-section-metrics {
        order: 1 !important;
    }
    .dashboard-section-sankey {
        order: 2 !important;
    }
    .dashboard-section-transactions {
        order: 3 !important;
    }
    .dashboard-card-budget {
        order: 4 !important;
    }
    .dashboard-card-total-potential {
        order: 5 !important;
    }
    .dashboard-section-income-chart {
        order: 6 !important;
    }
}
