/* ================================================================
   components/table-base.css  –  Compliance Checker

   Table CHASSIS — shared by all variants. Variant files:
     • components/table-trade-flows.css   .cc-table--trade-flows
     • components/table-case-studies.css  .cc-table--case-studies

   Sections:
     1.  .cc-table-card    2.  .cc-table-scroll  3.  .cc-table
     4.  .cc-table__head   5.  .cc-table__body   6.  .cc-table__row
     7.  .cc-table__cell   8.  .cc-table__sort   9.  .cc-table__group
    10.  .cc-table__empty
================================================================ */


/* === 1. CARD CHROME === */
/* overflow:hidden lets the radius clip the teal header strip at the corners. */
.cc-table-card,
.table-section,
.chart-section {
    background: var(--white);
    border: 1px solid var(--color-track-bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}


/* === 2. SCROLL WRAPPER === */

.cc-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}


/* === 3. TABLE === */
/* Positioning anchor for the variant modifier; grid-template-columns
   is set per variant in the variant file. */

.cc-table {
    /* No own display / background — chrome comes from .cc-table-card. */
}


/* === 4. HEADER STRIP === */

.cc-table__head {
    background: var(--ae-darkblue);
    color: var(--white);
    padding: 14px 16px;
    font-size: var(--fs-sm);
    font-weight: 500;
    border-bottom: 1px solid color-mix(in srgb, var(--ae-darkblue) 25%, transparent);
}

/* Header + row share grid-template-columns so columns stay aligned.
   The template lives on the variant modifier. */
.cc-table__head,
.cc-table__row {
    display: grid;
    gap: 12px;
    align-items: start;
}


/* === 5. BODY === */

.cc-table__body {
    /* No own styling — see .cc-table__row below. */
}


/* === 6. ROW === */

.cc-table__row {
    padding: 14px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--color-track-bg);
    font-size: var(--fs-md);
    transition: background .12s;
}

.cc-table__row:last-child {
    border-bottom: none;
}

.cc-table__row:hover {
    background: color-mix(in srgb, var(--ae-lightgreen) 18%, transparent);
}

/* Filter-driven hidden rows — display:none beats the grid layout. */
.cc-table__row[hidden] {
    display: none;
}


/* === 7. CELL === */
/* min-width:0 lets grid children shrink past their intrinsic content
   width, enabling text ellipsis in constrained columns. */

.cc-table__cell {
    min-width: 0;
}


/* === 8. SORT BUTTON === */

.cc-table__sort {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--white);
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    transition: opacity .15s;
}

.cc-table__sort:hover {
    opacity: 0.85;
}

.cc-table__sort:hover .cc-table__sort-arrow {
    opacity: 1;
}

.cc-table__sort-arrow {
    font-size: 14px;
    line-height: 1;
    opacity: 0.55;
    transition: transform .2s ease, opacity .15s;
}

.cc-table__sort.is-active .cc-table__sort-arrow {
    opacity: 1;
}

/* Base glyph is fa-arrow-down (↓); flip on asc so the arrow points up. */
.cc-table__sort[data-direction="asc"] .cc-table__sort-arrow {
    transform: rotate(180deg);
}


/* === 9. GROUP HEADER === */

.cc-table__group {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(180deg, var(--card-bg), var(--white));
    border-top: 2px solid var(--group-color, var(--ae-darkblue));
    border-bottom: 1px solid var(--color-input-border);
    font-weight: 600;
    color: var(--ae-darkblue);
    font-size: var(--fs-md);
}


/* === 10. EMPTY STATE === */

.cc-table__empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--color-muted);
    font-size: 13px;
    background: var(--card-bg);
}


/* === LEGACY <table class="table"> SHIM (deprecated) === */
/* Used by commodity_detail.html's #sortableTable / #tradeTable /
   #tradeTableExport pending .cc-table* migration. Remove once ported. */

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--white);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-dropdown);
    overflow: hidden;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
}

.table thead tr {
    height: 120px;
}

.table thead th {
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}


/* === RESPONSIVE === */
/* sm  ≤ 767px — phones: tighter cell padding + legacy shim. */
@media (max-width: 767px) {
    .cc-table__head,
    .cc-table__row {
        padding: 12px;
        gap: 8px;
    }
    .table td {
        padding: 0.5rem 0.75rem;
    }
    .table thead tr {
        height: 80px;
    }
}
