/* keyMetricsTrend.css - Editorial Financial Intelligence Design */

/* ===== DESIGN SYSTEM FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ===== CSS VARIABLES (Design System) ===== */
:root {
    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

    /* Neutrals */
    --text-primary: #1A1D29;
    --text-secondary: #4E5668;
    --text-tertiary: #878E9F;
    --surface: #FFFFFF;
    --bg: #FAFBFC;
    --border: #E5E9F0;
    --shadow: rgba(0, 0, 0, 0.04);

    /* Contextual Colors */
    --positive: #0A6E4E;
    --negative: #C7383E;
    --warning: #D97706;
    --neutral: #3B5A9D;
}

/* ===== MAIN CONTAINER ===== */
.key-metrics-trend-container {
    padding: 0;
    background: var(--bg);
    font-family: var(--font-body);
}

/* ===== HEADER ===== */
.key-metrics-trend-header {
    background: linear-gradient(to bottom, #FFFFFF 0%, #FAFAF9 100%);
    border-bottom: 1px solid var(--border);
    padding: 2rem 3rem 1.5rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.key-metrics-trend-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    margin: 0;
}

/* ===== HERO BANNER (Dark Gradient) ===== */
.key-metrics-hero {
    background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
    padding: 2.5rem 3rem;
    margin: 0;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}

.hero-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 3rem;
}

.hero-main {
    flex: 0 0 auto;
}

.hero-label {
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.hero-value {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #FFFFFF;
    line-height: 1;
    margin-bottom: 0.75rem;
}

.hero-growth-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
}

.hero-growth-indicator.positive {
    background: rgba(16, 185, 129, 0.15);
    color: #6EE7B7;
}

.hero-growth-indicator.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
}

.hero-growth-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
}

.hero-growth-icon svg {
    width: 100%;
    height: 100%;
}

.hero-stats {
    display: flex;
    gap: 3rem;
    flex: 1;
    justify-content: flex-end;
}

.hero-stat {
    text-align: right;
}

.hero-stat-label {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}

.hero-stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #FFFFFF;
    line-height: 1.2;
}

/* ===== TREND CONTROLS PANEL ===== */
.trend-controls-panel {
    display: flex;
    gap: 2rem;
    margin: 2rem 3rem;
    padding: 1.75rem 2rem;
    background: var(--surface);
    border-radius: 12px;
    flex-wrap: wrap;
    align-items: center;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.trend-controls-panel:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.trend-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 180px;
}

.trend-control-group label {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.trend-control-group select,
.trend-control-group input[type="checkbox"] {
    font-family: var(--font-body);
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.trend-control-group select:focus {
    outline: 2px solid var(--neutral);
    outline-offset: 2px;
    border-color: var(--neutral);
    box-shadow: 0 0 0 3px rgba(59, 90, 157, 0.1);
}

.trend-control-group select:hover {
    border-color: var(--text-tertiary);
}

.trend-control-group input[type="checkbox"] {
    margin-right: 0.375rem;
    vertical-align: middle;
    width: auto;
    padding: 0;
}

.trend-control-group .checkbox-label {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: color 0.2s ease;
}

.trend-control-group .checkbox-label:hover {
    color: var(--neutral);
}

/* ===== SUMMARY METRICS ===== */
.key-trend-summary-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 0 3rem 2rem 3rem;
    padding: 0;
}

.trend-metric-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    border-left-width: 4px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.trend-metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Colored left borders for metric cards */
.trend-metric-card:nth-child(1) {
    border-left-color: #3B5A9D; /* Revenue - slate blue */
    animation-delay: 0s;
}

.trend-metric-card:nth-child(2) {
    border-left-color: #0A6E4E; /* Positive - forest green */
    animation-delay: 0.1s;
}

.trend-metric-card:nth-child(3) {
    border-left-color: #1E40AF; /* Net Income - deep blue */
    animation-delay: 0.2s;
}

.trend-metric-card:nth-child(4) {
    border-left-color: #D97706; /* Avg metric - amber */
    animation-delay: 0.3s;
}

.trend-metric-card:nth-child(5) {
    border-left-color: #059669; /* Gross Profit - green */
    animation-delay: 0.4s;
}

.trend-metric-card .metric-label {
    display: block;
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.trend-metric-card .metric-value {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    display: block;
    line-height: 1.2;
}

.trend-metric-card .metric-sub-value {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.375rem;
    font-variant-numeric: tabular-nums;
}

.trend-metric-card .metric-trend-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-left: 0.375rem;
    vertical-align: middle;
}

.trend-metric-card .metric-trend-icon.positive {
    color: var(--positive);
}

.trend-metric-card .metric-trend-icon.negative {
    color: var(--negative);
}

.trend-metric-card .metric-trend-icon svg {
    width: 100%;
    height: 100%;
}

.trend-metric-card .positive {
    color: var(--positive);
}

.trend-metric-card .negative {
    color: var(--negative);
}

/* ===== MAIN CHART CONTAINER ===== */
.key-metrics-main-chart-container {
    width: calc(100% - 6rem);
    min-height: 520px;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 2px 8px var(--shadow);
    margin: 0 3rem 2rem 3rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.key-metrics-main-chart-container:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Chart canvas styling */
.key-metrics-main-chart-container canvas {
    display: block;
    box-sizing: border-box;
}

/* ===== CHART MESSAGE OVERLAY ===== */
.chart-message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.98);
    padding: 1.5rem 2rem;
    border-radius: 12px;
    text-align: center;
    font-family: var(--font-body);
    font-style: italic;
    color: var(--text-secondary);
    border: 2px dashed var(--border);
    font-size: 0.9375rem;
    z-index: 10;
    box-shadow: 0 4px 12px var(--shadow);
}

/* ===== INSIGHTS PANEL ===== */
.trend-insights-panel {
    margin: 0 3rem 2rem 3rem;
    padding: 0;
    background: linear-gradient(to bottom, #F8F9FA 0%, #FFFFFF 100%);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
}

.trend-insights-panel h4 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    padding: 1.75rem 2rem 1.25rem 2rem;
    background: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%);
    border-bottom: 2px solid var(--border);
    letter-spacing: -0.01em;
}

.insights-content {
    padding: 1.5rem 2rem 2rem 2rem;
}

/* ===== INSIGHT ITEMS ===== */
.trend-insight-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 0.875rem;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    border-left-width: 4px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.trend-insight-item:nth-child(2) { animation-delay: 0.1s; }
.trend-insight-item:nth-child(3) { animation-delay: 0.2s; }
.trend-insight-item:nth-child(4) { animation-delay: 0.3s; }
.trend-insight-item:nth-child(5) { animation-delay: 0.4s; }

.trend-insight-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.trend-insight-item.positive {
    border-left-color: var(--positive);
}

.trend-insight-item.positive .trend-insight-icon {
    color: var(--positive);
}

.trend-insight-item.negative {
    border-left-color: var(--negative);
}

.trend-insight-item.negative .trend-insight-icon {
    color: var(--negative);
}

.trend-insight-item.neutral {
    border-left-color: var(--warning);
}

.trend-insight-item.neutral .trend-insight-icon {
    color: var(--warning);
}

.trend-insight-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.trend-insight-icon svg {
    width: 100%;
    height: 100%;
}

.trend-insight-content {
    flex: 1;
}

.trend-insight-title {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin: 0 0 0.375rem 0;
}

.trend-insight-description {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* ===== ANALYSIS NOTE ===== */
.trend-analysis-note {
    font-family: var(--font-body);
    font-size: 0.875rem;
    text-align: center;
    margin: 0 3rem 2rem 3rem;
    color: var(--text-tertiary);
    padding: 1.25rem 1.75rem;
    font-style: italic;
    line-height: 1.6;
    background: linear-gradient(135deg, var(--bg) 0%, #FFFFFF 100%);
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* ===== FISCAL YEAR CONFIG ===== */
.fiscal-year-config-item {
    margin-bottom: 1rem;
    width: 100%;
}

.fiscal-year-config-item label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.9375rem;
    color: #374151;
}

.fiscal-year-config-item select,
.fiscal-year-config-item input[type="number"] {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9375rem;
    box-sizing: border-box;
    color: #1f2937;
}

.fiscal-year-config-item select:focus,
.fiscal-year-config-item input[type="number"]:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-color: #3b82f6;
}

.fiscal-year-config-item input[type="number"] {
    max-width: 150px;
}

.fiscal-year-config-item small {
    display: block;
    font-size: 0.8125rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .key-metrics-hero {
        padding: 2rem;
    }

    .hero-content {
        gap: 2rem;
    }

    .hero-value {
        font-size: 2.5rem;
    }

    .hero-stat-value {
        font-size: 1.25rem;
    }

    .hero-stats {
        gap: 2rem;
    }

    .key-trend-summary-metrics {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        margin: 0 2rem 1.75rem 2rem;
    }

    .key-metrics-main-chart-container {
        min-height: 450px;
        width: calc(100% - 4rem);
        margin: 0 2rem 1.75rem 2rem;
    }

    .trend-controls-panel {
        margin: 1.75rem 2rem;
    }

    .trend-insights-panel {
        margin: 0 2rem 1.75rem 2rem;
    }

    .trend-analysis-note {
        margin: 0 2rem 1.75rem 2rem;
    }
}

@media (max-width: 768px) {
    .key-metrics-trend-container {
        padding: 0;
    }

    .key-metrics-trend-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 2rem 1.5rem 1.5rem 1.5rem;
    }

    .key-metrics-trend-title {
        font-size: 2rem;
    }

    .key-metrics-hero {
        padding: 2rem 1.5rem;
    }

    .hero-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 2rem;
    }

    .hero-value {
        font-size: 2.25rem;
    }

    .hero-stats {
        width: 100%;
        justify-content: space-between;
        gap: 1rem;
    }

    .hero-stat {
        text-align: left;
    }

    .trend-controls-panel {
        padding: 1.5rem;
        gap: 1.5rem;
        margin: 1.5rem 1.5rem;
    }

    .trend-control-group {
        min-width: 150px;
    }

    .key-trend-summary-metrics {
        grid-template-columns: 1fr;
        gap: 0.875rem;
        margin: 0 1.5rem 1.5rem 1.5rem;
    }

    .trend-metric-card {
        padding: 1.25rem;
    }

    .trend-metric-card .metric-value {
        font-size: 1.5rem;
    }

    .key-metrics-main-chart-container {
        padding: 1.5rem;
        min-height: 400px;
        width: calc(100% - 3rem);
        margin: 0 1.5rem 1.5rem 1.5rem;
    }

    .trend-insights-panel {
        padding: 1.5rem;
        margin: 0 1.5rem 1.5rem 1.5rem;
    }

    .trend-insight-item {
        padding: 1rem;
    }

    .trend-analysis-note {
        margin: 0 1.5rem 1.5rem 1.5rem;
        padding: 1rem 1.25rem;
    }
}

@media (max-width: 480px) {
    .key-metrics-trend-container {
        padding: 0;
    }

    .key-metrics-trend-header {
        padding: 1.5rem 1rem 1rem 1rem;
    }

    .key-metrics-trend-title {
        font-size: 1.5rem;
        letter-spacing: -0.02em;
    }

    .key-metrics-hero {
        padding: 1.5rem 1rem;
    }

    .hero-label {
        font-size: 0.75rem;
    }

    .hero-value {
        font-size: 2rem;
    }

    .hero-stats {
        flex-direction: column;
        gap: 1.25rem;
    }

    .hero-stat-value {
        font-size: 1.125rem;
    }

    .trend-controls-panel {
        padding: 1.25rem;
        gap: 1rem;
        margin: 1.25rem 1rem;
    }

    .trend-control-group {
        min-width: 100%;
    }

    .trend-metric-card {
        padding: 1rem;
    }

    .trend-metric-card .metric-value {
        font-size: 1.375rem;
    }

    .key-metrics-main-chart-container {
        padding: 1rem;
        min-height: 350px;
        width: calc(100% - 2rem);
        margin: 0 1rem 1.25rem 1rem;
    }

    .chart-message-overlay {
        padding: 1rem;
        font-size: 0.875rem;
    }

    .trend-insights-panel {
        padding: 1.25rem;
        margin: 0 1rem 1.25rem 1rem;
    }

    .trend-insights-panel h4 {
        font-size: 1rem;
    }

    .trend-insight-item {
        flex-direction: column;
        padding: 1rem;
        text-align: center;
    }

    .trend-insight-icon {
        align-self: center;
    }

    .trend-analysis-note {
        margin: 0 1rem 1.25rem 1rem;
        padding: 1rem;
    }

    .fiscal-year-config-item input[type="number"] {
        max-width: 100%;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .key-metrics-trend-container {
        background: white;
        box-shadow: none;
        border: 1px solid #d1d5db;
        padding: 1rem;
    }

    .key-metrics-trend-header {
        page-break-after: avoid;
    }

    .trend-controls-panel {
        display: none;
    }

    .key-trend-summary-metrics {
        page-break-inside: avoid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .trend-metric-card {
        page-break-inside: avoid;
        border: 1px solid #d1d5db;
        box-shadow: none;
    }

    .trend-metric-card:hover {
        box-shadow: none;
    }

    .key-metrics-main-chart-container {
        page-break-inside: avoid;
        min-height: 400px;
        box-shadow: none;
        border: 1px solid #d1d5db;
    }

    .key-metrics-main-chart-container:hover {
        box-shadow: none;
    }

    .trend-insights-panel {
        page-break-inside: avoid;
        border: 1px solid #d1d5db;
    }

    .trend-insight-item {
        page-break-inside: avoid;
        box-shadow: none;
    }

    .trend-insight-item:hover {
        box-shadow: none;
    }
}

/* ===== ACCESSIBILITY ===== */
.trend-metric-card:focus-within,
.trend-insight-item:focus-within,
.key-metrics-main-chart-container:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
