:root {
    /* Row heights */
    --bureau-height: 32px;
    --title-height: 30px;
    --filter-height: 68px;
    --month-chart-height: 100px;
    --map-height: 380px;
    --countries-grid-row-gap: 10px;
    
    /* Column widths */
    --country-width: 230px;
    --publication-width: 270px;
    --sector-width: 130px;
}

/* Countries-specific main content layout */
#main-content.countries-content {
    display: grid;
    grid-template-areas:
        "chart-bureau         chart-bureau         title-story          title-story          sector-label"
        "chart-map            chart-map            filters              filters              chart-sector"
        "chart-map            chart-map            chart-month          chart-month          chart-sector"
        "chart-map            chart-map            chart-story          chart-story          chart-sector"
        "chart-country        chart-publication    chart-story          chart-story          chart-language";
    grid-template-columns: var(--country-width) var(--publication-width) var(--sector-width) 1fr var(--sector-width);
    grid-template-rows:
        var(--bureau-height)
        var(--filter-height)
        100px
        220px
        1fr;
    gap: var(--countries-grid-row-gap) 10px;
    padding: 5px 20px;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    transition: grid-template-rows 0.3s ease-out;
}

/* No filters - collapse filter row, expand month chart */
#main-content.countries-content.no-active-filters {
    grid-template-rows:
        var(--bureau-height)
        0px
        160px
        220px
        1fr;
}


#main-content.countries-content #filters {
    grid-area: filters;
    max-height: 120px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

#main-content.countries-content #filters:empty,
#main-content.countries-content #filters.no-filters {
    max-height: 0;
    margin: 0;
    padding: 0;
}

#main-content.countries-content #chart-month {
    grid-area: chart-month;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

#main-content.countries-content #chart-month svg {
    transition: height 0.3s ease-out;
}

#main-content.countries-content #results-header-top {
    grid-area: title-story;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

#main-content.countries-content #title-story {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

#main-content.countries-content #chart-bureau {
    grid-area: chart-bureau;
    display: flex;
    gap: 10px;
    align-items: stretch;
}

#main-content.countries-content #chart-bureau .bureau-panel {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    height: calc(var(--bureau-height) - 3px);
    padding: 4px 4px;
    justify-content: center;
}

#main-content.countries-content #chart-bureau .bureau-name {
    font-size: 13px;
    font-weight: 500;
    max-width: none;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

#main-content.countries-content #chart-bureau .bureau-story-count {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 0;
    line-height: 1;
}

#main-content.countries-content #chart-bureau .bureau-content {
    gap: 1px;
}

#main-content.countries-content #sector-context-label {
    grid-area: sector-label;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    padding: 6px 4px 1px 4px;
    color: #333;
    line-height: 1.2;
}

#main-content.countries-content #chart-sector {
    grid-area: chart-sector;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-left: 4px;
    padding-top: 0;
    align-items: stretch;
    overflow-y: auto;
}

#main-content.countries-content #chart-language-container {
    grid-area: chart-language;
    overflow: hidden;
    padding-left: 0;
    padding-top: 6px;
    min-height: 0;
}

#main-content.countries-content #chart-language-container .chart-title {
    font-size: 11px;
    line-height: 1.1;
    margin-bottom: 6px;
}

#main-content.countries-content #chart-language-container .chart-title-text {
    font-weight: 600;
}

#main-content.countries-content #chart-language-container .chart-title-count {
    font-size: 10px;
}

#main-content.countries-content #chart-language-container .chart-scroll {
    max-height: 130px;
    overflow-y: auto;
    overflow-x: hidden;
}

#main-content.countries-content #chart-language-container .dc-chart svg {
    overflow: hidden;
}

#main-content.countries-content #chart-language-container .dc-chart g.row text {
    font-size: 10px;
}

#main-content.countries-content #chart-map {
    grid-area: chart-map;
    overflow: hidden;
}

#main-content.countries-content #chart-country {
    grid-area: chart-country;
    overflow-y: auto;
}

#main-content.countries-content #chart-publication-container {
    grid-area: chart-publication;
    overflow-y: auto;
    overflow-x: hidden;
}

#main-content.countries-content #chart-story {
    grid-area: chart-story;
    overflow-y: auto;
    background-color: #e4e8ec;
    border-radius: 8px;
    padding: 16px 24px;
    border: 1px solid #bcc2c8;
}

#main-content.countries-content #chart-topic,
#main-content.countries-content #chart-country {
    font-weight: 500;
    font-size: 16px;
}

/* Country data table header */
#main-content.countries-content .country-header {
    display: grid;
    grid-template-columns: 80px 60px 60px 30px;
    font-weight: 600;
    font-size: 16px;
    height: var(--title-height);
    align-items: flex-end;
    padding-bottom: 5px;
    border-bottom: 1px solid #ccc;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

/* Country data row */
#main-content.countries-content .country-row {
    display: grid;
    grid-template-columns: 80px 60px 60px 30px;
    height: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
}

#main-content.countries-content .country-row:hover {
    background-color: #e8e8e8;
}

#main-content.countries-content .country-row.country-active {
    background-color: #0052a3;
    color: white;
}

#main-content.countries-content .country-row.country-active:hover {
    background-color: #003d7a;
}

#main-content.countries-content .country-row.country-active .country-cell-name {
    color: white;
}

#main-content.countries-content .country-row.country-active .country-bar-label {
    color: white !important;
}

/* Country row cells */
#main-content.countries-content .country-cell {
    display: flex;
    align-items: center;
    height: 20px;
    margin-bottom: 2px;
    overflow: hidden;
}

#main-content.countries-content .country-cell-name {
    font-weight: 500;
    font-size: 22px;
    padding-left: 4px;
}

#main-content.countries-content .country-cell-bar {
    position: relative;
    height: 20px;
    overflow: hidden;
}

#main-content.countries-content .country-bar {
    height: 20px;
    background-color: #9ecae1;
    max-width: 100%;
}

#main-content.countries-content .country-bar-stories {
    height: 20px;
    background-color: #bbb;
    max-width: 100%;
}

#main-content.countries-content .country-bar-label {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* Sector panels - card style (same as sectors page) */
#main-content.countries-content #chart-sector .sector-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    min-height: 40px;
    margin: 0 0 4px 0;
    background-color: #f5f5f5;
    box-sizing: border-box;
}

#main-content.countries-content #chart-sector .sector-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    filter: brightness(0.95);
}

#main-content.countries-content #chart-sector .sector-panel.active {
    background-color: #0066cc !important;
    border-color: #0066cc !important;
    color: white !important;
    box-shadow: none !important;
    font-weight: 500;
}

#main-content.countries-content #chart-sector .sector-panel.active .sector-name,
#main-content.countries-content #chart-sector .sector-panel.active .sector-story-count {
    color: white !important;
}

#main-content.countries-content #chart-sector .sector-panel.active:hover {
    background-color: #0052a3 !important;
    border-color: #0052a3 !important;
}

#main-content.countries-content #chart-sector .sector-panel.disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
    filter: grayscale(100%);
}

#main-content.countries-content #chart-sector .sector-name {
    font-size: 12px;
    font-weight: 400;
    text-align: center;
    line-height: 1.1;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#main-content.countries-content #chart-sector .sector-story-count {
    font-size: 9px;
    font-weight: 500;
    text-align: center;
    opacity: 0.8;
    margin-top: auto;
    width: 100%;
    line-height: 1.1;
}

/* ========================================
   EMBEDDED MAP STYLES
   (scoped from bureau-maps.css)
   ======================================== */

#chart-map .map-frame {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(17, 24, 39, 0.10);
    padding: 10px;
    margin-top: 0px;
    overflow: hidden;
    max-width: 760px;
}

#chart-map .map-svg {
    width: 100%;
    height: auto;
    display: block;
}

#chart-map path.country {
    cursor: pointer;
    transition: filter 120ms ease, stroke-width 120ms ease;
}

#chart-map path.country.is-context {
    cursor: default;
}

#chart-map path.country:hover {
    filter: drop-shadow(0 2px 5px rgba(17, 24, 39, 0.25));
    stroke-width: 1.4;
}

#chart-map path.country.is-context:hover {
    filter: none;
    stroke-width: 0.6;
}

#chart-map path.country.is-selected {
    stroke: #111827 !important;
    stroke-width: 2.2 !important;
}

#chart-map .country-label {
    font-size: 10px;
    font-weight: 400;
    fill: rgba(17, 24, 39, 0.75);
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 2.5px;
    stroke-linejoin: round;
    pointer-events: none;
}

#chart-map .country-label.is-context {
    font-size: 10px;
    font-weight: 350;
    fill: rgba(17, 24, 39, 0.35);
    stroke: rgba(255, 255, 255, 0.75);
    stroke-width: 2.2px;
}

#chart-map .country-label.is-context.is-forced {
    font-size: 11px;
    font-weight: 400;
    fill: rgba(17, 24, 39, 0.38);
}

#chart-map .country-label.is-active {
    font-size: 11px;
    font-weight: 450;
    fill: rgba(17, 24, 39, 0.8);
    stroke: rgba(255, 255, 255, 0.92);
    stroke-width: 2.8px;
}

#chart-map .water-label {
    font-size: 12px;
    font-style: italic;
    font-weight: 550;
    fill: rgba(30, 64, 175, 0.25);
    letter-spacing: 0.01em;
    pointer-events: none;
    user-select: none;
}

/* Map tooltip */
.map-tooltip {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    background: rgba(17, 24, 39, 0.95);
    color: #ffffff;
    border-radius: 10px;
    padding: 10px 10px;
    min-width: 140px;
    box-shadow: 0 10px 30px rgba(17, 24, 39, 0.10);
}

.map-tooltip.is-hidden {
    display: none;
}

.map-tooltip-title {
    font-weight: 750;
    font-size: 14px;
    margin-bottom: 2px;
}

.map-tooltip-metric {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
}
