/* ================================================================
   page-country-shared.css  –  Compliance Checker

   Styles shared by both /country (EU member state) and
   /country-export (producing country) pages. Page-specific
   overrides live in page-country.css and page-country-export.css.
   ================================================================ */


/* === PAGE HEADER ================================================
   Two-column split header used at the top of both /country and
   /country-export. Left column: flag + country name + page type
   label. Right column: total-volume stat + optional rank pill
   (rank pill is country-only; its style lives in page-country.css). */

.page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.2fr);
    align-items: center;
    gap: var(--space-xl);
    padding: var(--space-lg);
    background-color: var(--white);
    border-radius: var(--radius-dropdown);
    box-shadow: var(--shadow);
    max-width: var(--page-max);
    margin: clamp(1rem, 2vw, 2rem) auto var(--space-2xl);
}

.page-header__left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 0;
}

.page-header__flag {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.page-header__country {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.page-header__country-name {
    font-family: var(--font-heading);
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    line-height: 1.1;
    letter-spacing: -0.5px;
    color: var(--ae-darkblue);
    margin: 0;
}

.page-header__country-type {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: var(--ls-uppercase);
    text-transform: uppercase;
    color: var(--color-muted);
}

.page-header__divider {
    align-self: stretch;
    width: 1px;
    background-color: color-mix(in srgb, var(--ae-darkblue) 20%, transparent);
}

.page-header__right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    gap: 0.5rem;
    min-width: 0;
}

.page-header__stat-number {
    font-family: var(--font-heading);
    font-size: clamp(1.4rem, 2.85vw, 2.3rem);
    line-height: 1.05;
    letter-spacing: -0.5px;
    color: var(--ae-darkblue);
    text-align: right;
}

/* Unit (MT / €) — used in three contexts:
   1. Bar-volume gutters (default rule): bold muted grey at 0.85em
      so the unit reads as a label next to the number.
   2. Page-header stat number / stat-card value (override below):
      thin teal at reduced opacity so the unit recedes behind the
      headline figure. */
.stat-unit {
    font-weight: 700;
    color: var(--color-muted);
    font-size: 0.85em;
    margin-left: 4px;
}

.page-header__stat-number .stat-unit,
.stat-card__value .stat-unit {
    font-weight: 400;
    color: var(--ae-darkblue);
    opacity: 0.6;
    font-size: 0.55em;
}

.page-header__stat-label {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1.2vw, 1.05rem);
    line-height: 1.4;
    color: var(--text-muted);
    text-align: right;
}


/* === STAT CARDS =================================================
   Four-up summary row that sits directly beneath .page-header on
   both /country and /country-export. Cards mirror the page-header
   surface (white, soft shadow, rounded corners) so the two blocks
   read as a single composition. Cards collapse to 2x2 on tablet
   and to a single column on phone. */

.page-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-sm);
    max-width: var(--page-max);
    margin: 0 auto clamp(1.75rem, 2.5vw, 2.5rem);
}

.stat-card {
    background-color: var(--white);
    border-radius: var(--radius-dropdown);
    box-shadow: var(--shadow);
    padding: clamp(16px, 2vw, 28px);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.stat-card__label {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: var(--ls-uppercase);
    text-transform: uppercase;
    color: var(--color-muted);
}

.stat-card__value {
    font-family: var(--font-heading);
    font-size: clamp(1.4rem, 2.2vw, 2rem);
    line-height: 1.15;
    letter-spacing: -0.5px;
    color: var(--ae-darkblue);
    overflow-wrap: break-word;
}

.stat-card__sublabel {
    font-family: var(--font-body);
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--color-muted);
}


/* === LAYOUT =====================================================
   Page body defaults, select-header, and the shared spacing /
   width rules for the blocks that sit below the page header. */

body {
    background-color: var(--ae-white);
    color: var(--text-muted);
    line-height: 1.6;
}

.select-header {
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-md);
    max-width: var(--page-max);
    margin-left: auto;
    margin-right: auto;
}

.select-header h2 {
    font-size: clamp(1.8rem, 2.5vw, 2.5rem);
    color: var(--ae-darkblue);
    font-weight: 600;
}

/* Summary panel heading — colour is supplied per-page via
   --summary-color on .import-summary / .export-summary. */
.summary-title {
    color: var(--summary-color, var(--ae-darkblue));
    font-size: clamp(1.8rem, 2.5vw, 2.5rem);
    margin-bottom: 1.5rem;
}

/* Commodity list (inside the summary panel) */
.commodity-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.commodity-row {
    display: grid;
    /* Name column scales on ultrawide so it doesn't look stranded
       next to a much wider bar at 2400px+. Icon col stays fixed. */
    grid-template-columns: 50px clamp(200px, 14vw, 320px) 1fr;
    align-items: center;
    gap: 1.5rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-base);
}

.commodity-row:hover {
    background-color: var(--color-row-hover);
}

.commodity-name-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    justify-content: space-between;
}

/* Tonnage gutter — sits inside .commodity-name-container, right-
   aligned next to the bar. Muted-grey number; the unit (.stat-unit)
   is bold in the same muted grey so it reads as a label. */
.bar-volume {
    font-size: var(--fs-sm);
    font-weight: 400;
    color: var(--color-muted);
    text-align: right;
    white-space: nowrap;
    margin-left: auto;
}

.commodity-bar-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.commodity-bar-track {
    height: 20px;
    background-color: transparent;
    border-radius: var(--radius-sm);
    overflow: visible;
    position: relative;
}

.commodity-bar-fill {
    height: 100%;
    background: var(--ae-orange);
    border-radius: var(--radius-sm);
}

/* End-of-bar percentage label. Positioned absolutely at the right
   edge of the fill via inline left: calc({pct}% + 5px). The
   percentage span keeps its own colour; the suffix recedes to
   muted grey so the descriptive text doesn't compete. */
.bar-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 600;
}

.bar-label__suffix {
    font-size: 0.78em;
    font-weight: 400;
    color: var(--color-muted);
}


/* === COMPONENTS =================================================
   Reusable bits used inside summaries, filters, tables, and cells. */

/* Commodity name + rank-based size variants */
.commodity-name {
    font-weight: 500;
    color: var(--ae-darkblue);
    transition: font-size var(--transition-base);
}

.top-export    .commodity-name       { font-size: 1.4rem; font-weight: 700; }
.second-export .commodity-name       { font-size: 1.2rem; font-weight: 600; }
.third-export  .commodity-name       { font-size: 1.1rem; font-weight: 600; }
.other-export  .commodity-name       { font-size: 1rem;   font-weight: 500; }
.top-export    .commodity-percentage { font-size: 1.2rem; }
.second-export .commodity-percentage { font-size: 1.1rem; }
.third-export  .commodity-percentage { font-size: 1rem;   }
.other-export  .commodity-percentage { font-size: 0.9rem; }

.commodity-percentage {
    color: var(--ae-orange);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Commodity filter — grid of icon-tile buttons */
.commodity-filter {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(10px, 1.5vw, 18px);
    margin-bottom: var(--space-md);
    background-color: var(--white);
    padding: clamp(1.5rem, 2.5vw, 2rem);
    border-radius: var(--radius-dropdown);
    box-shadow: var(--shadow);
    max-width: var(--page-max);
    margin-left: auto;
    margin-right: auto;
}

.commodity-button {
    position: relative;
    background-position: center;
    background-color: var(--white);
    border: 1px solid var(--ae-darkblue);
    /* Tile size scales on ultrawide so a row of buttons doesn't look
       cramped against a 2400px-wide page width. */
    height: clamp(150px, 11vw, 220px);
    width: clamp(140px, 10vw, 200px);
    cursor: pointer;
    text-align: center;
    font-size: clamp(1rem, 0.9vw, 1.125rem);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-dropdown);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.commodity-button:hover {
    transform: translateY(2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.commodity-button.active {
    background-color: color-mix(in srgb, var(--ae-orange) 30%, transparent);
    transform: translateY(2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.commodity-button__content {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    color: var(--white);
}

.commodity-icon {
    width: 40px;
    height: 40px;
}

.commodity-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.commodity-icon-button {
    width: clamp(100px, 7vw, 150px);
    height: clamp(100px, 7vw, 150px);
    margin-bottom: 10px;
}

.commodity-text {
    font-size: var(--fs-md);
    color: var(--ae-darkblue);
    text-align: center;
}

/* Search / filter bars */
.search-bar {
    background-color: var(--white);
    padding: clamp(1.25rem, 2.5vw, 1.75rem);
    border-radius: var(--radius-dropdown);
    box-shadow: var(--shadow);
    max-width: var(--page-max);
    margin-left: auto;
    margin-right: auto;
}

.search-bar.is-stacked {
    margin-top: var(--space-xs);
}

.search-bar input {
    border: 1px solid var(--color-input-border);
    padding: 0.8rem;
    border-radius: var(--radius-dropdown);
    font-size: 1rem;
}

/* Custom checkbox (used inside .search-bar rows) */
.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-checkbox .form-check-input {
    width: 18px;
    height: 18px;
    margin-top: 0;
    border-color: var(--ae-darkblue);
    cursor: pointer;
}

.custom-checkbox .form-check-input:checked {
    background-color: var(--ae-darkblue);
    border-color: var(--ae-darkblue);
}

.custom-checkbox .form-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    cursor: pointer;
    color: var(--ae-darkblue);
    font-weight: 500;
}

.shipment-filter-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* === INFO ICON ==================================================
   Outline-style affordance shared across both country pages and
   their tooltips. Uses --info-bg / --info-color so surrounding
   sections can re-theme it: in the orange .import-summary panel
   the icon picks up an orange border, in neutral contexts it
   stays dark teal. On hover it inverts to a filled pill. */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    box-sizing: border-box;
    border: 2px solid var(--info-bg, var(--ae-darkblue));
    background: transparent;
    color: var(--info-bg, var(--ae-darkblue));
    border-radius: 50%;
    text-align: center;
    line-height: 1;
    font-size: 11px;
    font-weight: 700;
    cursor: help;
    margin-left: 4px;
    font-style: normal;
    transition: background-color var(--transition-base), color var(--transition-base);
}

.info-icon:hover {
    background-color: var(--info-bg, var(--ae-darkblue));
    color: var(--info-color, var(--white));
}

.info-container {
    position: relative;
    align-items: center;
    display: inline-flex;
    gap: 4px;
    width: 100%;
}

.info-container.is-inline {
    width: auto;
}

.info-tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--info-bg, var(--ae-darkblue));
    color: var(--info-color, var(--white));
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    z-index: var(--z-tooltip);
    margin-bottom: 5px;
    width: max-content;
    max-width: 300px;
    text-align: center;
}

.info-container:hover .info-tooltip {
    visibility: visible;
}

.info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--info-bg, var(--ae-darkblue)) transparent transparent transparent;
}

/* Boat icon (shipment-data availability affordance) */
.boat-icon {
    height: 20px;
    width: 20px;
    cursor: pointer;
    display: block;
    margin-top: 5px;
    position: relative;
}

.boat-icon-wrapper {
    position: relative;
    display: inline-block;
}

.boat-icon-wrapper:hover::after {
    content: 'Click to see available analyzed shipment data';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--ae-darkblue);
    color: var(--white);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    z-index: var(--z-tooltip);
    margin: 5px 0 0;
}

/* Table-cell content (data lives inside table.css rows). Two
   stacked rows: product short-name on top, commodity dot + group
   name beneath. The bottom row reads as supporting metadata so it
   sits a touch smaller in the same muted grey. */
.hs-description {
    font-size: 0.9rem;
    color: var(--color-muted);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hs-description__name {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.hs-description__commodity {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78em;
    color: color-mix(in srgb, var(--color-muted) 60%, var(--white));
}


/* === COMMODITY DOTS =============================================
   Small colour swatch placed before the product description in the
   trade table. Mirrors the case-studies palette so a row's primary
   commodity is identifiable at a glance. Modifier classes pick the
   colour from the shared --commodity-* tokens. Default falls back
   to muted grey if the commodity slug doesn't match a known token. */
.commodity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--color-muted);
}

.commodity-dot--cattle   { background: var(--commodity-cattle);  }
.commodity-dot--cocoa    { background: var(--commodity-cocoa);   }
.commodity-dot--coffee   { background: var(--commodity-coffee);  }
.commodity-dot--corn     { background: var(--commodity-corn);    }
.commodity-dot--cotton   { background: var(--commodity-cotton);  }
.commodity-dot--palm     { background: var(--commodity-palm);    }
.commodity-dot--palm-oil { background: var(--commodity-palm);    }
.commodity-dot--poultry  { background: var(--commodity-poultry); }
.commodity-dot--rubber   { background: var(--commodity-rubber);  }
.commodity-dot--soy      { background: var(--commodity-soy);     }
.commodity-dot--wood     { background: var(--commodity-wood);    }
.commodity-dot--timber   { background: var(--commodity-wood);    }

.hs-percentage-container {
    margin-top: 8px;
    width: 100%;
    display: block;
}

.hs-percentage-bar {
    height: 4px;
    width: calc(100% - 24px);
    background-color: var(--color-track-bg);
    border-radius: 2px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.hs-percentage-fill {
    height: 100%;
    width: var(--percentage-width); /* set inline per row */
    background-color: var(--ae-orange);
    border-radius: 2px;
    display: block;
}

.hs-percentage-text {
    font-size: 0.8rem;
    color: var(--ae-darkblue);
    margin-top: 4px;
    display: block;
}

/* Country cell — flag + name + trade volume + percentage bar */
.country-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.country-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.country-name-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.country-flag {
    width: 25px;
    height: 18px;
    object-fit: cover;
}

.country-name {
    color: var(--ae-darkblue);
    text-decoration: none;
    font-weight: 500;
}

.country-name.has-data {
    text-decoration: underline;
    cursor: pointer;
}

.country-name.no-data {
    color: var(--color-muted);
    cursor: default;
}

.trade-volume {
    font-size: 0.9rem;
    color: var(--color-muted);
}

.percentage-bar {
    width: 100%;
    margin-top: 0.5rem;
    color: var(--ae-darkblue);
}

.percentage-bar .bar-container {
    height: 6px;
    background-color: var(--color-track-bg);
}

.percentage-bar .bar {
    background: var(--ae-darkblue);
    height: 100%;
    width: 0;
    border-radius: var(--radius-dropdown);
}

/* Search-result highlight (applied dynamically by JS) */
.highlight {
    background-color: var(--ae-orange) !important;
    border-left: 4px solid var(--ae-orange);
}

/* Data freshness card (bottom of each page) */
.data-freshness-card {
    display: inline-flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: clamp(0.85rem, 1.5vw, 1.25rem) var(--space-md);
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-2xl);
    margin-left: auto;
    margin-right: auto;
    background: linear-gradient(180deg,
        var(--color-data-panel-bg-top) 0%,
        var(--color-data-panel-bg-bottom) 100%);
    border: 1px solid var(--color-data-panel-border);
    border-left: 4px solid var(--ae-lightgreen);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(24, 62, 53, 0.06);
    max-width: var(--page-max);
}

.data-freshness-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-data-panel-label);
}

.data-freshness-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ae-darkblue);
    line-height: 1.4;
}

.data-freshness-subvalue {
    font-size: 0.88rem;
    color: var(--color-data-panel-subvalue);
}

/* Utility — circular product image in the trade table */
.product-image-circle {
    border-radius: 50%;
    object-fit: cover;
}


/* === TABLE OVERRIDES ============================================
   Page-level overrides on top of the global table.css rules. */

/* Width cap so the trade-data table lines up with the other top-level
   blocks (summary, filter, search, freshness). On the country page
   the wrapper sits inside .table-section, which already caps width,
   so this rule is inert there. */
.table-scroll-wrapper {
    max-width: var(--page-max);
    margin-left: auto;
    margin-right: auto;
}

/* First-column tooltips anchor to the right of the cell so they
   don't clip on the left edge. */
td:first-child .info-container {
    position: relative;
}

td:first-child .info-tooltip {
    left: auto;
    right: -263px;
    transform: none;
    min-width: 250px;
}

td:first-child .info-tooltip::after {
    left: 30px;
}


/* === RESPONSIVE (tablet) =======================================
   Filled in during the separate responsive pass. */
@media (max-width: 1400px) {
    /* TODO: responsive pass */
}

/* === RESPONSIVE (mobile) =======================================
   Page header stacks vertically; left-border accent becomes a
   top-border accent. Stat-card row collapses to a 2x2 grid. */
@media (max-width: 768px) {
    .page-header {
        grid-template-columns: 1fr;
        border-left: none;
        border-top: 4px solid var(--ae-darkblue);
    }
    .page-header__flag {
        width: 100%;
        height: auto;
        aspect-ratio: 60 / 40;
        max-width: 200px;
    }
    .page-header__divider {
        display: none;
    }
    .page-header__right {
        align-items: stretch;
    }
    .page-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* === RESPONSIVE (small mobile) =================================
   Stat cards stack into a single column. */
@media (max-width: 480px) {
    .page-stats {
        grid-template-columns: 1fr;
    }
}
