/**
 * Joomla! 5/6 mod_hort_ferien
 * Stylesheet für Ferienschließzeiten
 * Barrierefrei (WCAG 2.1/2.2 AA & BITV 2.0) & Vollständig Responsiv
 */

:root {
    --hort-font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --hort-bg: #ffffff;
    --hort-text: #1f2937;
    --hort-text-muted: #4b5563;
    --hort-border: #d1d5db;
    --hort-border-light: #e5e7eb;
    --hort-stripe: #f9fafb;
    --hort-hover: #f3f4f6;

    /* Status Grün (geöffnet) - Hoher Kontrast > 6.5:1 */
    --hort-open-bg: #e8f5e9;
    --hort-open-text: #14532d;
    --hort-open-border: #86efac;

    /* Status Rot (geschlossen) - Hoher Kontrast > 6.5:1 */
    --hort-closed-bg: #fef2f2;
    --hort-closed-text: #991b1b;
    --hort-closed-border: #fca5a5;

    /* Gemeinsame Regelung / Teamtag */
    --hort-joint-bg: #fffbeb;
    --hort-joint-text: #78350f;
    --hort-joint-border: #fde68a;

    /* Zusatznotiz (z.B. Fortbildung) - Dunkelrot/Weinrot */
    --hort-note-text: #881337;
    --hort-note-bg: #ffe4e6;
    --hort-note-border: #fecdd3;

    /* Primärfarbe für Buttons / Hervorhebung */
    --hort-primary: #0284c7;
    --hort-primary-hover: #0369a1;
    --hort-primary-active: #0c4a6e;
    --hort-focus-ring: 0 0 0 3px rgba(2, 132, 199, 0.45);
}

/* Basis Modul-Container */
.mod-hort-ferien {
    font-family: var(--hort-font-family);
    color: var(--hort-text);
    background-color: var(--hort-bg);
    margin: 1.5rem 0;
    line-height: 1.5;
}

/* Hilfsklasse für Barrierefreiheit (Screenreader only) */
.mod-hort-ferien .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;
}

/* Kopfbereich */
.hort-header {
    margin-bottom: 1.25rem;
    text-align: left !important;
}

.hort-title {
    text-align: left !important;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--hort-text);
    margin: 0 0 0.35rem 0;
    line-height: 1.25;
}

.hort-subtitle {
    text-align: left !important;
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--hort-text-muted);
    margin: 0 0 0.75rem 0;
}

.hort-intro {
    text-align: left !important;
    font-size: 1rem;
    color: var(--hort-text-muted);
    margin-bottom: 1rem;
}

/* Steuerungs- und Toolbar-Leiste */
.hort-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem 1.25rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background-color: var(--hort-stripe);
    border: 1px solid var(--hort-border-light);
    border-radius: 8px;
}

.hort-toolbar-section {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.hort-toolbar-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--hort-text);
    margin-right: 0.15rem;
    white-space: nowrap;
}

.hort-filter-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

/* Segmentierter Switch-Schalter (Ansicht: Tabelle / Karten) */
.hort-switch-group {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.hort-segmented-switch {
    display: inline-flex;
    align-items: center;
    background-color: #e2e8f0;
    padding: 3px;
    border-radius: 7px;
    border: 1px solid #cbd5e1;
}

.hort-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: #475569;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    line-height: 1.2;
    text-decoration: none;
}

.hort-switch-btn:hover {
    color: #0f172a;
    background-color: rgba(255, 255, 255, 0.5);
}

.hort-switch-btn.is-active,
.hort-switch-btn[aria-pressed="true"] {
    background-color: #ffffff !important;
    color: #0284c7 !important;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
}

.hort-switch-btn:focus-visible {
    outline: none;
    box-shadow: var(--hort-focus-ring);
}

/* Standard Buttons (Filter & Print) */
.hort-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--hort-text);
    background-color: #ffffff;
    border: 1px solid var(--hort-border);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
}

.hort-btn:hover {
    background-color: var(--hort-hover);
    border-color: #9ca3af;
}

.hort-btn:focus-visible {
    outline: none;
    box-shadow: var(--hort-focus-ring);
}

.hort-btn.is-active,
.hort-btn[aria-pressed="true"] {
    background-color: var(--hort-primary);
    color: #ffffff;
    border-color: var(--hort-primary);
}

.hort-btn.is-active:hover,
.hort-btn[aria-pressed="true"]:hover {
    background-color: var(--hort-primary-hover);
}

.hort-btn-print {
    background-color: #ffffff;
    color: var(--hort-text-muted);
}

.hort-btn-print:hover {
    color: var(--hort-text);
    background-color: var(--hort-hover);
    border-color: #9ca3af;
}

/* Icons */
.hort-icon,
.badge-icon {
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

/* ==========================================================
   1. TABELLEN-LAYOUT
   ========================================================== */
.hort-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--hort-border);
    border-radius: 6px;
    background-color: #ffffff;
    margin-bottom: 1.25rem;
}

.hort-table-container:focus-visible {
    outline: none;
    box-shadow: var(--hort-focus-ring);
}

.hort-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.hort-table th,
.hort-table td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--hort-border-light);
    vertical-align: middle;
}

/* Tabellenkopf */
.hort-table thead th {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    border-bottom: 2px solid var(--hort-border);
    white-space: nowrap;
}

.hort-table thead th.col-hort {
    text-align: center;
    min-width: 140px;
}

/* Tabellenzeilen & Zebra-Streifen */
.hort-table tbody tr:nth-child(even) {
    background-color: var(--hort-stripe);
}

.hort-table tbody tr:hover {
    background-color: var(--hort-hover);
}

/* Spaltenbreiten & Ausrichtungen */
.hort-table .cell-ferien {
    font-weight: 600;
    color: var(--hort-text);
    min-width: 110px;
}

.hort-table .cell-von,
.hort-table .cell-bis {
    white-space: nowrap;
    min-width: 90px;
}

.hort-table .cell-tage {
    white-space: nowrap;
    min-width: 80px;
    color: var(--hort-text-muted);
}

.hort-table .cell-hort {
    text-align: center;
}

.hort-table .cell-joint {
    text-align: center;
    background-color: #fffdf5;
}

/* Status Badges */
.status-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.825rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
    line-height: 1.2;
    white-space: nowrap;
}

.status-badge.status-open {
    background-color: var(--hort-open-bg);
    color: var(--hort-open-text);
    border-color: var(--hort-open-border);
}

.status-badge.status-closed {
    background-color: var(--hort-closed-bg);
    color: var(--hort-closed-text);
    border-color: var(--hort-closed-border);
}

.status-badge.status-emergency {
    background-color: #e0f2fe;
    color: #0369a1;
    border-color: #7dd3fc;
}

.status-badge.status-custom {
    background-color: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

/* Zusatzhinweise (z.B. "Mo. Fortbildung", "Do.+ Fr. Fortbildung") */
.status-note {
    display: inline-block;
    font-size: 0.775rem;
    font-weight: 700;
    color: var(--hort-note-text);
    background-color: var(--hort-note-bg);
    border: 1px solid var(--hort-note-border);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    line-height: 1.2;
    white-space: nowrap;
}

/* Gemeinsamer Banner (z.B. "Beide Horte geschlossen - Teamtag") */
.joint-banner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--hort-joint-bg);
    color: var(--hort-joint-text);
    border: 1px solid var(--hort-joint-border);
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
}

/* Aktueller Zeitraum Markierung */
.badge-current-pill {
    display: inline-block;
    margin-left: 0.4rem;
    background-color: #0284c7;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    vertical-align: middle;
}

.hort-table tbody tr.is-current {
    background-color: #f0f9ff !important;
    border-left: 4px solid var(--hort-primary);
}

.hort-table tbody tr.is-highlighted {
    background-color: #fefce8 !important;
}

/* ==========================================================
   2. KARTEN-ANSICHT (Mobil & Barrierefrei)
   ========================================================== */
.hort-cards-container {
    display: none; /* Im Desktop standardmäßig ausgeblendet */
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.hort-card {
    background-color: #ffffff;
    border: 1px solid var(--hort-border);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hort-card.is-current {
    border-color: var(--hort-primary);
    border-left-width: 5px;
    background-color: #f8fafc;
}

.hort-card.is-highlighted {
    border-color: #facc15;
    background-color: #fffef7;
}

.hort-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--hort-border-light);
}

.hort-card-title-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.hort-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--hort-text);
}

.hort-card-meta {
    font-size: 0.875rem;
    color: var(--hort-text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.hort-card-facilities {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.hort-facility-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.65rem;
    background-color: var(--hort-stripe);
    border-radius: 6px;
    border: 1px solid var(--hort-border-light);
}

.hort-facility-row .facility-name {
    font-size: 0.9rem;
    color: var(--hort-text);
}

.hort-facility-row .facility-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.joint-banner-card {
    text-align: center;
    padding: 0.75rem;
}

/* ==========================================================
   3. LEGENDE & FUSSBEREICH
   ========================================================== */
.hort-legend {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: var(--hort-stripe);
    border: 1px solid var(--hort-border-light);
    border-radius: 6px;
}

.hort-legend-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--hort-text);
}

.hort-legend-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.875rem;
    color: var(--hort-text-muted);
}

.status-note-example {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--hort-note-text);
    background-color: var(--hort-note-bg);
    border: 1px solid var(--hort-note-border);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.hort-footer {
    margin-top: 1rem;
}

.hort-footnote {
    font-size: 0.875rem;
    color: var(--hort-text-muted);
    margin: 0;
    line-height: 1.4;
}

/* ==========================================================
   4. FILTER-STEUERUNG (Spalten ausblenden / fokussieren)
   ========================================================== */
.filter-active-hort1 .col-hort2,
.filter-active-hort1 .cell-hort2,
.filter-active-hort1 .facility-hort2 {
    display: none !important;
}

.filter-active-hort2 .col-hort1,
.filter-active-hort2 .cell-hort1,
.filter-active-hort2 .facility-hort1 {
    display: none !important;
}

/* ==========================================================
   5. RESPONSIVE REGELN & ANSICHTS-UMSCHALTUNG (Tabelle / Karten)
   ========================================================== */

/* Wenn cards_only erzwungen ist */
.layout-cards_only .hort-table-container {
    display: none !important;
}
.layout-cards_only .hort-cards-container {
    display: flex !important;
}

/* MANUELLE UMSCHALTUNG: Gilt universell auf ALLEN Bildschirmbreiten */
.mod-hort-ferien.view-mode-table .hort-table-container {
    display: block !important;
}
.mod-hort-ferien.view-mode-table .hort-cards-container {
    display: none !important;
}

.mod-hort-ferien.view-mode-cards .hort-table-container {
    display: none !important;
}
.mod-hort-ferien.view-mode-cards .hort-cards-container {
    display: flex !important;
}

/* AUTOMATISCHER MODUS (solange der Nutzer noch nicht manuell umgeschaltet hat) */
.layout-table_auto:not(.view-mode-table):not(.view-mode-cards) .hort-table-container {
    display: block;
}
.layout-table_auto:not(.view-mode-table):not(.view-mode-cards) .hort-cards-container {
    display: none;
}

/* Breakpoint ab 1100px: Umschaltung auf Mobil-Karten im automatischen Modus */
@media (max-width: 1100px) {
    .layout-table_auto:not(.view-mode-table):not(.view-mode-cards) .hort-table-container {
        display: none;
    }
    .layout-table_auto:not(.view-mode-table):not(.view-mode-cards) .hort-cards-container {
        display: flex;
    }

    .hort-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
    }

    .hort-toolbar-section {
        width: 100%;
    }

    .hort-actions-section {
        justify-content: space-between;
    }
}

/* ==========================================================
   6. HIGH-CONTRAST / ACCESSIBILITY (Windows High Contrast & WCAG)
   ========================================================== */
@media (forced-colors: active) {
    .status-badge,
    .status-note,
    .joint-banner,
    .hort-btn {
        forced-color-adjust: none;
        border: 2px solid CanvasText !important;
    }

    .hort-btn.is-active,
    .hort-btn[aria-pressed="true"] {
        background-color: Highlight !important;
        color: HighlightText !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hort-btn,
    .hort-card {
        transition: none !important;
    }
}

/* ==========================================================
   7. DRUCKANSICHT (@media print)
   Isoliert das Modul vollständig – alles drumherum wird ignoriert
   ========================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm 15mm;
    }

    /* 1. Gesamte Webseite und Template-Elemente ausblenden */
    header,
    nav,
    footer,
    aside,
    .header,
    .footer,
    .sidebar,
    .navigation,
    .navbar,
    .top-bar,
    .bottom-bar,
    .breadcrumbs,
    .banner,
    .joomla-header,
    .sp-header,
    .t4-header,
    .astroid-header,
    .uk-navbar,
    .tm-header,
    .tm-footer,
    #header,
    #footer,
    #sidebar,
    #aside,
    #nav {
        display: none !important;
    }

    /* 2. Alle Geschwister-Elemente und Fremdinhalte im Body verstecken */
    body * {
        visibility: hidden !important;
    }

    /* 3. Ausschließlich das Hort-Modul und seine Kind-Elemente sichtbar machen */
    .mod-hort-ferien,
    .mod-hort-ferien * {
        visibility: visible !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .mod-hort-ferien {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    /* Verstecke Web-Steuerelemente, Toolbar und Debug-Boxen im Modul */
    .mod-hort-ferien .hort-toolbar,
    .mod-hort-ferien .hort-view-toggle,
    .mod-hort-ferien .hort-btn,
    .mod-hort-ferien .badge-current-pill,
    .mod-hort-ferien .hort-debug-box,
    .mod-hort-ferien .hort-cards-container {
        display: none !important;
        visibility: hidden !important;
    }

    .mod-hort-ferien .hort-header {
        border-bottom: 2px solid #000000 !important;
        padding-bottom: 8px !important;
        margin-bottom: 12px !important;
    }

    .mod-hort-ferien .hort-title {
        color: #000000 !important;
        font-size: 16pt !important;
    }

    .mod-hort-ferien .hort-subtitle {
        color: #333333 !important;
        font-size: 11pt !important;
    }

    .mod-hort-ferien .hort-table-container {
        display: block !important;
        visibility: visible !important;
        border: none !important;
        overflow: visible !important;
        width: 100% !important;
    }

    .mod-hort-ferien .hort-table {
        border-collapse: collapse !important;
        width: 100% !important;
        font-size: 9.5pt !important;
    }

    .mod-hort-ferien .hort-table th,
    .mod-hort-ferien .hort-table td {
        border: 1px solid #111111 !important;
        padding: 5px 7px !important;
        color: #000000 !important;
        vertical-align: middle !important;
    }

    .mod-hort-ferien .hort-table thead th {
        background-color: #f0f0f0 !important;
        color: #000000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        font-weight: 700 !important;
    }

    .mod-hort-ferien .hort-table tbody tr {
        page-break-inside: avoid !important;
    }

    .mod-hort-ferien .status-badge {
        display: inline-block !important;
        padding: 2px 6px !important;
        border-radius: 4px !important;
        font-size: 8.5pt !important;
        font-weight: bold !important;
        border: 1px solid #333333 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .mod-hort-ferien .status-badge.status-open {
        background-color: #e8f5e9 !important;
        color: #14532d !important;
        border-color: #86efac !important;
    }

    .mod-hort-ferien .status-badge.status-closed {
        background-color: #fef2f2 !important;
        color: #991b1b !important;
        border-color: #fca5a5 !important;
    }

    .mod-hort-ferien .status-note {
        display: inline-block !important;
        border: 1px solid #fecdd3 !important;
        background-color: #ffe4e6 !important;
        color: #881337 !important;
        font-weight: bold !important;
        padding: 1px 4px !important;
        border-radius: 3px !important;
        font-size: 8pt !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .mod-hort-ferien .joint-banner {
        background-color: #fffbeb !important;
        color: #78350f !important;
        border: 1px solid #fde68a !important;
        padding: 4px 8px !important;
        font-weight: bold !important;
        font-size: 9pt !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .mod-hort-ferien .hort-legend {
        margin-top: 15px !important;
        padding: 8px 12px !important;
        border: 1px solid #cccccc !important;
        background: #f7f7f7 !important;
        font-size: 8.5pt !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .mod-hort-ferien .hort-footnote {
        margin-top: 10px !important;
        font-size: 8pt !important;
        color: #444444 !important;
    }

    .mod-hort-ferien .badge-icon,
    .mod-hort-ferien .hort-icon {
        display: none !important;
    }
}
