/* ============================================
   Humanitarian Impact Page - Dedicated Styles
   ============================================ */

/* Scroll Progress Bar */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, #c62828, #d32f2f);
    z-index: 9999;
    transition: width 0.1s linear;
}

/* History Header */
.history-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: white;
    padding: 3rem 0 2.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.history-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.history-header .container {
    position: relative;
    z-index: 1;
}

.history-header h1 {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.history-header h1 i {
    color: #d32f2f;
    margin-right: 0.5rem;
}

.history-header .subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    margin-bottom: 1rem;
}

.history-meta {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

.history-meta span {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.history-meta i {
    color: #d32f2f;
}

/* Layout: Sidebar + Content */
.history-layout {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 20px;
}

/* Table of Contents - Sidebar */
.toc-nav {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 1.5rem;
}

.toc-nav h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f0f0f0;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin-bottom: 0.25rem;
}

.toc-list a {
    display: block;
    padding: 0.4rem 0.75rem;
    color: #555;
    text-decoration: none;
    font-size: 0.82rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    line-height: 1.4;
}

.toc-list a:hover {
    background: #f8f9fa;
    color: #1a1a2e;
}

.toc-list a.active {
    background: rgba(198, 40, 40, 0.08);
    color: #c62828;
    border-left-color: #c62828;
    font-weight: 600;
}

/* Mobile TOC Toggle */
.toc-mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #1a1a2e;
    color: white;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    align-items: center;
    justify-content: center;
}

/* Main Content Area */
.history-content {
    flex: 1;
    min-width: 0;
}

/* Era Sections */
.era-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

.era-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    border-left: 5px solid #c62828;
}

.era-header:hover {
    background: #fafafa;
}

.era-number {
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    background: #c62828;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.era-header h2 {
    flex: 1;
    font-size: 1.15rem;
    color: #1a1a2e;
    margin: 0;
    line-height: 1.3;
}

.era-header .era-dates {
    font-size: 0.8rem;
    color: #999;
    white-space: nowrap;
}

.era-toggle {
    font-size: 1rem;
    color: #999;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.era-section.open .era-toggle {
    transform: rotate(180deg);
}

.era-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.era-section.open .era-content {
    max-height: none;
}

.era-body {
    padding: 0 1.5rem 1.5rem;
    line-height: 1.8;
    color: #444;
    text-align: justify;
}

.era-body p {
    margin-bottom: 1rem;
}

.era-body h3 {
    font-size: 1.05rem;
    color: #1a1a2e;
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid #f0f0f0;
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.data-table th {
    background: #1a1a2e;
    color: white;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
}

.data-table tr:hover td {
    background: #f8f9fa;
}

/* Transformation Visual: Before/After */
.transformation-visual {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: stretch;
    margin: 1.5rem 0;
}

.transform-panel {
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
}

.transform-panel.allies {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border: 2px solid #4caf50;
}

.transform-panel.enemies {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    border: 2px solid #d32f2f;
}

.transform-panel h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.transform-panel.allies h4 {
    color: #2e7d32;
}

.transform-panel.enemies h4 {
    color: #c62828;
}

.transform-panel .dates {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    opacity: 0.7;
}

.transform-panel ul {
    list-style: none;
    padding: 0;
    text-align: left;
    font-size: 0.88rem;
}

.transform-panel ul li {
    padding: 0.3rem 0;
    padding-left: 1.2rem;
    position: relative;
}

.transform-panel.allies ul li::before {
    content: '+';
    position: absolute;
    left: 0;
    color: #4caf50;
    font-weight: 700;
}

.transform-panel.enemies ul li::before {
    content: '−';
    position: absolute;
    left: 0;
    color: #d32f2f;
    font-weight: 700;
}

.transform-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #999;
    flex-direction: column;
    gap: 0.5rem;
}

.transform-arrow span {
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Key Figures / Organizations Grid */
.figures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.figure-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.figure-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.figure-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 0.75rem;
}

.figure-card h5 {
    font-size: 0.9rem;
    color: #1a1a2e;
    margin-bottom: 0.2rem;
}

.figure-card .figure-role {
    font-size: 0.78rem;
    color: #c62828;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.figure-card .figure-desc {
    font-size: 0.78rem;
    color: #666;
    line-height: 1.4;
}

/* Sources Section */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.source-category h4 {
    font-size: 0.9rem;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid #c62828;
}

.source-category ul {
    list-style: none;
    padding: 0;
}

.source-category ul li {
    font-size: 0.82rem;
    color: #555;
    padding: 0.3rem 0;
}

.source-category ul li a {
    color: #0f3460;
    text-decoration: none;
}

.source-category ul li a:hover {
    color: #c62828;
    text-decoration: underline;
}

/* Callout boxes */
.callout {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 0.92rem;
    line-height: 1.6;
}

.callout.info {
    background: #e3f2fd;
    border-left: 4px solid #1976d2;
    color: #1565c0;
}

.callout.warning {
    background: #fff3e0;
    border-left: 4px solid #f57c00;
    color: #e65100;
}

.callout.key-fact {
    background: #f3e5f5;
    border-left: 4px solid #7b1fa2;
    color: #4a148c;
}

/* History Footer */
.history-footer {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
}

.history-footer p {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.history-footer a {
    color: #d32f2f;
    text-decoration: none;
}

.history-footer a:hover {
    text-decoration: underline;
}

/* Chart Legend (shared) */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: #666;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

/* ============================================
   PAGE-SPECIFIC: Stat Dashboard
   ============================================ */

.stat-dashboard {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

.stat-dashboard-card {
    flex: 1;
    min-width: 200px;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    border: 1px solid #f0f0f0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.stat-dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.stat-dashboard-card:nth-child(1)::before { background: #c62828; }
.stat-dashboard-card:nth-child(2)::before { background: #e65100; }
.stat-dashboard-card:nth-child(3)::before { background: #1565c0; }
.stat-dashboard-card:nth-child(4)::before { background: #f57c00; }

.stat-number-large {
    font-size: 2.5rem;
    font-weight: 800;
    color: #1a1a2e;
    line-height: 1;
}

.stat-label-large {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.25rem;
}

.stat-icon {
    font-size: 2rem;
    color: #c62828;
    margin-bottom: 0.5rem;
}

.stat-sub {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.5rem;
}

/* ============================================
   PAGE-SPECIFIC: Horizontal Bar Chart
   ============================================ */

.casualty-chart {
    margin: 1.5rem 0;
}

.bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.bar-label {
    width: 180px;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: #333;
    text-align: right;
}

.bar-label small {
    color: #999;
    font-size: 0.75rem;
}

.bar-container {
    flex: 1;
    height: 30px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bar-h-fill {
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    min-width: 40px;
    transition: width 0.5s ease;
}

.bar-h-fill.bar-civilian {
    background: linear-gradient(90deg, #e53935, #ef5350);
}

.bar-h-fill.bar-military {
    background: linear-gradient(90deg, #455a64, #607d8b);
}

.bar-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    white-space: nowrap;
}

/* ============================================
   PAGE-SPECIFIC: Pie Charts (conic-gradient)
   ============================================ */

.pie-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.pie-chart-card {
    text-align: center;
    padding: 1.25rem;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.pie-chart-card h4 {
    font-size: 0.95rem;
    color: #1a1a2e;
    margin-bottom: 0.75rem;
}

.pie-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 1rem;
}

.pie-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.78rem;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pie-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.pie-total {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0.5rem 0 0.25rem;
}

.pie-children {
    font-size: 0.78rem;
    color: #c62828;
    margin: 0;
}

.pie-children i {
    margin-right: 0.25rem;
}

/* ============================================
   PAGE-SPECIFIC: Refugee Groups / People Icons
   ============================================ */

.refugee-group {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.refugee-group h3 {
    border-bottom: none !important;
    margin-top: 0 !important;
}

.refugee-group h3 i {
    color: #c62828;
    margin-right: 0.5rem;
}

.refugee-number {
    font-size: 2rem;
    font-weight: 800;
    color: #c62828;
}

.refugee-detail {
    font-size: 0.78rem;
    color: #999;
}

.people-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin: 0.75rem 0;
    font-size: 0.7rem;
    color: #c62828;
}

.people-icons i {
    opacity: 0.6;
}

/* ============================================
   PAGE-SPECIFIC: Progress Bars (Destruction)
   ============================================ */

.destruction-bars {
    margin: 1.5rem 0;
}

.destruction-row {
    margin-bottom: 1rem;
}

.destruction-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.destruction-label span:first-child {
    color: #333;
    font-weight: 600;
}

.destruction-label span:last-child {
    color: #999;
    font-size: 0.82rem;
}

.progress-bar {
    height: 24px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    transition: width 0.5s ease;
}

.progress-fill.severity-high {
    background: linear-gradient(90deg, #e53935, #c62828);
}

.progress-fill.severity-critical {
    background: linear-gradient(90deg, #b71c1c, #880e4f);
}

.progress-fill.severity-extreme {
    background: linear-gradient(90deg, #880e4f, #4a0e0e);
}

/* ============================================
   PAGE-SPECIFIC: IPC Food Security Scale
   ============================================ */

.ipc-scale {
    display: flex;
    gap: 0;
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.ipc-phase {
    flex: 1;
    padding: 1rem 0.5rem;
    text-align: center;
    color: white;
    font-size: 0.75rem;
}

.ipc-phase strong {
    display: block;
    margin-bottom: 0.25rem;
}

.ipc-1 { background: #c6e5b3; color: #333; }
.ipc-2 { background: #f9e87e; color: #333; }
.ipc-3 { background: #e8a54b; }
.ipc-4 { background: #d1462f; }
.ipc-5 { background: #6b1b15; }

/* ============================================
   PAGE-SPECIFIC: Rial Chart
   ============================================ */

.rial-chart {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 2rem 0;
    min-height: 200px;
    justify-content: center;
}

.rial-bar {
    flex: 1;
    max-width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rial-bar-fill {
    width: 100%;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 0.5rem;
    min-height: 20px;
}

.rial-bar-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.rial-bar-label {
    font-size: 0.78rem;
    color: #555;
    margin-top: 0.5rem;
    font-weight: 600;
}

/* ============================================
   Responsive Styles
   ============================================ */

@media (max-width: 1200px) {
    .toc-nav {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .history-header h1 {
        font-size: 1.6rem;
    }

    .history-header .subtitle {
        font-size: 0.95rem;
    }

    .history-layout {
        flex-direction: column;
    }

    .toc-nav {
        display: none;
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 260px;
        max-height: 60vh;
        z-index: 499;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    }

    .toc-nav.mobile-open {
        display: block;
    }

    .toc-mobile-toggle {
        display: flex;
    }

    /* Stat Dashboard: 2x2 grid */
    .stat-dashboard {
        gap: 1rem;
    }

    .stat-dashboard-card {
        min-width: calc(50% - 0.5rem);
        flex: 0 0 calc(50% - 0.5rem);
        padding: 1rem;
    }

    .stat-number-large {
        font-size: 1.8rem;
    }

    /* Bar chart label shrinks */
    .bar-label {
        width: 120px;
        font-size: 0.78rem;
    }

    /* Pie charts: 2 columns */
    .pie-charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Refugee icons smaller */
    .people-icons {
        font-size: 0.6rem;
    }

    /* Transformation visual stacks */
    .transformation-visual {
        grid-template-columns: 1fr;
    }

    .transform-arrow {
        flex-direction: row;
        padding: 0.5rem 0;
    }

    /* Figures grid */
    .figures-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Sources */
    .sources-grid {
        grid-template-columns: 1fr;
    }

    /* Era section */
    .era-header {
        padding: 1rem;
    }

    .era-body {
        padding: 0 1rem 1rem;
    }

    /* Rial chart */
    .rial-chart {
        gap: 0.5rem;
    }

    .rial-bar {
        max-width: 60px;
    }

    /* IPC scale text */
    .ipc-phase {
        font-size: 0.65rem;
        padding: 0.75rem 0.25rem;
    }
}

@media (max-width: 480px) {
    .history-header h1 {
        font-size: 1.3rem;
    }

    .history-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Stat Dashboard: 1 column */
    .stat-dashboard-card {
        min-width: 100%;
        flex: 0 0 100%;
    }

    /* Bar chart: label stacks above bar */
    .bar-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    .bar-label {
        width: 100%;
        text-align: left;
        font-size: 0.82rem;
    }

    /* Pie charts: 1 column */
    .pie-charts-grid {
        grid-template-columns: 1fr;
    }

    /* Figures grid: 1 column */
    .figures-grid {
        grid-template-columns: 1fr;
    }

    .era-header h2 {
        font-size: 1rem;
    }

    .era-header .era-dates {
        display: none;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }

    /* Rial chart smaller */
    .rial-bar {
        max-width: 50px;
    }

    .rial-bar-value {
        font-size: 0.65rem;
    }

    /* IPC scale stacks */
    .ipc-scale {
        flex-direction: column;
    }

    .ipc-phase {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}
