/* 100 Years of Stock Market - Interactive History Dashboard */
.market-history-dashboard {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: #1f2937;
}

/* Header Section */
.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.dashboard-title {
    font-size: 32px;
    font-weight: 800;
    margin: 0 0 10px 0;
    color: #111827;
    letter-spacing: -0.5px;
}

.dashboard-subtitle {
    font-size: 18px;
    color: #6b7280;
    margin: 0;
    font-weight: 400;
}

/* Main Layout */
.dashboard-main {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    margin-bottom: 30px;
}

.chart-section {
    display: flex;
    flex-direction: column;
}

.context-panel {
    background: #f9fafb;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    height: fit-content;
    position: sticky;
    top: 20px;
}

/* Timeline Navigation */
.timeline-navigation {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.timeline-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 15px 0;
    color: #374151;
}

.timeline-decades {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.decade-button {
    padding: 8px 16px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    transition: all 0.3s ease;
    user-select: none;
}

.decade-button:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
    transform: translateY(-1px);
}

.decade-button.active {
    border-color: #2563eb;
    background: #2563eb;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Chart Container */
.chart-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
    position: relative;
}

.chart-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: #111827;
    text-align: center;
}

.chart-canvas {
    width: 100%;
    height: 400px;
    position: relative;
}

/* Chart.js Canvas Styling */
.chart-canvas canvas {
    max-width: 100% !important;
    height: 400px !important;
}

#growth-chart canvas {
    max-width: 100% !important;
    height: 450px !important;
}

/* Ensure chart containers have proper dimensions */
.chart-canvas,
#growth-chart {
    position: relative;
    width: 100%;
    min-height: 300px;
    overflow: hidden; /* Prevent chart overflow */
}

.chart-canvas {
    min-height: 400px;
}

/* Legend - Keep for Chart.js reference */
.chart-legend {
    display: none; /* Hide since Chart.js has its own legend */
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}
}

/* Context Panel */
.context-header {
    margin-bottom: 20px;
}

.context-decade {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 5px 0;
}

.context-notable {
    font-size: 14px;
    color: #6b7280;
    font-style: italic;
    margin: 0;
}

.context-metrics {
    display: grid;
    gap: 15px;
    margin-bottom: 25px;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.metric-label {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

.metric-value {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.metric-value.positive {
    color: #059669;
}
.metric-value.negative {
    color: #dc2626;
}

/* Events Section */
.context-events {
    margin-top: 25px;
}

.events-title {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 15px 0;
}

.event-item {
    padding: 12px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.event-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.event-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.event-year {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.event-impact {
    font-size: 12px;
    font-weight: 600;
    color: #dc2626;
    margin-bottom: 5px;
}

.event-description {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

/* Presidential Overlay Toggle */
.presidential-toggle {
    margin-bottom: 20px;
    text-align: center;
}

.toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: all 0.2s ease;
}

.toggle-button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.toggle-button.active {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.toggle-checkbox {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 2px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-checkbox.checked::after {
    content: "✓";
    font-size: 12px;
    font-weight: bold;
}

/* Growth Chart (Bottom Section) */
.growth-section {
    margin-top: 30px;
    padding: 24px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.growth-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin: 0 0 20px 0;
    color: #111827;
}

.growth-chart {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    padding: 20px;
    position: relative;
}

.growth-chart canvas {
    max-width: 100% !important;
    height: 450px !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-main {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .context-panel {
        position: static;
        order: -1;
    }

    .dashboard-title {
        font-size: 28px;
    }

    /* Improve touch targets on tablets */
    .decade-button {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .toggle-button {
        min-height: 44px;
    }
}

@media (max-width: 768px) {
    .market-history-dashboard {
        padding: 15px;
        margin: 0;
        border-radius: 8px;
    }

    .dashboard-title {
        font-size: 24px;
    }

    .dashboard-subtitle {
        font-size: 16px;
    }

    .timeline-navigation {
        padding: 15px;
        margin-bottom: 20px;
    }

    .timeline-decades {
        justify-content: center;
        gap: 6px;
    }

    .decade-button {
        padding: 6px 10px;
        font-size: 12px;
    }

    .presidential-toggle {
        margin-bottom: 15px;
    }

    .toggle-button {
        padding: 6px 12px;
        font-size: 13px;
    }

    .chart-container,
    .context-panel,
    .growth-section {
        padding: 16px;
    }

    .chart-title,
    .growth-title {
        font-size: 18px;
    }

    /* Reduce Chart.js canvas heights for mobile */
    .chart-canvas {
        height: 280px !important;
    }

    .chart-canvas canvas {
        height: 280px !important;
    }

    .growth-chart canvas {
        height: 320px !important;
    }

    .context-metrics {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .metric {
        padding: 12px;
    }

    .metric-label {
        font-size: 12px;
    }

    .metric-value {
        font-size: 14px;
    }

    .event-item {
        padding: 10px;
    }

    .event-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .market-history-dashboard {
        padding: 10px;
    }

    .dashboard-title {
        font-size: 20px;
    }

    .dashboard-subtitle {
        font-size: 14px;
    }

    .timeline-navigation {
        padding: 12px;
    }

    .timeline-decades {
        gap: 4px;
        /* Enable horizontal scrolling for decade buttons on very small screens */
        overflow-x: auto;
        padding-bottom: 5px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .timeline-decades::-webkit-scrollbar {
        height: 4px;
    }

    .timeline-decades::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 2px;
    }

    .timeline-decades::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 2px;
    }

    .decade-button {
        padding: 4px 8px;
        font-size: 11px;
        min-width: 45px;
        flex-shrink: 0; /* Prevent buttons from shrinking */
    }

    .toggle-button {
        padding: 5px 10px;
        font-size: 12px;
    }

    .toggle-checkbox {
        width: 14px;
        height: 14px;
    }

    .chart-container,
    .context-panel,
    .growth-section {
        padding: 12px;
    }

    .chart-title,
    .growth-title {
        font-size: 16px;
        margin-bottom: 15px;
    }

    /* Further reduce heights for very small screens */
    .chart-canvas {
        height: 240px !important;
        min-height: 240px;
    }

    .chart-canvas canvas {
        height: 240px !important;
    }

    .growth-chart canvas {
        height: 280px !important;
    }

    #growth-chart {
        min-height: 280px;
    }

    .dashboard-main {
        gap: 15px;
    }

    .context-metrics {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .metric {
        padding: 8px;
        text-align: center;
    }

    .metric-label {
        font-size: 11px;
    }

    .metric-value {
        font-size: 13px;
    }

    .event-name {
        font-size: 13px;
    }

    .event-year {
        font-size: 11px;
    }

    .event-impact {
        font-size: 11px;
    }

    .event-description {
        font-size: 12px;
    }
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6b7280;
    font-size: 16px;
}

.loading::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    margin-left: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Smooth Transitions */
.decade-button,
.chart-bar,
.event-item,
.metric {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Accessibility */
.decade-button:focus,
.toggle-button:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
