/* Edytor CKEditor zapisuje tabele jako <figure class="table"><table>...</table></figure> */
.frame-type-text figure.table,
.frame-type-textpic figure.table {
    display: block;
    width: 100%;
    margin: 0 0 32px;
}
.frame-type-text figure.table table,
.frame-type-textpic figure.table table {
    margin-bottom: 0;
}

/*
 * Tabele w treści (cenniki, godziny przyjęć i inne tabele z edytora RTE).
 *
 * Obsługiwane układy:
 * - cennik: <thead> z nagłówkiem, ostatnia kolumna to cena, wiersze-podtytuły
 *   jako <tr><th colspan="2">...</th></tr>;
 * - tabela "klucz -> wartość": pierwsza komórka wiersza to <th scope="row">;
 * - stary format z RTE bez <thead>: pierwszy wiersz traktowany jako nagłówek.
 */
.frame-type-text table,
.frame-type-textpic table {
    width: 100%;
    margin: 0 0 32px;
    border-collapse: collapse;
    border: 1px solid #e1e8ef;
    font-size: 15px;
    line-height: 1.45;
    background: #fff;
}

.frame-type-text table td,
.frame-type-text table th,
.frame-type-textpic table td,
.frame-type-textpic table th {
    padding: 10px 16px;
    border-bottom: 1px solid #e1e8ef;
    text-align: left;
    vertical-align: middle;
    color: #222;
    font-weight: 400;
}

/* Nagłówek tabeli */
.frame-type-text table thead th,
.frame-type-textpic table thead th,
.frame-type-text table:not(:has(thead)):not(:has(th)) tr:first-child > td,
.frame-type-textpic table:not(:has(thead)):not(:has(th)) tr:first-child > td {
    background: #0a6ca8;
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: 13px;
    border-bottom: 0;
}
.frame-type-text table tr:first-child > td strong,
.frame-type-textpic table tr:first-child > td strong {
    color: inherit;
}

/* Naprzemienne tło wierszy */
.frame-type-text table tbody tr:nth-child(even) > td,
.frame-type-textpic table tbody tr:nth-child(even) > td {
    background: #f4f9fd;
}

.frame-type-text table tbody tr:hover > td,
.frame-type-textpic table tbody tr:hover > td {
    background: #e6f3fc;
}

/* Ostatnia kolumna (cena, godziny) */
.frame-type-text table td:last-child,
.frame-type-text table thead th:last-child,
.frame-type-textpic table td:last-child,
.frame-type-textpic table thead th:last-child {
    width: 1%;
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
}

/* Wiersz-podtytuł (np. "Pierwotne leczenie kanałowe"): komórka na całą szerokość.
   Edytor CKEditor przenosi podtytuł stojący zaraz pod nagłówkiem do <thead>,
   dlatego styl dotyczy th[colspan] w każdej części tabeli. */
.frame-type-text table tr th[colspan],
.frame-type-textpic table tr th[colspan],
.frame-type-text table:not(:has(th)) tr > td:only-child,
.frame-type-textpic table:not(:has(th)) tr > td:only-child {
    width: auto;
    background: #e6f3fc;
    color: #0a6ca8;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0;
    text-align: left;
    text-transform: none;
    white-space: normal;
    border-bottom: 1px solid #e1e8ef;
}

/* Tabela "klucz -> wartość" */
.frame-type-text table tbody th[scope="row"],
.frame-type-textpic table tbody th[scope="row"] {
    width: 32%;
    font-weight: 700;
    background: #f4f9fd;
}
.frame-type-text table th[scope="row"] + td,
.frame-type-textpic table th[scope="row"] + td {
    width: auto;
    text-align: left;
    white-space: normal;
    font-weight: 400;
}

.frame-type-text table p,
.frame-type-textpic table p {
    margin: 0;
}

@media (max-width: 767px) {
    .frame-type-text table,
    .frame-type-textpic table {
        font-size: 14px;
    }

    .frame-type-text table td,
    .frame-type-text table th,
    .frame-type-textpic table td,
    .frame-type-textpic table th {
        padding: 9px 10px;
    }

    .frame-type-text table tbody th[scope="row"],
    .frame-type-textpic table tbody th[scope="row"] {
        width: 40%;
    }
}
