/* marginAnalysis.css - Enhanced Margin Analysis Module Styles */

/* ===== Container and Layout ===== */
.margin-analysis-wrapper {
    padding: 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    min-height: calc(100vh - 200px);
    position: relative;
}

.margin-analysis-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
    color: white;
    padding: 2rem;
    border-radius: 0 0 1rem 1rem;
    box-shadow: 0 4px 20px rgba(74, 144, 226, 0.2);
    position: relative;
    overflow: hidden;
}

.margin-analysis-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 50%;
    height: 200%;
    background: rgba(255, 255, 255, 0.05);
    transform: rotate(45deg);
}

.margin-analysis-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
}

.margin-analysis-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 1rem;
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

/* ===== View Selector Tabs ===== */
.margin-view-tabs {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 2rem 0;
    flex-wrap: wrap;
}

.view-tab {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem 0.75rem 0 0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-tab:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color-medium);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.view-tab.active {
    background: white;
    border-color: var(--primary-color);
    border-bottom: 2px solid white;
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 -2px 12px rgba(74, 144, 226, 0.2);
}

.view-tab-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.view-tab.active .view-tab-icon {
    opacity: 1;
}

/* ===== Content Area ===== */
.margin-content-area {
    background: white;
    border-radius: 1rem;
    margin: 0 2rem 2rem;
    padding: 2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    min-height: 500px;
    position: relative;
}

/* ===== Metric Cards Grid ===== */
.margin-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
    margin-top: 1.5rem; /* Added this line */
}

.margin-metric-card {
    background: linear-gradient(135deg, var(--bg-color) 0%, white 100%);
    border-radius: 0.75rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.margin-metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.margin-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.margin-metric-card:hover::before {
    transform: translateY(0);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.813rem;
    font-weight: 600;
}

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

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

.trend-neutral {
    color: var(--text-muted);
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.metric-subtitle {
    font-size: 0.813rem;
    color: var(--text-color-light);
}

.metric-sparkline {
    height: 40px;
    margin-top: 0.75rem;
}

/* EBITDA Metric Badge */
.metric-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border-radius: 0.75rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Featured Metric Card (for EBITDA) */
.metric-card-featured {
    border-width: 2px;
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.02) 0%, white 100%);
}

.metric-card-featured::before {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.metric-card-featured:hover {
    box-shadow: 0 8px 28px rgba(74, 144, 226, 0.15);
}

/* ===== Control Panel ===== */
.margin-controls {
    background: var(--bg-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
}

.control-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-select:hover {
    border-color: var(--primary-color-medium);
}

.control-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.control-toggle {
    display: flex;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.toggle-option {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: none;
}

.toggle-option.active {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

/* ===== Visualization Containers ===== */
.margin-viz-container {
    position: relative;
    min-height: 280px;
    margin-bottom: 1rem;
}

.viz-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.viz-loading.show {
    display: block;
}

.margin-chart-wrapper {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    position: relative;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
}

.chart-actions {
    display: flex;
    gap: 0.5rem;
}

.chart-action-btn {
    padding: 0.375rem 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.813rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.chart-action-btn:hover {
    background: var(--primary-color-light);
    border-color: var(--primary-color-medium);
    color: var(--primary-color-dark);
}

/* ===== Margin Decomposition View ===== */
.decomposition-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-top: 2rem;
}

.decomposition-factors {
    background: var(--bg-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.factor-item {
    padding: 1rem;
    background: white;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.factor-item:hover {
    border-color: var(--primary-color-medium);
    transform: translateX(4px);
}

.factor-item.active {
    border-color: var(--primary-color);
    background: var(--primary-color-light);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.2);
}

.factor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.factor-name {
    font-weight: 600;
    color: var(--text-color);
}

.factor-impact {
    font-size: 0.875rem;
    font-weight: 600;
}

.factor-description {
    font-size: 0.813rem;
    color: var(--text-color-light);
}

/* ===== Benchmark Comparison ===== */
.benchmark-container {
    margin-top: 2rem;
}

.benchmark-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.benchmark-card {
    background: var(--bg-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    position: relative;
}

.benchmark-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.benchmark-title {
    font-weight: 600;
    color: var(--text-color);
}

.benchmark-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-above {
    background: var(--success-color-light);
    color: var(--success-color-dark);
}

.badge-below {
    background: var(--danger-color-light);
    color: var(--danger-color-dark);
}

.badge-inline {
    background: var(--warning-color-light);
    color: var(--warning-color-dark);
}

.benchmark-chart {
    height: 60px;
    margin: 1rem 0;
}

.benchmark-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.813rem;
}

/* ===== Sensitivity Analysis ===== */
.sensitivity-panel {
    background: var(--bg-color);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
}

.sensitivity-sliders {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

/* Compact grid layout for sensitivity charts */
.sensitivity-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.sensitivity-slider-group {
    position: relative;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.slider-label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.875rem;
}

.slider-value {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.875rem;
}

.margin-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    position: relative;
}

.margin-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.margin-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(74, 144, 226, 0.4);
}

.slider-track-fill {
    position: absolute;
    height: 6px;
    background: var(--primary-color);
    border-radius: 3px;
    pointer-events: none;
    transition: width 0.2s ease;
}

/* ===== Insights Panel ===== */
.margin-insights-panel {
    background: linear-gradient(135deg, var(--primary-color-light) 0%, var(--bg-color) 100%);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-top: 2rem;
    border: 1px solid var(--primary-color-medium);
}

.insights-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.insights-header h4 {
    margin: 0;
    color: var(--primary-color-dark);
    font-size: 1.25rem;
}

.insight-items {
    display: grid;
    gap: 1rem;
}

.margin-insight-item {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: start;
    transition: all 0.2s ease;
    border-left: 4px solid var(--primary-color);
}

.margin-insight-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.insight-icon-wrapper {
    width: 40px;
    height: 40px;
    background: var(--primary-color-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.insight-content {
    flex: 1;
}

.insight-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.insight-description {
    font-size: 0.875rem;
    color: var(--text-color-light);
    line-height: 1.5;
}

.insight-action {
    margin-top: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--primary-color-light);
    color: var(--primary-color-dark);
    border: none;
    border-radius: 0.25rem;
    font-size: 0.813rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.insight-action:hover {
    background: var(--primary-color);
    color: white;
}

/* ===== Export Options ===== */
.export-options {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
}

.export-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.813rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.export-btn:hover {
    background: var(--primary-color-light);
    border-color: var(--primary-color-medium);
    color: var(--primary-color-dark);
}

/* ===== Tooltips ===== */
.margin-tooltip {
    position: absolute;
    background: var(--text-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.813rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.margin-tooltip.show {
    opacity: 1;
}

.margin-tooltip::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--text-color);
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
    .margin-metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .decomposition-grid {
        grid-template-columns: 1fr;
    }
    
    .benchmark-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .margin-analysis-header {
        padding: 1.5rem;
    }
    
    .margin-content-area {
        margin: 0 1rem 1rem;
        padding: 1.5rem;
    }
    
    .margin-view-tabs {
        padding: 1rem 1rem 0;
        gap: 0.5rem;
    }
    
    .view-tab {
        padding: 0.5rem 1rem;
        font-size: 0.813rem;
    }
    
    .margin-metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .margin-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        width: 100%;
        justify-content: space-between;
    }
}

/* ===== Animations ===== */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.margin-metric-card {
    animation: slideInUp 0.4s ease;
    animation-fill-mode: both;
}

.margin-metric-card:nth-child(1) { animation-delay: 0.1s; }
.margin-metric-card:nth-child(2) { animation-delay: 0.15s; }
.margin-metric-card:nth-child(3) { animation-delay: 0.2s; }
.margin-metric-card:nth-child(4) { animation-delay: 0.25s; }

/* ===== Welcome Tour Overlay ===== */
.margin-welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.margin-welcome-modal {
    background: white;
    border-radius: 1.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.welcome-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
    color: white;
    padding: 2rem;
    border-radius: 1.5rem 1.5rem 0 0;
    text-align: center;
}

.welcome-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 700;
}

.welcome-header p {
    margin: 0;
    opacity: 0.95;
    font-size: 1rem;
}

.welcome-content {
    padding: 2rem;
}

.welcome-feature {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-color);
    border-radius: 1rem;
    transition: all 0.3s ease;
}

.welcome-feature:hover {
    transform: translateX(8px);
    background: var(--primary-color-light);
}

.feature-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.feature-content h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-color);
    font-size: 1.125rem;
}

.feature-content p {
    margin: 0;
    color: var(--text-color-light);
    font-size: 0.9rem;
    line-height: 1.5;
}

.welcome-actions {
    padding: 0 2rem 2rem;
    display: flex;
    gap: 1rem;
}

.welcome-btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.welcome-btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(74, 144, 226, 0.3);
}

.welcome-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(74, 144, 226, 0.4);
}

.welcome-btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.welcome-btn-secondary:hover {
    background: white;
    border-color: var(--primary-color-medium);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ===== Enhanced Tab with Badge ===== */
.view-tab-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.5rem;
    animation: badgePulse 2s ease infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0);
    }
}

/* ===== Margin Forecast Styles ===== */
.forecast-header {
    margin-bottom: 1.5rem;
}

.forecast-period-selector {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.period-btn-group {
    display: flex;
    background: var(--bg-color);
    border-radius: 0.75rem;
    padding: 0.25rem;
    gap: 0.25rem;
}

.period-btn {
    padding: 0.625rem 1.5rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.period-btn:hover {
    background: white;
    color: var(--primary-color);
}

.period-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.forecast-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.forecast-metric-card {
    background: linear-gradient(135deg, var(--bg-color) 0%, white 100%);
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.forecast-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color-medium);
}

.forecast-metric-card .metric-label {
    font-size: 0.813rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.forecast-metric-card .metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.forecast-metric-card .metric-change {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.forecast-metric-card .metric-change.positive {
    color: var(--success-color);
}

.forecast-metric-card .metric-change.negative {
    color: var(--danger-color);
}

.forecast-metric-card .metric-confidence {
    font-size: 0.75rem;
    color: var(--text-color-light);
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.forecast-insights {
    background: var(--bg-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-top: 2rem;
}

.forecast-insights .insights-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 1.25rem 0;
}

.forecast-insights .insights-list {
    display: grid;
    gap: 1rem;
}

.forecast-insights .insight-item {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--border-color);
    transition: all 0.2s ease;
}

.forecast-insights .insight-item.positive {
    border-left-color: var(--success-color);
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.05) 0%, white 100%);
}

.forecast-insights .insight-item.warning {
    border-left-color: var(--warning-color);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.05) 0%, white 100%);
}

.forecast-insights .insight-item.critical {
    border-left-color: var(--danger-color);
    background: linear-gradient(90deg, rgba(197, 48, 48, 0.05) 0%, white 100%);
}

.forecast-insights .insight-item.info {
    border-left-color: var(--primary-color);
    background: linear-gradient(90deg, rgba(74, 144, 226, 0.05) 0%, white 100%);
}

.forecast-insights .insight-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.forecast-insights .insight-text {
    font-size: 0.875rem;
    color: var(--text-color);
    line-height: 1.6;
}

.forecast-error {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(217, 119, 6, 0.05) 100%);
    border: 2px solid var(--warning-color);
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
    color: var(--warning-color-dark);
    font-weight: 600;
    font-size: 1rem;
}

/* Responsive adjustments for forecast */
@media (max-width: 768px) {
    .forecast-metrics-grid {
        grid-template-columns: 1fr;
    }

    .period-btn-group {
        flex-direction: column;
        width: 100%;
    }

    .period-btn {
        width: 100%;
    }
}

/* ===== Margin Performance Heat Map ===== */
.margin-heatmap {
    display: table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
}

.heatmap-row {
    display: table-row;
}

.heatmap-cell {
    display: table-cell;
    padding: 0.75rem;
    text-align: center;
    vertical-align: middle;
    font-size: 0.813rem;
    font-weight: 600;
    border-radius: 0.375rem;
}

.heatmap-header .heatmap-cell {
    background: var(--bg-color);
    color: var(--text-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.heatmap-label {
    background: var(--bg-color);
    color: var(--text-color);
    font-weight: 700;
    text-align: left !important;
    min-width: 150px;
}

.heatmap-month {
    min-width: 70px;
    font-size: 0.75rem;
}

.heatmap-value {
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 70px;
}

.heatmap-value:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
    justify-content: center;
}

.legend-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
}

.legend-gradient {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-marker {
    width: 24px;
    height: 24px;
    border-radius: 0.375rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.legend-text {
    font-size: 0.813rem;
    color: var(--text-color-light);
    font-weight: 500;
}

/* Heat map responsive */
@media (max-width: 992px) {
    .heatmap-cell {
        padding: 0.5rem 0.25rem;
        font-size: 0.7rem;
    }

    .heatmap-label {
        min-width: 100px;
        font-size: 0.7rem;
    }

    .heatmap-month,
    .heatmap-value {
        min-width: 50px;
    }
}

/* ===== Print Styles ===== */
@media print {
    .margin-analysis-wrapper {
        background: white;
    }

    .margin-view-tabs,
    .margin-controls,
    .export-options,
    .chart-actions,
    .margin-welcome-overlay,
    .forecast-period-selector {
        display: none !important;
    }

    .margin-content-area {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .margin-chart-wrapper {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .heatmap-value:hover {
        transform: none;
        box-shadow: none;
    }
}