/**
 * DigiSEO — bảng: viền đậm, chữ rõ, header xanh + zebra + hover.
 * UI đặc biệt: class no-digiseo-table để bỏ qua.
 */

:root {
    --digiseo-table-border: #0f172a;
    --digiseo-table-border-w: 2px;
    --digiseo-table-head-bg: #43a047;
    --digiseo-table-head-text: #ffffff;
    --digiseo-table-row-odd: #ffffff;
    --digiseo-table-row-even: #e8f5e9;
    --digiseo-table-row-hover: #a5d6a7;
    --digiseo-table-cell-text: #0f172a;
}

html[data-theme="dark"],
body.page-tool:not([data-theme="light"]) {
    /* Bảng trong bài vẫn nền sáng → giữ chữ đậm, viền đậm */
    --digiseo-table-border: #0f172a;
    --digiseo-table-border-w: 2px;
    --digiseo-table-head-bg: #388e3c;
    --digiseo-table-head-text: #ffffff;
    --digiseo-table-row-odd: #ffffff;
    --digiseo-table-row-even: #e8f5e9;
    --digiseo-table-row-hover: #81c784;
    --digiseo-table-cell-text: #0f172a;
}

.digiseo-table-wrap {
    overflow-x: auto;
    margin: 1.25rem 0;
    padding: 0;
    -webkit-overflow-scrolling: touch;
}

table.digiseo-table,
table:not(.no-digiseo-table) {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-family: Inter, system-ui, "Segoe UI", sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--digiseo-table-cell-text) !important;
    border: var(--digiseo-table-border-w) dashed var(--digiseo-table-border) !important;
    background: var(--digiseo-table-row-odd);
    opacity: 1 !important;
}

table.digiseo-table th,
table.digiseo-table td,
table:not(.no-digiseo-table) th,
table:not(.no-digiseo-table) td {
    padding: 12px 16px;
    vertical-align: middle;
    border: var(--digiseo-table-border-w) dashed var(--digiseo-table-border) !important;
    text-align: left;
    color: var(--digiseo-table-cell-text) !important;
    font-weight: 500;
    opacity: 1 !important;
    -webkit-font-smoothing: antialiased;
}

table.digiseo-table thead th,
table:not(.no-digiseo-table) thead th {
    background: var(--digiseo-table-head-bg) !important;
    color: var(--digiseo-table-head-text) !important;
    font-weight: 700 !important;
    text-align: center;
    white-space: nowrap;
}

table.digiseo-table thead th:not(:first-child),
table.digiseo-table tbody td:not(:first-child),
table:not(.no-digiseo-table) thead th:not(:first-child),
table:not(.no-digiseo-table) tbody td:not(:first-child) {
    text-align: center;
}

table.digiseo-table:not(:has(thead)) tbody tr:first-child td,
table:not(.no-digiseo-table):not(:has(thead)) tbody tr:first-child td {
    background: var(--digiseo-table-head-bg) !important;
    color: var(--digiseo-table-head-text) !important;
    font-weight: 700 !important;
    text-align: center;
}

table.digiseo-table:not(:has(thead)) tbody tr:first-child td:first-child,
table:not(.no-digiseo-table):not(:has(thead)) tbody tr:first-child td:first-child {
    text-align: left;
}

table.digiseo-table tbody tr:nth-child(odd),
table:not(.no-digiseo-table) tbody tr:nth-child(odd) {
    background: var(--digiseo-table-row-odd) !important;
}

table.digiseo-table tbody tr:nth-child(even),
table:not(.no-digiseo-table) tbody tr:nth-child(even) {
    background: var(--digiseo-table-row-even) !important;
}

table.digiseo-table tbody tr:hover,
table:not(.no-digiseo-table) tbody tr:hover {
    background: var(--digiseo-table-row-hover) !important;
    transition: background 0.12s ease;
}

table.digiseo-table tbody tr:hover td,
table:not(.no-digiseo-table) tbody tr:hover td {
    color: #0f172a !important;
}

/* Editor Content AI — không kế thừa chữ xám của shell tối */
.content-render table.digiseo-table,
.content-render table:not(.no-digiseo-table),
#contentRender table.digiseo-table,
#contentRender table:not(.no-digiseo-table),
.preview-body table.digiseo-table,
.preview-body table:not(.no-digiseo-table),
.ad-content-preview table.digiseo-table,
.ad-content-preview table:not(.no-digiseo-table) {
    border: var(--digiseo-table-border-w) dashed var(--digiseo-table-border) !important;
}

.content-render table th,
.content-render table td,
#contentRender table th,
#contentRender table td,
.preview-body table th,
.preview-body table td {
    color: #0f172a !important;
    opacity: 1 !important;
    border-color: #0f172a !important;
}

.content-render table thead th,
#contentRender table thead th,
.preview-body table thead th {
    background: #43a047 !important;
    color: #ffffff !important;
}

.content-render table,
#contentRender table,
.preview-body table,
.ad-content-preview table,
.history-preview table {
    margin: 1.25rem 0;
}

/* TinyMCE iframe */
.mce-content-body table.digiseo-table th,
.mce-content-body table.digiseo-table td,
.mce-content-body table:not(.no-digiseo-table) th,
.mce-content-body table:not(.no-digiseo-table) td {
    color: #0f172a !important;
    border: 2px dashed #0f172a !important;
    opacity: 1 !important;
}

.mce-content-body table thead th,
.mce-content-body table:not(.no-digiseo-table) thead th {
    background: #43a047 !important;
    color: #ffffff !important;
}
