/* ============================================================
   Blog Single - Universal table styling + Mobile tabs
   Desktop : every table in blog content = full-width styled
   Mobile  : table hidden, tappable tabs (accordion) shown
   Prefix  : ctsmt- (no conflicts with theme/Elementor)

   Wrapper-agnostic scope (matches any blog single content box):
     .c__article .m__textBlock | .single .entry-content |
     .single .post-content | .single .c__article | .blog-content
   ============================================================ */

/* =====================================================
   DESKTOP TABLE (all viewports; tabs hide it on mobile)
   ===================================================== */
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table {
    width: 100% !important;
    height: auto !important;
    border-collapse: collapse;
    border-spacing: 0;
    margin: 24px 0;
    table-layout: auto;
    font-size: 15px;
    line-height: 1.5;
    background: #fff;
    border: 1px solid #d9dce3;
}

/* Kill inline height: 48px / 24px on rows & cells */
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table tr,
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table th,
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table td {
    height: auto !important;
}

/* Header row */
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table thead th {
    background: #f4f6fb;
    color: #1a1a1a;
    font-weight: 600;
    text-align: left;
    padding: 14px 16px;
    border: 1px solid #d9dce3;
    vertical-align: middle;
}

:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table thead th strong {
    font-weight: 600;
}

/* Body cells */
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table tbody td,
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table tbody th {
    padding: 14px 16px;
    border: 1px solid #d9dce3;
    text-align: left;
    vertical-align: top;
    color: #333;
}

:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table tbody td strong,
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table tbody th strong {
    font-weight: 600;
    color: #1a1a1a;
}

/* Tables with no <thead>: treat first row as header */
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table:not(:has(thead)) tr:first-child td {
    background: #f4f6fb;
    font-weight: 600;
    color: #1a1a1a;
    vertical-align: middle;
}

/* Neutralize editor inline width on tables/cells so columns distribute */
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table[style],
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table td[style],
:is(.c__article .m__textBlock,
    .single .entry-content,
    .single .post-content,
    .single .c__article,
    .blog-content) table th[style] {
    width: auto !important;
}

/* Accordion hidden on desktop */
.ctsmt-accordion {
    display: none;
}

/* =====================================================
   MOBILE (<= 767px): tabs instead of table
   ===================================================== */
@media (max-width: 767px) {

    /* Hide every processed table, show its tabs */
    table.ctsmt-source-table {
        display: none !important;
    }

    .ctsmt-accordion {
        display: block;
        margin: 24px 0;
        border: 1px solid #d9dce3;
        border-radius: 8px;
        overflow: hidden;
        background: #fff;
    }

    .ctsmt-item + .ctsmt-item {
        border-top: 1px solid #d9dce3;
    }

    /* Tab button (row title) */
    .ctsmt-tab {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        padding: 14px 16px;
        background: #f4f6fb;
        border: 0;
        margin: 0;
        cursor: pointer;
        text-align: left;
        font-size: 15px;
        line-height: 1.45;
        font-weight: 600;
        color: #1a1a1a;
        font-family: inherit;
        -webkit-tap-highlight-color: transparent;
        transition: background-color 0.2s ease;
    }

    .ctsmt-tab:hover,
    .ctsmt-tab:focus-visible {
        background: #e9edf7;
    }

    .ctsmt-tab[aria-expanded="true"] {
        background: #e9edf7;
    }

    .ctsmt-tab-label {
        flex: 1 1 auto;
        min-width: 0;
    }

    .ctsmt-tab-label strong {
        font-weight: 600;
    }

    /* Chevron icon */
    .ctsmt-tab-icon {
        flex: 0 0 auto;
        width: 10px;
        height: 10px;
        border-right: 2px solid #5a6478;
        border-bottom: 2px solid #5a6478;
        transform: rotate(45deg);
        transition: transform 0.25s ease;
        margin-top: -4px;
    }

    .ctsmt-tab[aria-expanded="true"] .ctsmt-tab-icon {
        transform: rotate(-135deg);
        margin-top: 4px;
    }

    /* Panel (details) */
    .ctsmt-panel {
        background: #fff;
    }

    .ctsmt-panel-inner {
        padding: 14px 16px 16px;
        opacity: 0;
        transform: translateY(-4px);
        transition: opacity 0.25s ease, transform 0.25s ease;
    }

    .ctsmt-panel.ctsmt-open .ctsmt-panel-inner {
        opacity: 1;
        transform: translateY(0);
    }

    .ctsmt-field + .ctsmt-field {
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px dashed #e3e6ee;
    }

    .ctsmt-field-label {
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #6b7280;
        margin-bottom: 4px;
    }

    .ctsmt-field-value {
        font-size: 14px;
        line-height: 1.55;
        color: #333;
    }

    .ctsmt-field-value strong {
        font-weight: 600;
        color: #1a1a1a;
    }
}
