/**
 * Table Shortcode Styles
 *
 * BEM naming convention: .oe-table (block), __element, --modifier
 * Styles: default, striped, bordered, minimal, compact
 * Responsive: scroll, stack, collapse
 */

/* ==========================================================================
   Wrapper
   ========================================================================== */

.oe-table-wrapper {
    margin: 1.5em 0;
    max-width: 100%;
    font-family: inherit;
    border-radius: 8px;
    overflow: hidden;
    background: var(--oe-color-white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}

/* Scroll responsive mode */
.oe-table-wrapper--scroll {
    overflow-x: auto;
}

/* ==========================================================================
   Title
   ========================================================================== */

.oe-table__title {
    margin: 0;
    padding: 14px 16px;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--oe-color-text-dark);
    background: var(--oe-color-bg);
    border-bottom: 1px solid var(--oe-color-border);
}

/* ==========================================================================
   Base Table
   ========================================================================== */

.oe-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9375em;
    line-height: 1.5;
    background: var(--oe-color-white);
}

/* ==========================================================================
   Header
   ========================================================================== */

.oe-table thead {
    background: linear-gradient(135deg, var(--oe-color-primary) 0%, var(--oe-color-primary-dark) 100%);
}

.oe-table th {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.8125em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    color: var(--oe-color-white);
    background: transparent;
    border: none;
    white-space: nowrap;
}

/* Rounded header corners (when no title above) */
.oe-table-wrapper:not(:has(.oe-table__title)) .oe-table th:first-child {
    border-radius: 8px 0 0 0;
}

.oe-table-wrapper:not(:has(.oe-table__title)) .oe-table th:last-child {
    border-radius: 0 8px 0 0;
}

/* ==========================================================================
   Body
   ========================================================================== */

.oe-table tbody {
    background: var(--oe-color-white);
}

.oe-table td {
    padding: 12px 16px;
    color: var(--oe-color-text-dark);
    border: none;
    border-bottom: 1px solid var(--oe-color-bg-alt);
    vertical-align: middle;
}

.oe-table tbody tr {
    background: var(--oe-color-white);
    transition: background-color 0.15s ease;
}

/* Last row - no border, rounded bottom corners */
.oe-table tbody tr:last-child td {
    border-bottom: none;
}

.oe-table tbody tr:last-child td:first-child {
    border-radius: 0 0 0 8px;
}

.oe-table tbody tr:last-child td:last-child {
    border-radius: 0 0 8px 0;
}

/* Numeric cells */
.oe-table__cell--numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Links */
.oe-table a {
    color: var(--oe-color-primary);
    text-decoration: none;
    font-weight: 500;
}

.oe-table a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.oe-table tfoot td {
    font-weight: 600;
    color: var(--oe-color-text-dark);
    background: var(--oe-color-bg);
    border-top: 2px solid var(--oe-color-border);
    border-bottom: none;
}

/* ==========================================================================
   Highlight Row
   ========================================================================== */

.oe-table__row--highlight {
    background: var(--oe-color-primary-tint) !important;
}

.oe-table__row--highlight td {
    font-weight: 600;
    color: var(--oe-color-primary-dark);
}

/* ==========================================================================
   Style: Default — alternating rows + hover
   ========================================================================== */

.oe-table--default tbody tr:nth-child(even) {
    background: var(--oe-color-bg);
}

.oe-table--hover tbody tr:hover {
    background: var(--oe-color-bg-alt);
}

.oe-table--hover tbody tr:nth-child(even):hover {
    background: var(--oe-color-border-light);
}

/* ==========================================================================
   Style: Striped (explicit or legacy)
   ========================================================================== */

.oe-table--striped tbody tr:nth-child(odd) {
    background: var(--oe-color-white);
}

.oe-table--striped tbody tr:nth-child(even) {
    background: var(--oe-color-bg);
}

/* ==========================================================================
   Style: Bordered
   ========================================================================== */

.oe-table--bordered td,
.oe-table--bordered th {
    border: 1px solid var(--oe-color-border);
}

.oe-table--bordered tbody tr:last-child td {
    border-bottom: 1px solid var(--oe-color-border);
}

/* ==========================================================================
   Style: Minimal — no background, thin dividers
   ========================================================================== */

.oe-table--minimal {
    box-shadow: none;
}

.oe-table-wrapper:has(.oe-table--minimal) {
    box-shadow: none;
}

.oe-table--minimal thead {
    background: none;
}

.oe-table--minimal th {
    color: var(--oe-color-text-muted);
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid var(--oe-color-border);
    padding: 8px 16px;
}

.oe-table--minimal td {
    border-bottom: 1px solid var(--oe-color-bg-alt);
}

.oe-table--minimal tfoot td {
    background: transparent;
    border-top: 2px solid var(--oe-color-border);
}

/* ==========================================================================
   Style: Compact
   ========================================================================== */

.oe-table--compact {
    font-size: 0.875em;
}

.oe-table--compact th,
.oe-table--compact td {
    padding: 8px 12px;
}

/* ==========================================================================
   Alignment
   ========================================================================== */

.oe-table--align-center th,
.oe-table--align-center td {
    text-align: center;
}

.oe-table--align-right th,
.oe-table--align-right td {
    text-align: right;
}

/* Numeric cells always stay right-aligned */
.oe-table--align-left .oe-table__cell--numeric,
.oe-table--align-center .oe-table__cell--numeric {
    text-align: right;
}

/* ==========================================================================
   Sortable
   ========================================================================== */

.oe-table--sortable th {
    cursor: pointer;
    user-select: none;
}

.oe-table__sort-icon {
    display: inline-block;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.oe-table--sortable th:hover .oe-table__sort-icon {
    opacity: 0.7;
}

.oe-table th[aria-sort="ascending"] .oe-table__sort-icon,
.oe-table th[aria-sort="descending"] .oe-table__sort-icon {
    opacity: 1;
}

.oe-table th[aria-sort="ascending"] .oe-table__sort-icon path:last-child,
.oe-table th[aria-sort="descending"] .oe-table__sort-icon path:first-child {
    opacity: 0.2;
}

.oe-table th[aria-sort="ascending"] .oe-table__sort-icon path:first-child,
.oe-table th[aria-sort="descending"] .oe-table__sort-icon path:last-child {
    opacity: 1;
}

/* ==========================================================================
   Responsive: Stack (mobile cards)
   ========================================================================== */

@media (max-width: 640px) {
    .oe-table-wrapper--stack .oe-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .oe-table-wrapper--stack .oe-table tbody tr {
        display: block;
        margin-bottom: 0.75em;
        border: 1px solid var(--oe-color-border);
        border-radius: 8px;
        background: var(--oe-color-white);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    .oe-table-wrapper--stack .oe-table tbody tr:last-child {
        margin-bottom: 0;
    }

    .oe-table-wrapper--stack .oe-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 14px;
        border-bottom: 1px solid var(--oe-color-bg-alt);
        text-align: right;
    }

    .oe-table-wrapper--stack .oe-table td:last-child {
        border-bottom: none;
    }

    .oe-table-wrapper--stack .oe-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.85em;
        color: var(--oe-color-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-align: left;
        margin-right: 1em;
    }

    .oe-table-wrapper--stack .oe-table__row--highlight {
        border-color: var(--oe-color-primary-light);
        background: var(--oe-color-primary-tint);
    }

    .oe-table-wrapper--stack .oe-table__cell--numeric {
        text-align: right;
    }

    /* Collapse: hide extra columns */
    .oe-table-wrapper--collapse .oe-table td:nth-child(n+4),
    .oe-table-wrapper--collapse .oe-table th:nth-child(n+4) {
        display: none;
    }
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
    .oe-table-wrapper {
        box-shadow: none;
        page-break-inside: avoid;
    }

    .oe-table {
        background: none !important;
        font-size: 10pt;
    }

    .oe-table thead {
        background: #eee !important;
    }

    .oe-table th {
        color: #000 !important;
    }

    .oe-table th,
    .oe-table td {
        border: 1px solid #999 !important;
        background: none !important;
    }

    .oe-table__row--highlight {
        background: #eee !important;
    }

    .oe-table__row--highlight td {
        color: #000;
    }

    .oe-table__sort-icon {
        display: none;
    }
}
