/* Anpassung der Header-Image-Höhe für die Booking-Seite */
body:not(.home) #header-background {
    height: 120px;
    object-fit: cover;
}

.grid-container {
    position: relative;
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    grid-template-rows: repeat(64, 20px);
    /* 64 Slots à 15 Minuten */
    background: var(--color-surface);
    border: 1px solid var(--color-surface-muted);
}

/* === CONTAINER === */
.box {
    width: 100%;
    /* height: 100%; */
    padding: 0 20px;
}

/* === PLATZGRUPPE === */
.reiter {
    display: flex;
    flex-wrap: nowrap;
    /* Verhindert das Umbrechen der Reiter */
    overflow-x: auto;
    /* Ermöglicht horizontales Scrollen, falls nötig */
    justify-content: flex-start;
    /* Elemente beginnen von links */
    align-items: center;
    margin-top: 20px;
    width: 100%;
    /* Stellt sicher, dass der Container die volle Breite einnimmt */
    position: relative;
    /* Für die positionierten Kindelemente */

    position: sticky;
    top: 56px;
    /* Positioniert den Reiter relativ zum Header */
    background: var(--color-surface);
    /* oder eine andere Hintergrundfarbe, um Überlappung zu vermeiden */
    z-index: 10;
    /* stellt sicher, dass der Reiter über anderen Elementen bleibt */
}

.reiter.single-group {
    justify-content: center;
    overflow-x: visible;
}

.reiter.single-group .platzgruppe {
    flex: 0 1 min(820px, 100%);
    margin-left: 0;
    text-align: center;
    font-size: 18px;
    padding: 10px 48px;
}

.reiter.few-groups .platzgruppe {
    font-size: 17px;
}

.platzgruppe {
    padding: 8px 36px;
    user-select: none;
    cursor: pointer;
    /* Etwas weniger Padding für bessere Anpassung */
    border: 1px solid var(--color-surface-muted);
    border-radius: 10px 10px 0 0;
    font-size: 16px;
    flex: 1;
    /* Jedes Element nimmt den gleichen Anteil des verfügbaren Platzes ein */
    text-align: start;
    /* Text zentriert für bessere Optik */
    position: relative;
    /* Für z-index */
    margin-left: -10px;
    /* Negativer Margin für Überlappung */
    background-color: var(--color-surface-muted);
    box-shadow: 5px 5px 10px -1px color-mix(in hsl, var(--color-text-muted) 65%, transparent);
    white-space: nowrap;
    /* Verhindert den Textumbruch innerhalb eines Reiters */
}

.platzgruppe .matrix-rotate-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.platzgruppe .matrix-rotate-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.platzgruppe .info-icon {
    display: inline-flex;
    width: 22px;
    height: 22px;
    margin-left: 8px;
    vertical-align: middle;
}

.platzgruppe .info-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.platzgruppe:first-child {
    margin-left: 0;
    /* Das erste Element hat keinen negativen Margin links */
    z-index: 10;
    /* Höchster z-index für das erste Element */
}

.platzgruppe:nth-child(2) {
    z-index: 9;
    /* Zweithöchster z-index */
}

.platzgruppe:nth-child(3) {
    z-index: 8;
}

.platzgruppe:nth-child(4) {
    z-index: 7;
}

.platzgruppe:hover {
    font-weight: bold;
    /* links ein kleiner Schatten */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 20;
    /* Bei Hover über alle anderen Elemente */
}

.platzgruppe.selected {
    z-index: 15;
    /* Ausgewähltes Element über die anderen, aber unter hover */
    background-color: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
    border-color: var(--color-primary);
    box-shadow:
        0 0 0 2px color-mix(in srgb, var(--color-primary) 70%, transparent),
        0 8px 18px -8px color-mix(in srgb, var(--color-primary) 55%, transparent);
    font-weight: 700;
    /* Hintergrund hinzufügen, damit die Überlappung sichtbar ist */
}

.platzgruppe.selected::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 4px;
    height: 3px;
    border-radius: 999px;
    background-color: var(--color-primary);
}

/* Hintergrund-Dim (optional) */
#court-info-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    display: none;
    opacity: 0;
    transition: opacity 150ms ease;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

#court-info-overlay.show {
    opacity: 1;
}

/* Popup Box */
#court-info {
    background: var(--color-surface);
    width: min(90%, 500px);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    max-height: 85vh;
    overflow-y: auto;
    animation: fadeIn 0.25s ease;
    position: relative;
}

/* X-Schließen Button */
#court-info .close-btn {
    position: absolute;
    top: 10px;
    right: 14px;
    cursor: pointer;
    font-size: 1.4rem;
    border: 0;
    background: transparent;
    color: inherit;
    line-height: 1;
    padding: 0;
}

/* Animation */
@keyframes fadeIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/********************************************/
/*   HEADERBLOCK (Titel + Infos + Plätze)
/********************************************/

/* alles zusammen optisch als Block */
#court-info>h1,
#court-info>p:first-of-type,
#court-info>h2:first-of-type,
#court-info>ul:first-of-type {
    background: var(--color-primary);
    color: var(--color-surface);
    margin: 0;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Zeile 1: Titel */
#court-info>h1 {
    padding-top: 1rem;
    padding-bottom: 0.2rem;
    font-size: 1.4rem;
    font-weight: 700;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

/* Zeile 2: Beschreibung (3 Plätze / Parkett) */
#court-info>p:first-of-type {
    padding-bottom: 0.2rem;
    font-size: 0.95rem;
    opacity: 0.95;
}

/* Zeile 3: Text "Plätze" */
#court-info>h2:first-of-type {
    padding-top: 0.4rem;
    padding-bottom: 0.1rem;
    font-size: 1.05rem;
    font-weight: 600;
}

/* Zeile 4: Liste der Plätze */
#court-info>ul:first-of-type {
    list-style: none;
    /* Punkte weg */
    padding-left: 1rem;
    /* Einzug */
    padding-bottom: 0.7rem;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

/********************************************/
/*   EINSTELLUNGEN-BALKEN (h2)
/********************************************/
#court-info>h2:nth-of-type(2) {
    background: var(--color-primary);
    color: var(--color-surface);
    padding: 0.6rem 1rem;
    margin-top: 1.5rem;
    margin-bottom: 0;
    font-size: 1.15rem;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
    /* oben rund */
}

/********************************************/
/*   EINZELNE EINSTELLUNGEN (UL + LI)
/********************************************/
#court-info>ul:nth-of-type(2) {
    list-style: none;
    background: var(--color-surface);
    margin: 0;
    padding: 0;
    border-radius: 0 0 8px 8px;
    /* unten rund */
    border: 1px solid var(--color-surface-muted);
    border-top: none;
}

#court-info>ul:nth-of-type(2)>li {
    padding: 0.6rem 1rem;
    margin: 0;
    border-bottom: 1px solid var(--color-surface-muted);
    font-size: 0.95rem;
}

#court-info>ul:nth-of-type(2)>li:last-child {
    border-bottom: none;
}

#court-info>ul:nth-of-type(2)>li strong {
    font-weight: 600;
}

/*=== PA WRAPPER ===*/
.pa-wrapper {
    overflow: auto;
}

/* Desktop matrix layout:
   Scroll only matrix body under the booking header. */
@media (min-width: 1001px) {
    body.selectCourt .content-container {
        display: flex;
        flex-direction: column;
        min-height: calc(100vh - 64px - env(safe-area-inset-top, 0px));
    }

    body.selectCourt .box {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    body.selectCourt .reiter {
        position: static;
        top: auto;
    }

    body.selectCourt .pa-wrapper {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    body.selectCourt .pa-wrapper:has(#paGrid.matrix-rotated) {
        flex: 1;
    }
}

@media (max-width: 1000px) {
    .box {
        display: none;
    }
    .pa-wrapper {
        max-height: calc(100vh - 280px);
        -webkit-overflow-scrolling: touch;
    }

    .sticky-book-btn {
        position: fixed;
        bottom: 12px;
        left: 12px;
        right: 12px;
        top: auto;
        z-index: 300;
    }
}

/*=== COURTS ===*/
.courts {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.courts .platzgruppe {
    flex: 0 0 auto;
    /* Courts können unterschiedliche Breiten haben */
    margin-left: 0;
    /* Kein negativer Margin */
    background-color: var(--color-surface-muted);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.courts .platzgruppe:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.wochenansicht.is-disabled {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.court {
    width: 227px;
    height: var(--btnHeight);
    font-size: 16px;
    color: var(--color-text-muted);
    background-color: var(--color-surface-muted);
    border-radius: var(--bradius);
}

.belegt {
    position: relative;
    font-size: 16px;
    color: var(--color-text-default);
}

.time-frame {
    display: block;
    width: 100px;
    height: var(--btnHeight);
}

/* === LEGNDE === */
.legende {
    margin: 1rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    width: 70%;
    height: 60px;
}

.legende-text {
    font-size: 12px;
    width: max-content;
}

.legende-item {
    display: flex;
    align-items: center;
    justify-content: start;
    gap: 10px;
}

.legende-box {
    width: 16px;
    height: 16px;
}

.legende-box.ausgewählt {
    background-color: var(--color-slot-selected);
}

.legende-box.Einzel {
    background-color: var(--color-slot-single);
}

.legende-box.Block {
    background-color: var(--color-slot-block);
}

.legende-box.Abonnement {
    background-color: var(--color-slot-abonnement);
}

.legende-box.OpenMatch {
    background-color: #ff2f92;
}

.legende-box.blockiert {
    background-color: var(--color-slot-blocked);
}

.legende-box.abgelaufen {
    background-color: var(--color-slot-expired);
}

.legende-box.browser {
    background-color: var(--color-slot-browser);
}

.legende-box.round {
    border-radius: 50%;
    width: 16px;
    height: 16px;
    background-color: var(--color-slot-selected);
}

.legende-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
}

@media (max-width: 1000px) {
    .legende-row {
        flex-direction: column;
        align-items: flex-start;
    }

}

.legende-box.mitglied {
    background-color: var(--color-info);
}

.legende-box.gast {
    background-color: var(--color-slot-guest);
}
