/* ================================================================
   table.css  –  Compliance Checker
   Global table styles. Loaded on every page via base.html so any
   <table class="table"> inherits a consistent look.

   Base rules mirror the existing country-page appearance so no
   page that already used <table class="table"> visually shifts.
   Zebra striping, compact padding, row hover, and numeric-column
   alignment are opt-in via modifier classes — they do nothing
   unless the table explicitly requests them.
   ================================================================ */


/* === BASE TABLE ================================================ */

.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;
}


/* === HEADER ==================================================== */

.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);
}

/* Bootstrap 5's `.table > :not(caption) > * > *` rule has specificity
   (0,1,1) and forces background/padding on every cell. To override
   without !important we need a selector that beats it — `.table
   th.header-cell` at (0,2,1) wins cleanly. */
.table th.header-cell {
    background-color: var(--ae-darkblue);
    padding: 1rem;
    vertical-align: top;
}

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

.header-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--white);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-subtitle {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: normal;
    text-transform: none;
}


/* === RANKING HEADER-CELL ENHANCEMENT =========================== */

.rank-badge {
    background-color: var(--ae-orange);
    color: var(--white);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ranking-cell .header-content {
    position: relative;
    padding-top: 0.5rem;
}

/* === SORT BUTTON (in header) =================================== */

.sort-button {
    position: relative;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--white);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.sort-button::before {
    content: '';
    visibility: hidden;
    position: absolute;
    bottom: 100%;
    left: 100%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--info-bg, var(--ae-darkblue)) transparent transparent transparent;
    margin-bottom: -5px;
}

.sort-button:hover::before { visibility: visible; }

.sort-button::after {
    content: attr(data-tooltip);
    visibility: hidden;
    position: absolute;
    bottom: 100%;
    left: 100%;
    background-color: var(--ae-darkblue);
    color: var(--white);
    padding: 8px 12px;
    border: 1px solid var(--white);
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    z-index: var(--z-tooltip);
    margin-bottom: 5px;
    width: max-content;
    text-align: center;
}

.sort-button:hover::after { visibility: visible; }

.sort-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    position: relative;
}

.sort-icon.asc::after  { content: '↑'; }
.sort-icon.desc::after { content: '↓'; }
.sort-icon.none::after { content: '↕'; }


/* === RESPONSIVE WRAPPER ======================================== */

/* Wrap any <table class="table"> in <div class="table-scroll-wrapper">
   to allow horizontal scroll on narrow viewports instead of the
   table bursting out of its container. */
.table-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}


/* === RESPONSIVE ================================================ */

@media (max-width: 768px) {
    .table td {
        padding: 0.5rem 0.75rem;
    }
    .table thead tr {
        height: 80px;
    }
    .header-title {
        font-size: 0.95rem;
    }
}
