/* ==========================================================================
   MOD_SW_ENWG14A - Netzentgelte nach § 14a EnWG (Stadtwerke Prenzlau)
   Barrierefrei (WCAG 2.1 AA / BITV 2.0) & Responsive
   ========================================================================== */

.sw-enwg14a-module {
    --enwg-primary: var(--color-primary, #003366);
    --enwg-text: var(--color-text, #001E64);
    --enwg-muted: #4A5D75;
    --enwg-surface: var(--font-weiss, #ffffff);
    --enwg-surface-alt: #f4f7fa;
    --enwg-highlight: var(--color-bg-even, #DEEAF1);
    --enwg-highlight-strong: #cfe1ee;
    --enwg-border: #c5d5e4;
    --enwg-border-soft: #dce6f0;
    --enwg-accent: var(--color-brand-green, #52992F);

    margin: 2rem 0;
    font-family: inherit;
    color: var(--enwg-text);
}

.sw-enwg14a-heading {
    color: var(--enwg-primary);
    margin: 0 0 1.25rem 0;
}

.sw-enwg14a-card {
    background-color: var(--enwg-surface);
    border: 1px solid var(--enwg-border);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 30, 100, 0.05);
    overflow: hidden;
}

/* Mobile Kontext-Header (auf Desktop ausgeblendet) */
.sw-enwg14a-mobile-context {
    display: none;
}

/* Tastatur-fokussierbarer Scroll-Container für Zoom-Stufen (WCAG 1.4.10) */
.sw-enwg14a-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.sw-enwg14a-scroll:focus-visible {
    outline: 3px solid var(--enwg-accent);
    outline-offset: -3px;
}

/* Fallback für visually-hidden (falls nicht global geladen) */
.sw-enwg14a-module .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* --------------------------------------------------------------------------
   Desktop-Tabelle (ab 768px)
   -------------------------------------------------------------------------- */
.sw-enwg14a-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    color: var(--enwg-text);
    background-color: var(--enwg-surface);
    font-size: 0.95em;
    line-height: 1.4;
}

.sw-enwg14a-table th,
.sw-enwg14a-table td {
    border-right: 1px solid var(--enwg-border);
    border-bottom: 1px solid var(--enwg-border);
    vertical-align: middle;
}

.sw-enwg14a-table th:last-child,
.sw-enwg14a-table td:last-child {
    border-right: none;
}

.sw-enwg14a-table tbody tr:last-child th,
.sw-enwg14a-table tbody tr:last-child td {
    border-bottom: none;
}

/* Tabellenkopf */
.sw-enwg14a-table thead th {
    background-color: var(--enwg-primary);
    color: var(--enwg-surface);
    font-weight: 700;
    padding: 1rem 1.15rem;
    border-right: 1px solid rgba(255, 255, 255, 0.22);
    border-bottom: 2px solid var(--enwg-primary);
    vertical-align: middle;
}

.sw-enwg14a-table thead th:last-child {
    border-right: none;
}

.sw-enwg14a-th-modul {
    text-align: left;
    width: 34%;
    min-width: 230px;
}

.sw-enwg14a-th-title {
    display: block;
    font-size: 1.05em;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.35rem;
}

.sw-enwg14a-th-sub {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: #e2edf7;
    line-height: 1.35;
}

.sw-enwg14a-th-devices {
    display: block;
    font-size: 0.82em;
    font-weight: 400;
    color: #e2edf7;
    line-height: 1.35;
    margin-top: 0.15rem;
}

.sw-enwg14a-th-gp,
.sw-enwg14a-th-ap,
.sw-enwg14a-th-red {
    text-align: center;
}

.sw-enwg14a-th-gp {
    width: 14%;
    min-width: 115px;
}

.sw-enwg14a-th-ap {
    width: 35%;
    min-width: 265px;
}

.sw-enwg14a-th-red {
    width: 17%;
    min-width: 140px;
}

.sw-enwg14a-th-label {
    display: block;
    font-size: 1em;
    font-weight: 700;
    line-height: 1.25;
}

.sw-enwg14a-th-unit {
    display: block;
    font-size: 0.84em;
    font-weight: 400;
    color: #e2edf7;
    margin-top: 0.25rem;
}

.sw-enwg14a-asterisk {
    font-weight: 700;
}

/* Tabellenkörper */
.sw-enwg14a-cell-modul {
    text-align: left;
    font-weight: 700;
    padding: 0.9rem 1.15rem;
    background-color: var(--enwg-surface);
    color: var(--enwg-primary);
}

.sw-enwg14a-cell-num {
    text-align: center;
    padding: 0.9rem 1rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

.sw-enwg14a-cell--muted {
    color: var(--enwg-muted);
    font-weight: 400;
}

.sw-enwg14a-row--m2 .sw-enwg14a-cell-modul,
.sw-enwg14a-row--m2 td {
    background-color: var(--enwg-surface-alt);
}

/* Modul 3: Struktur mit Quartalshinweis und 3-stufigem Arbeitspreis
   (ohne height: 1px Hack – 100 % kompatibel mit Firefox/Gecko, Chrome & Safari) */
.sw-enwg14a-table th.sw-enwg14a-cell-modul--m3 {
    padding: 0;
    vertical-align: bottom;
    position: relative;
}

.sw-enwg14a-m3-head {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-top: 3.1em;
}

.sw-enwg14a-m3-head .sw-enwg14a-modul-title {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: block;
    padding: 0.9rem 1.15rem;
}

.sw-enwg14a-quarter-note {
    display: flex;
    align-items: center;
    min-height: 2.75em;
    padding: 0.55rem 1.15rem;
    background-color: var(--enwg-highlight);
    border-top: 1px solid var(--enwg-border);
    color: var(--enwg-text);
    font-size: 0.92em;
    font-weight: 600;
    line-height: 1.3;
}

.sw-enwg14a-table td.sw-enwg14a-cell--align-bottom {
    vertical-align: bottom;
    padding-bottom: 0.72rem;
}

/* Modul 3: Arbeitspreis-Unterraster (HT / NT / ST) */
.sw-enwg14a-table td.sw-enwg14a-cell-ap-m3 {
    padding: 0;
    vertical-align: bottom;
}

.sw-enwg14a-tiers {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
}

.sw-enwg14a-tier {
    display: grid;
    grid-template-rows: auto 1fr auto;
    text-align: center;
    border-right: 1px solid var(--enwg-border);
}

.sw-enwg14a-tier:last-child {
    border-right: none;
}

.sw-enwg14a-tier__code {
    padding: 0.55rem 0.5rem;
    font-weight: 700;
    font-size: 0.95em;
    border-bottom: 1px solid var(--enwg-border);
    color: var(--enwg-primary);
}

.sw-enwg14a-tier__code abbr {
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    cursor: help;
}

.sw-enwg14a-tier__time {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.45rem;
    font-size: 0.85em;
    line-height: 1.3;
    color: var(--enwg-text);
    background-color: var(--enwg-surface);
}

.sw-enwg14a-tier__price {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75em;
    padding: 0.55rem 0.5rem;
    border-top: 1px solid var(--enwg-border);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 0.92em;
    line-height: 1.3;
    color: var(--enwg-text);
}

/* Visuelle Zuordnung HT & NT zum Q1+Q4-Hinweis (identisch zum Original-Layout) */
.sw-enwg14a-tier--highlight .sw-enwg14a-tier__code,
.sw-enwg14a-tier--highlight .sw-enwg14a-tier__price {
    background-color: var(--enwg-highlight);
}

.sw-enwg14a-tier--standard .sw-enwg14a-tier__code,
.sw-enwg14a-tier--standard .sw-enwg14a-tier__price {
    background-color: var(--enwg-surface);
}

/* Mobile-Labels auf Desktop ausblenden */
.sw-enwg14a-mobile-label {
    display: none;
}

/* Fußnote (analog zu .sw-tb-footer) */
.sw-enwg14a-footer {
    padding: 1.15rem 1.35rem;
    background-color: var(--enwg-surface-alt);
    border-top: 1px solid var(--enwg-border);
}

.sw-enwg14a-footnote {
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    font-size: 0.86em;
    line-height: 1.55;
    color: var(--enwg-muted);
}

.sw-enwg14a-footnote__mark {
    font-weight: 700;
    color: var(--enwg-primary);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Responsive Karten-Ansicht für Mobilgeräte (< 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .sw-enwg14a-card {
        border-radius: 8px;
    }

    .sw-enwg14a-mobile-context {
        display: block;
        background-color: var(--enwg-primary);
        color: var(--enwg-surface);
        padding: 1.1rem 1.25rem;
    }

    .sw-enwg14a-mobile-context__title {
        font-size: 1.05em;
        font-weight: 700;
        line-height: 1.3;
    }

    .sw-enwg14a-mobile-context__sub {
        font-size: 0.88em;
        font-weight: 600;
        color: #e2edf7;
        margin-top: 0.25rem;
    }

    .sw-enwg14a-mobile-context__devices {
        font-size: 0.84em;
        color: #e2edf7;
        margin-top: 0.15rem;
        line-height: 1.4;
    }

    .sw-enwg14a-scroll {
        overflow-x: visible;
    }

    .sw-enwg14a-table,
    .sw-enwg14a-table tbody,
    .sw-enwg14a-table tr,
    .sw-enwg14a-table th,
    .sw-enwg14a-table td {
        display: block;
        width: 100%;
        height: auto;
    }

    /* thead nur visuell ausblenden – bleibt für Screenreader voll verfügbar */
    .sw-enwg14a-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;
    }

    .sw-enwg14a-table tbody {
        padding: 1rem;
        display: flex;
        flex-direction: column;
        gap: 1rem;
        background-color: var(--enwg-surface-alt);
    }

    .sw-enwg14a-row {
        background-color: var(--enwg-surface);
        border: 1px solid var(--enwg-border);
        border-radius: 6px;
        overflow: hidden;
        box-shadow: 0 2px 6px rgba(0, 30, 100, 0.04);
    }

    .sw-enwg14a-table th,
    .sw-enwg14a-table td {
        border-right: none;
        border-bottom: 1px solid var(--enwg-border-soft);
    }

    .sw-enwg14a-row td:last-child {
        border-bottom: none;
    }

    /* Karten-Kopf (Modul 1 / 2 / 3) */
    .sw-enwg14a-cell-modul,
    .sw-enwg14a-row--m2 .sw-enwg14a-cell-modul {
        background-color: var(--enwg-surface-alt);
        border-left: 4px solid var(--enwg-primary);
        border-bottom: 1px solid var(--enwg-border);
        padding: 0.85rem 1rem;
        font-size: 1.05rem;
    }

    .sw-enwg14a-table th.sw-enwg14a-cell-modul--m3 {
        padding: 0;
        position: static;
        vertical-align: baseline;
        border-left: 4px solid var(--enwg-accent);
    }

    .sw-enwg14a-m3-head {
        padding-top: 0;
    }

    .sw-enwg14a-m3-head .sw-enwg14a-modul-title {
        position: static;
        padding: 0.85rem 1rem 0.65rem 1rem;
    }

    .sw-enwg14a-quarter-note {
        min-height: 0;
        padding: 0.5rem 1rem;
        font-size: 0.86em;
        border-top: 1px solid var(--enwg-border);
    }

    /* Datenzeilen innerhalb der Karte */
    .sw-enwg14a-row--m2 td {
        background-color: var(--enwg-surface);
    }

    .sw-enwg14a-table td.sw-enwg14a-cell-num {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: baseline;
        gap: 0.35rem 1rem;
        padding: 0.8rem 1rem;
        text-align: left;
        white-space: normal;
    }

    .sw-enwg14a-mobile-label {
        display: inline-block;
        font-weight: 700;
        font-size: 0.92em;
        color: var(--enwg-primary);
        text-align: left;
    }

    .sw-enwg14a-mobile-unit {
        font-weight: 400;
        color: var(--enwg-muted);
        font-size: 0.88em;
    }

    .sw-enwg14a-value {
        font-size: 1em;
        font-weight: 700;
        margin-left: auto;
        text-align: right;
    }

    .sw-enwg14a-cell--muted .sw-enwg14a-value {
        font-weight: 400;
        color: var(--enwg-muted);
    }

    /* Modul 3: Arbeitspreis-Blöcke auf Mobilgeräten */
    .sw-enwg14a-table td.sw-enwg14a-cell-ap-m3 {
        padding: 0.85rem 1rem 1rem 1rem;
    }

    .sw-enwg14a-mobile-label--block {
        display: block;
        margin-bottom: 0.65rem;
    }

    .sw-enwg14a-tiers {
        border: 1px solid var(--enwg-border);
        border-radius: 6px;
        overflow: hidden;
    }

    .sw-enwg14a-tier__code {
        padding: 0.45rem 0.35rem;
        font-size: 0.9em;
    }

    .sw-enwg14a-tier__time {
        padding: 0.45rem 0.3rem;
        font-size: 0.82em;
    }

    .sw-enwg14a-tier__price {
        min-height: 0;
        padding: 0.5rem 0.35rem;
        font-size: 0.95em;
    }

    .sw-enwg14a-footer {
        padding: 1rem 1.1rem;
    }
}

/* Sehr schmale Displays (< 400px) oder starke Vergrößerung: HT/NT/ST untereinander */
@media (max-width: 399.98px) {
    .sw-enwg14a-tiers {
        grid-template-columns: 1fr;
    }

    .sw-enwg14a-tier {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--enwg-border);
        text-align: left;
    }

    .sw-enwg14a-tier:last-child {
        border-bottom: none;
    }

    .sw-enwg14a-tier__code,
    .sw-enwg14a-tier__time,
    .sw-enwg14a-tier__price {
        border-top: none;
        border-bottom: none;
        padding: 0.6rem 0.75rem;
    }

    .sw-enwg14a-tier__code {
        min-width: 3rem;
        border-right: 1px solid var(--enwg-border);
        text-align: center;
    }

    .sw-enwg14a-tier__time {
        justify-content: flex-start;
    }

    .sw-enwg14a-tier__price {
        text-align: right;
        border-left: 1px solid var(--enwg-border);
        min-width: 4.2rem;
    }
}

/* --------------------------------------------------------------------------
   Kompatibilität mit SWP A11y Suite (plg_system_lbv_a11y)
   -------------------------------------------------------------------------- */
body.a11y-contrast-high .sw-enwg14a-card,
body.a11y-contrast-high .sw-enwg14a-table th,
body.a11y-contrast-high .sw-enwg14a-table td,
body.a11y-contrast-high .sw-enwg14a-tier,
body.a11y-contrast-high .sw-enwg14a-tier__code,
body.a11y-contrast-high .sw-enwg14a-tier__time,
body.a11y-contrast-high .sw-enwg14a-tier__price,
body.a11y-contrast-high .sw-enwg14a-quarter-note,
body.a11y-contrast-high .sw-enwg14a-footer {
    border-color: #ffffff !important;
}

body.a11y-contrast-high .sw-enwg14a-tier--highlight .sw-enwg14a-tier__code,
body.a11y-contrast-high .sw-enwg14a-tier--highlight .sw-enwg14a-tier__price,
body.a11y-contrast-high .sw-enwg14a-quarter-note {
    text-decoration: underline;
    text-underline-offset: 3px;
}

body.a11y-font-xlarge .sw-enwg14a-table {
    font-size: 0.92em;
}

@media (max-width: 767.98px) {
    body.a11y-font-xlarge .sw-enwg14a-tiers {
        grid-template-columns: 1fr;
    }

    body.a11y-font-xlarge .sw-enwg14a-tier {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--enwg-border);
        text-align: left;
    }

    body.a11y-font-xlarge .sw-enwg14a-tier:last-child {
        border-bottom: none;
    }

    body.a11y-font-xlarge .sw-enwg14a-tier__code,
    body.a11y-font-xlarge .sw-enwg14a-tier__time,
    body.a11y-font-xlarge .sw-enwg14a-tier__price {
        border-top: none;
        border-bottom: none;
        padding: 0.6rem 0.75rem;
    }
}

/* Druckansicht */
@media print {
    .sw-enwg14a-card {
        box-shadow: none;
        border: 1px solid #000000;
    }

    .sw-enwg14a-table thead th {
        background-color: #ffffff !important;
        color: #000000 !important;
        border: 1px solid #000000 !important;
    }

    .sw-enwg14a-table th,
    .sw-enwg14a-table td,
    .sw-enwg14a-tier,
    .sw-enwg14a-tier__code,
    .sw-enwg14a-tier__time,
    .sw-enwg14a-tier__price,
    .sw-enwg14a-quarter-note {
        border-color: #000000 !important;
        color: #000000 !important;
    }

    .sw-enwg14a-th-sub,
    .sw-enwg14a-th-devices,
    .sw-enwg14a-th-unit,
    .sw-enwg14a-footnote {
        color: #000000 !important;
    }
}
