/* ============================================
   Virtual CFO - Executive Dashboard Styles
   Design inspired by Microsoft Fabric / Power BI
   ============================================ */

/* ---- KPI Card Grid ---- */
.cfo-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* ---- KPI Card ---- */
.kpi-card {
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--md-sys-color-outline-variant);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.kpi-card.trend-up {
    border-left: 4px solid #22c55e;
}

.kpi-card.trend-down {
    border-left: 4px solid #ef4444;
}

.kpi-card.trend-flat {
    border-left: 4px solid var(--md-sys-color-outline);
}

.kpi-card-header {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
    font-weight: 500;
}

.kpi-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.kpi-card-delta {
    font-size: 0.85rem;
    font-weight: 600;
}

.kpi-card-delta.positive {
    color: #22c55e;
}

.kpi-card-delta.negative {
    color: #ef4444;
}

.kpi-card-subtitle {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
}

/* ---- Dashboard Sections ---- */
.cfo-section {
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.cfo-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.cfo-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    margin: 0;
}

.cfo-section-subtitle {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
}

/* ---- Dashboard Grid Layout ---- */
.cfo-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1200px) {
    .cfo-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.cfo-dashboard-grid-full {
    grid-column: 1 / -1;
}

/* ---- Scenario Simulator Sliders ---- */
.cfo-scenario-layout {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
}

.cfo-slider-group {
    margin-bottom: 16px;
}

.cfo-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.cfo-slider-name {
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.cfo-slider-value {
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.cfo-slider-input {
    width: 100%;
}

/* ---- Results Table ---- */
.cfo-results-table {
    width: 100%;
    border-collapse: collapse;
}

.cfo-results-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface-variant);
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--md-sys-color-outline-variant);
    font-weight: 600;
}

.cfo-results-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    font-size: 0.9rem;
}

.cfo-results-table tr.highlight {
    background: var(--md-sys-color-primary-container);
    font-weight: 600;
}

/* ---- Delta Indicators ---- */
.delta-positive {
    color: #22c55e;
    font-weight: 600;
}

.delta-negative {
    color: #ef4444;
    font-weight: 600;
}

.delta-neutral {
    color: var(--md-sys-color-on-surface-variant);
}

/* ---- Insight Cards ---- */
.cfo-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.cfo-insight-card {
    background: var(--md-sys-color-surface-container-low);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.cfo-insight-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
    font-weight: 600;
}

.cfo-insight-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}

.cfo-insight-delta {
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ---- Opportunity Cards ---- */
.cfo-opportunity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cfo-opportunity-card {
    background: var(--md-sys-color-surface-container-low);
    border-radius: 10px;
    padding: 16px 20px;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--md-sys-color-outline-variant);
    transition: box-shadow 0.15s ease;
    cursor: pointer;
}

.cfo-opportunity-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.cfo-opportunity-rank {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

.cfo-opportunity-rank.top {
    background: #f59e0b;
}

.cfo-opportunity-rank.good {
    background: var(--md-sys-color-primary);
}

.cfo-opportunity-info {
    min-width: 0;
}

.cfo-opportunity-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 2px;
}

.cfo-opportunity-detail {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
}

.cfo-opportunity-impact {
    font-weight: 700;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.cfo-opportunity-meta {
    display: flex;
    gap: 12px;
    align-items: center;
}

.cfo-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.cfo-badge-low {
    background: #dcfce7;
    color: #16a34a;
}

.cfo-badge-medium {
    background: #fef9c3;
    color: #ca8a04;
}

.cfo-badge-high {
    background: #fecdd3;
    color: #dc2626;
}

/* ---- Goal Seeking Result ---- */
.cfo-goal-result {
    background: var(--md-sys-color-primary-container);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--md-sys-color-primary);
}

.cfo-goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.cfo-goal-probability {
    font-size: 2rem;
    font-weight: 700;
    color: var(--md-sys-color-primary);
}

.cfo-goal-variable-bar {
    display: grid;
    grid-template-columns: 140px 1fr 80px 90px;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 0.85rem;
}

.cfo-goal-variable-name {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.cfo-goal-variable-value {
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.cfo-goal-variable-impact {
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.cfo-progress-bar-bg {
    height: 8px;
    background: var(--md-sys-color-surface-container-highest);
    border-radius: 4px;
    overflow: hidden;
}

.cfo-progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--md-sys-color-primary);
    transition: width 0.5s ease;
}

/* ---- Action Plan Progress ---- */
.cfo-action-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cfo-action-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--md-sys-color-surface-container-highest);
    border-radius: 3px;
    overflow: hidden;
}

.cfo-action-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.cfo-action-progress-fill.on-track {
    background: #22c55e;
}

.cfo-action-progress-fill.delayed {
    background: #f59e0b;
}

.cfo-action-progress-fill.completed {
    background: var(--md-sys-color-primary);
}

/* ---- Tab Navigation (matching treasury style) ---- */
.cfo-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--md-sys-color-outline-variant);
    margin-bottom: 24px;
}

.cfo-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.cfo-tab:hover {
    color: var(--md-sys-color-on-surface);
}

.cfo-tab.active {
    color: var(--md-sys-color-primary);
    border-bottom-color: var(--md-sys-color-primary);
    font-weight: 600;
}

/* ---- Filter Bar ---- */
.cfo-filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.cfo-filter-bar label {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
}

/* ---- Export/Import Buttons ---- */
.cfo-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ---- Dark Mode Overrides ---- */
[data-theme="dark"] .kpi-card {
    background: var(--md-sys-color-surface-container-high);
}

[data-theme="dark"] .cfo-section {
    background: var(--md-sys-color-surface-container-high);
}

[data-theme="dark"] .cfo-goal-result {
    background: rgba(var(--md-sys-color-primary-rgb, 59, 130, 246), 0.12);
}
