#paGrid {
    display: grid;
    grid-auto-flow: column;
    gap: 1px;
    font-family: sans-serif;
    justify-content: start;
    /* alle Spalten linksbündig */
    width: fit-content;
    /* keine unnötige Breite einnehmen */
    --matrix-slot-row-height: 20px;
}

#paGrid.matrix-rotated {
    grid-auto-flow: row;
    grid-template-columns: 100%;
    gap: 6px;
    width: 100%;
    --matrix-rotate-header: 160px;
    --matrix-rotate-slot: 4rem;
}

#paGrid.matrix-rotated .row {
    display: grid;
    align-items: center;
    gap: 4px;
}

#paGrid.matrix-rotated .header {
    margin-top: 0;
}

#paGrid.matrix-rotated .time {
    font-size: 0.75em;
    padding: 4px 2px;
    white-space: nowrap;
}

#paGrid.matrix-rotated .slot {
    min-height: 28px;
}

.col {
    display: grid;
    background: var(--color-surface);
    gap: 4px;
}

.time-col {
    width: auto;
    /* Zeitspalte passt sich an den Text an */
    min-width: 0;
    max-width: none;
}

.court-col {
    min-width: var(--matrix-court-col-min-width, 200px);
    width: auto;
    max-width: none;
    grid-template-rows: var(--matrix-court-template-rows, auto);
}

.header {
    background: var(--color-text-muted);
    color: var(--color-surface);
    text-align: center;
    font-weight: bold;
    padding: 4px;
}

.time {
    text-align: center;
    user-select: none;
    padding: 4px;
    font-size: 0.9em;
    white-space: nowrap;
}

.slot {
    margin: 1px;
    color: var(--color-surface);
    font-size: 0.85em;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: visible;
    padding: 0 4px;
}

#paGrid .slot-label {
    display: block;
    max-width: 100%;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
}

#paGrid:not(.matrix-rotated).booking-grid .court-col > .header,
#paGrid:not(.matrix-rotated).booking-grid .court-col > .slot {
    min-width: 0;
}

#paGrid:not(.matrix-rotated).booking-grid .slot-label {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

#paGrid:not(.matrix-rotated).booking-grid .slot:hover .slot-label {
    position: relative;
    z-index: 4;
    width: max-content;
    max-width: none;
    overflow: visible;
    padding-inline: 4px;
    border-radius: var(--bradius);
    background: inherit;
}

#paGrid .slot[data-slottypeorstate="BLOCKED"] .slot-label,
#paGrid .slot[data-slottypeorstate="NOT_BOOKABLE"] .slot-label
 {
    color: var(--darkgrey);
}

.slot.selected {
    /* ausgewählte Buchung */
    background-color: var(--color-secondary);
    /* grün */
    color: var(--color-surface);
}

.slot.week-selection-flash {
    z-index: 20;
    animation: week-selection-flash 0.8s ease-in-out 3;
}

@keyframes week-selection-flash {
    0%,
    100% {
        box-shadow: none;
        filter: brightness(1);
    }

    50% {
        background-color: var(--color-accent);
        box-shadow:
            0 0 0 3px var(--color-surface),
            0 0 0 8px var(--color-primary),
            0 8px 20px rgba(0, 0, 0, 0.24);
        color: var(--color-text-muted);
        filter: brightness(1.28);
        transform: scale(1.02);
    }
}

.slot.selected.playpartner-search-active {
    background-color: var(--color-slot-selected);
    color: var(--color-surface);
}

.slot:hover:not([data-slottypeorstate="EXPIRED"]) {
    /* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); */
    /* leichter Schatten bei Hover */
    transform: translateY(-2px);
    opacity: .75;
    /* leichtes Anheben bei Hover */
}

.header,
.slot,
.time {
    border-radius: var(--bradius);
    /* Abgerundete Ecken */
    background-color: var(--color-surface-muted);
}

#paGrid .slot-price {
    position: absolute;
    top: 0px;
    right: 1px;
    height: var(--matrix-slot-row-height);
    line-height: var(--matrix-slot-row-height);
    padding: 0 6px;
    border-radius: 5px;
    background: var(--color-accent);
    color: var(--color-text-muted);
    font-size: 11px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1;
    display: none;
}

#paGrid .slot-options {
    position: absolute;
    right: 4px;
    bottom: 2px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    z-index: 1;
}

#paGrid .slot-option-badge {
    display: block;
    width: 12px;
    height: 12px;
    object-fit: contain;
    filter:
        drop-shadow(0 0 1px var(--color-surface))
        drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

#paGrid .slot:not(.selected)[data-price] .slot-price {
    display: inline-flex;
    align-items: center;
}

#paGrid .slot[data-tooltip]:hover,
#paGrid .slot[data-tooltip]:focus-visible {
    z-index: 120;
}

#paGrid .slot[data-tooltip]:hover::after,
#paGrid .slot[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    z-index: 130;
    min-width: max-content;
    max-width: 220px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--color-text-muted);
    color: var(--color-surface);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    font-size: 12px;
    line-height: 1.3;
    font-weight: 500;
    pointer-events: none;
    white-space: pre-line;
}

#paGrid .slot[data-tooltip]:hover::before,
#paGrid .slot[data-tooltip]:focus-visible::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 3px);
    transform: translateX(-50%);
    z-index: 131;
    border: 5px solid transparent;
    border-top-color: var(--color-text-muted);
    pointer-events: none;
}

.header {
    border-radius: var(--bradius);
    background-color: var(--color-surface-muted);
    color: var(--color-text-muted);
    font-size: 15px;
    font-weight: 600;
    margin-top: 1rem;
}

/* === booking grid sticky time-cols + header (alle Breakpoints) === */
#paGrid.booking-grid {
    --time-col-width: 92px;
    --matrix-court-col-min-width: 200px;
    overflow: visible;
    min-width: 100%;
    width: max-content;
    justify-content: start;
}

#paGrid.matrix-rotated.booking-grid {
    grid-template-columns: 100%;
    width: 100%;
}

#paGrid:not(.matrix-rotated).booking-grid {
    width: 100%;
    grid-template-columns: var(--time-col-width, 92px) repeat(var(--matrix-court-count, 1), minmax(var(--matrix-court-col-min-width, 200px), 1fr)) var(--time-col-width, 92px);
}

#paGrid:not(.matrix-rotated).booking-grid.matrix-few-courts {
    width: 100%;
    margin-inline: 0;
    grid-template-columns: var(--time-col-width, 92px) repeat(var(--matrix-court-count, 1), minmax(var(--matrix-court-col-min-width, 200px), 1fr)) var(--time-col-width, 92px);
}

#paGrid:not(.matrix-rotated).booking-grid.matrix-single-court {
    width: 100%;
    margin-inline: 0;
    grid-template-columns: var(--time-col-width, 92px) minmax(var(--matrix-court-col-min-width, 200px), 1fr) var(--time-col-width, 92px);
    justify-content: start;
}

#paGrid.matrix-rotated.booking-grid .court-row .court-header {
    position: sticky;
    left: 0;
    z-index: 30;
    box-shadow: 6px 0 10px rgba(0, 0, 0, 0.08);
}

#paGrid.booking-grid > .col.time-col {
    position: sticky;
    z-index: 14;
    background: var(--color-surface);
}

#paGrid:not(.matrix-rotated).booking-grid > .time-col:first-child {
    left: 0;
    width: var(--time-col-width, 92px);
    min-width: var(--time-col-width, 92px);
    max-width: var(--time-col-width, 92px);
    box-shadow: 6px 0 10px rgba(0, 0, 0, 0.08);
}

#paGrid:not(.matrix-rotated).booking-grid > .time-col:last-child {
    right: 0;
    width: var(--time-col-width, 92px);
    min-width: var(--time-col-width, 92px);
    max-width: var(--time-col-width, 92px);
    box-shadow: -6px 0 10px rgba(0, 0, 0, 0.08);
}

#paGrid:not(.matrix-rotated).booking-grid .col .header {
    position: sticky;
    top: 0;
    z-index: 20;
}

#paGrid:not(.matrix-rotated).booking-grid > .time-col:first-child .header {
    z-index: 60;
}

.pa-wrapper {
    position: relative;
}

.pa-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        linear-gradient(90deg, transparent 49.7%, color-mix(in hsl, var(--color-primary) 8%, transparent) 50%, transparent 50.3%),
        radial-gradient(ellipse at center, transparent 62%, color-mix(in hsl, var(--color-primary) 8%, transparent) 62.8%, transparent 63.6%),
        linear-gradient(180deg, color-mix(in hsl, var(--color-surface-muted) 55%, transparent), color-mix(in hsl, var(--color-surface) 85%, transparent));
    background-size: 100% 100%, 70% 70%, 100% 100%;
    background-position: center center;
}

#paGrid.booking-grid {
    position: relative;
    z-index: 1;
}

.matrix-partial-unavailable {
    position: relative;
    z-index: 2;
    margin: 0 0 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--color-text);
    font-weight: 600;
    line-height: 1.4;
    background: color-mix(in srgb, var(--color-warning, #f0ad4e) 16%, var(--color-surface));
    border: 1px solid color-mix(in srgb, var(--color-warning, #f0ad4e) 48%, var(--color-surface-muted));
    border-radius: var(--bradius);
}

#paGrid.booking-grid.matrix-unavailable {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    width: 100%;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    background: var(--color-surface);
    border: 1px solid var(--color-surface-muted);
    border-radius: var(--bradius);
}

@media (max-width: 1000px) {

  /* feste Werte mobile */
  #paGrid.booking-grid {
    --time-col-width: 92px; /* anpassen */
  }

  /* scroller */
  .pa-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }
  .pa-wrapper::before {
    display: none;
  }
  .pa-wrapper {
    scroll-snap-type: none;
    scroll-padding-left: 0;
    scroll-padding-right: 0;
  }

}

/* === Anzeige der timeSlots === */
.slot[data-slottypeorstate="SINGLE"] {
    background-color: var(--color-slot-single);
    /* orange */
    cursor: not-allowed;
}

.slot[data-slottypeorstate="SUBSCRIPTION"] {
    background-color: var(--color-slot-subscription);
    /* orange */
    cursor: not-allowed;
}

.slot[data-slottypeorstate="DOUBLE"] {
    background-color: var(--color-slot-double);
    /* orange */
    cursor: not-allowed;

}

.slot[data-slottypeorstate="TRAINING"] {
    background-color: var(--color-slot-training);
    /* grün */
    cursor: not-allowed;
}


.slot[data-slottypeorstate="EXPIRED"] {
    background-color: var(--color-slot-expired);
    cursor: not-allowed;
    /* grün */
}

.slot[data-slottypeorstate="BLOCK"] {
    background-color: var(--color-slot-block);
    cursor: not-allowed;
    /* grün */
}

.slot[data-slottypeorstate="OPEN_MATCH"] {
    background-color: #ff2f92;
    color: #fff;
    box-shadow: inset 0 0 0 2px #7a0038;
    font-weight: 700;
}

.slot[data-slottypeorstate="BLOCKED"] {
    background-color: var(--color-slot-blocked);
    cursor: not-allowed;
    /* grün */
}

/* === WEEK OVERLAY === */
.reiter-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: space-between;
    flex-wrap: wrap;
}

.week-overview-btn {
    align-self: flex-end;
    min-width: 180px;
}

.week-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 12000;
}

.week-overlay.show {
    display: flex;
}

.week-overlay-content {
    background: var(--color-surface);
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
    padding: 1rem;
    width: 99vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* nur der Grid-Bereich soll scrollen */
}

.week-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--color-surface);
    padding: 0.25rem 0;
}

.week-grid {
    display: grid;
    grid-auto-flow: column;
    gap: 2px;
    width: max-content;
    min-width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.week-day {
    display: grid;
    background: var(--color-surface-muted);
    gap: 1px;
}

.week-day-header {
    font-weight: 700;
    padding: 6px 8px;
    background: var(--color-surface-muted);
    border-radius: var(--bradius);
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.week-court-header {
    text-align: center;
    padding: 2px;
    font-weight: 400;
    font-size: 10px;
    white-space: nowrap;
    background: var(--color-surface-muted);
    border-radius: var(--bradius);
    min-height: 28px;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.week-court-header:hover {
    white-space: normal;
    overflow: visible;
    z-index: 3;
    background: var(--color-surface-muted);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
}

.week-slot {
    color: transparent;
    font-size: 0;
    padding: 0;
    margin: 0;
    border: 1px dotted var(--darkgreen);
    border-radius: 3px;
}

.week-time-col {
    position: sticky;
    left: 0;
    background: var(--color-surface);
    z-index: 2;
    min-width: 72px;
    max-width: 72px;
    gap: 1px;
}

.week-time-day-spacer {
    min-height: 28px;
}

.week-time-col .header {
    font-weight: 500;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.week-time-col .time {
    font-size: 11px;
    font-weight: 400;
    padding: 0;
    line-height: 1.1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
