/* =======================================================================
   Smart Tables frontend
   Theme colors are injected as CSS variables from plugin settings.
======================================================================= */
.smart-table-title-text,
.smart-table-wrap,
.smart-table-wrap * {
    box-sizing: border-box;
}

.smart-table-title-text {
    color: var(--smart-title-color, #081a2e);
    font-size: clamp(18px, 2.1vw, 24px);
    font-weight: 800;
    line-height: 1.55;
    text-align: center;
    margin: 20px 0 14px;
    overflow-wrap: anywhere;
}

/* Outer scroll container keeps real table semantics on small screens. */
.smart-table-wrap {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--smart-border-color, #b9c2cc);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    margin: 0 0 26px;
    background: var(--smart-row-bg, #f7f3ec);
    scrollbar-width: thin;
    scrollbar-color: var(--smart-border-color, #b9c2cc) transparent;
}

.smart-table-wrap::-webkit-scrollbar {
    height: 7px;
}

.smart-table-wrap::-webkit-scrollbar-thumb {
    background: var(--smart-border-color, #b9c2cc);
    border-radius: 999px;
}

.smart-table {
    width: 100%;
    min-width: 100%;
    border: 0;
    border-spacing: 0;
    border-collapse: separate;
    table-layout: auto;
    margin: 0;
    background: transparent;
}

.smart-table thead tr {
    background: var(--smart-header-bg, #081a2e);
    color: var(--smart-header-text, #f7f3ec);
}

.smart-table th,
.smart-table td {
    min-width: 0;
    padding: 11px 12px;
    border: 0;
    border-left: 1px solid var(--smart-border-color, #b9c2cc);
    border-bottom: 1px solid var(--smart-border-color, #b9c2cc);
    text-align: center;
    vertical-align: middle;
    font-size: 15px;
    line-height: 1.75;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.smart-table th:last-child,
.smart-table td:last-child {
    border-left: 0;
}

.smart-table th {
    color: var(--smart-header-text, #f7f3ec);
    font-weight: 700;
    background: var(--smart-header-bg, #081a2e);
}

.smart-table tbody td {
    color: inherit;
    background: var(--smart-row-bg, #f7f3ec);
}

.smart-table tbody tr:nth-child(even) td {
    background: var(--smart-stripe-bg, #b9c2cc);
}

/* The wrapper itself provides the bottom edge; avoid a fake-looking blank row. */
.smart-table tbody tr:last-child td {
    border-bottom: 0;
}

/* Rows beyond the initial visible-row limit. */
.smart-hidden-row {
    display: none;
}

/* More / less toggle */
button.smart-more {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 0;
    border-top: 1px solid var(--smart-border-color, #b9c2cc);
    border-radius: 0;
    background: var(--smart-more-bg, #ff6b5a);
    color: var(--smart-more-text, #081a2e);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.8;
    text-align: center;
    transition: filter .15s ease, background .15s ease, color .15s ease;
}

button.smart-more:hover,
button.smart-more:focus-visible {
    filter: brightness(.97);
    outline: 2px solid var(--smart-header-bg, #081a2e);
    outline-offset: -3px;
}

button.smart-more .arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

button.smart-more.open {
    background: var(--smart-row-bg, #f7f3ec);
    color: var(--smart-more-text, #081a2e);
}

/* Kept for compatibility with old saved output. */
.smart-table.smart-no-header thead {
    display: none;
}

/* =======================================================================
   Responsive behavior
   We preserve a semantic table and enable horizontal scrolling only when
   columns genuinely no longer fit. This is safer than converting cells to
   cards, especially with rowspan/colspan.
======================================================================= */
@media (max-width: 767px) {
    .smart-table-title-text {
        font-size: 17px;
        margin: 14px 0 10px;
    }

    .smart-table-wrap {
        border-radius: 10px;
        margin-bottom: 20px;
    }

    .smart-table {
        width: auto;
        min-width: 100%;
    }

    .smart-table th,
    .smart-table td {
        /* With 4+ columns this intentionally creates a smooth horizontal
           scroll instead of crushing text into unreadable narrow cells. */
        min-width: 104px;
        max-width: 260px;
        padding: 9px 9px;
        font-size: 13px;
        line-height: 1.65;
    }

    button.smart-more {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 420px) {
    .smart-table th,
    .smart-table td {
        min-width: 96px;
        padding: 8px 7px;
        font-size: 12.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    button.smart-more {
        transition: none;
    }
}
