/**
 * Courtora – Grid-View CSS (2.3.0)
 * Scoped unter .tcb-grid-wrap – keine Auswirkung auf andere Seitenelemente.
 */

/* ── Variablen ────────────────────────────────────────────────── */
.tcb-grid-wrap {
    --tcb-header-color:   #016b6b;
    --tcb-row-h:          30px;    /* Höhe 1 Slot (30 Min) */
    --tcb-time-w:         52px;    /* Breite Zeitachse */
    --tcb-court-min-w:    80px;    /* Min-Breite einer Platzspalte */
    --tcb-hd-shift:       0px;     /* per JS: Kopfzeile unter der Navigation halten */
}

/* Style "modern": ruhige, abgestimmte Palette. Die Kopffarbe kommt aus den
   Einstellungen, freie Zellen sind hell, belegte gedämpft rosa, die eigene
   Buchung kräftig blau. Style "classic" setzt die Variablen inline. */
.tcb-grid--modern {
    --tcb-color-free:     #f3f8f5;
    --tcb-text-free:      #1e293b;
    --tcb-color-occ:      #f6dcdc;
    --tcb-text-occ:       #7a2a2a;
    --tcb-color-mine:     #1d5fd0;
    --tcb-text-mine:      #ffffff;
    --tcb-color-blocked:  #e5e9ee;
    --tcb-text-blocked:   #475569;
}

/* ── Basis-Wrapper ────────────────────────────────────────────── */
.tcb-grid-wrap {
    font-family: inherit;
    font-size: .9rem;
    color: #1e293b;
    margin: 0 auto;
    max-width: 100%;
    position: relative;
}

/* ── Navigation: bleibt beim Scrollen oben stehen ─────────────── */
.tcb-grid-wrap .tcb-grid-nav {
    position: sticky;
    top: 0;               /* per JS unter einen festen Theme-Kopf gesetzt */
    z-index: 30;
    margin-bottom: 0;
}

/* ── Lade-Overlay ─────────────────────────────────────────────── */
.tcb-grid-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    font-weight: 600;
    color: var(--tcb-header-color);
    border-radius: 8px;
}

/* ── Äußerer Scroll-Container ─────────────────────────────────── */
.tcb-grid-outer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: .5rem;
    position: relative;
    background: #fff;
}
.tcb-grid-outer--stuck .tcb-grid-day-hd,
.tcb-grid-outer--stuck .tcb-grid-time-hd {
    box-shadow: 0 3px 6px rgba(15,23,42,.18);
}

/* ── Scroll-Innenbereich: Zeitachse + Tage ────────────────────── */
.tcb-grid-scroll {
    display: flex;
    min-width: min-content;
}

/* ── Zeitachsen-Spalte (links + rechts) ───────────────────────── */
.tcb-grid-time-col {
    flex-shrink: 0;
    width: var(--tcb-time-w);
    position: sticky;
    z-index: 10;
    background: #fff;
}
.tcb-grid-time-left  { left: 0;  border-right: 2px solid #e2e8f0; }
.tcb-grid-time-right { right: 0; border-left:  2px solid #e2e8f0; }

.tcb-grid-time-hd {
    height: 42px; /* Platzhalter für Datums-/Platzkopf */
    background: var(--tcb-header-color);
    border-bottom: 1px solid rgba(255,255,255,.2);
    position: relative;
    z-index: 9;
    transform: translateY(var(--tcb-hd-shift, 0px));
}

.tcb-grid-time-cell {
    height: var(--tcb-row-h);
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
    font-size: .72rem;
    font-weight: 600;
    color: #64748b;
    box-sizing: border-box;
}
.tcb-grid-time-left  .tcb-grid-time-cell { justify-content: flex-end; padding-right: 5px; }
.tcb-grid-time-right .tcb-grid-time-cell { justify-content: flex-start; padding-left: 4px; }
.tcb-time-hour  { border-top: 1px solid #cbd5e1; }
.tcb-time-half  { border-top: 1px dashed #e2e8f0; }

/* ── Tages-Gruppen ────────────────────────────────────────────── */
.tcb-grid-days-wrap {
    display: flex;
    flex: 1 1 auto;
}

.tcb-grid-day {
    flex: 1 1 auto;
    min-width: calc(var(--tcb-court-min-w) * 2); /* mind. 2 Plätze sichtbar */
    border-right: 2px solid #cbd5e1;
}
.tcb-grid-day:last-child { border-right: none; }

/* ── Tag-Kopf: Datum + Platznamen ─────────────────────────────── */
.tcb-grid-day-hd {
    height: 42px;
    background: var(--tcb-header-color);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 8;
    /* Bleibt unter der Navigation sichtbar (siehe frontend-grid.js) */
    transform: translateY(var(--tcb-hd-shift, 0px));
}

.tcb-grid-day-label {
    font-size: .75rem;
    font-weight: 700;
    text-align: center;
    padding: 2px 4px 0;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tcb-grid-court-heads {
    display: flex;
    flex: 1;
}
.tcb-grid-court-head {
    flex: 1 1 0;
    min-width: var(--tcb-court-min-w);
    font-size: .72rem;
    font-weight: 600;
    text-align: center;
    padding: 2px 2px 0;
    border-left: 1px solid rgba(255,255,255,.15);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255,255,255,.95);
}
.tcb-grid-court-head:first-child { border-left: none; }

/* ── Grid-Body: das eigentliche Buchungsraster ────────────────── */
.tcb-grid-body {
    display: grid;
    /* grid-template-columns wird per JS gesetzt: repeat(N, 1fr) */
    /* grid-template-rows  wird per JS gesetzt: repeat(28, 30px) */
    position: relative;
}

/* Raster-Hintergrundlinien */
.tcb-grid-body::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent calc(var(--tcb-row-h) - 1px),
            #e2e8f0 calc(var(--tcb-row-h) - 1px),
            #e2e8f0 var(--tcb-row-h),
            transparent var(--tcb-row-h),
            transparent calc(var(--tcb-row-h) * 2 - 1px),
            #f1f5f9 calc(var(--tcb-row-h) * 2 - 1px),
            #f1f5f9 calc(var(--tcb-row-h) * 2)
        );
    pointer-events: none;
    z-index: 0;
}

/* ── Zellen ───────────────────────────────────────────────────── */
.tcb-grid-cell {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    margin: 1px 2px;
    border-radius: 5px;
    transition: background-color .12s, box-shadow .12s, filter .12s;
}

/* frei */
.tcb-grid-cell--free {
    background: var(--tcb-color-free);
    border: 1px solid rgba(15,23,42,.07);
    cursor: pointer;
}
.tcb-grid-cell--free:hover {
    filter: brightness(.94);
    box-shadow: inset 0 0 0 2px var(--tcb-header-color);
}
.tcb-grid-cell--free:active { filter: brightness(.88); }

/* belegt (andere) */
.tcb-grid-cell--occupied {
    background: var(--tcb-color-occ);
    color: var(--tcb-text-occ, #fff);
    border: 1px solid rgba(15,23,42,.08);
    cursor: default;
}
.tcb-grid--modern .tcb-grid-cell--occupied {
    box-shadow: inset 3px 0 0 #d46a6a;
}

/* eigene Buchung: deutlich hervorgehoben */
.tcb-grid-cell--mine {
    background: var(--tcb-color-mine);
    color: var(--tcb-text-mine, #fff);
    border: 1px solid rgba(15,23,42,.18);
    cursor: default;
    z-index: 2;
}
.tcb-grid--modern .tcb-grid-cell--mine {
    box-shadow: inset 3px 0 0 #0b3d91, 0 2px 6px rgba(29,95,208,.35);
}
.tcb-grid-cell--mine .tcb-grid-cell-name { font-weight: 800; }

/* Sperrzeit */
.tcb-grid-cell--blocked {
    background: var(--tcb-color-blocked);
    color: var(--tcb-text-blocked, #fff);
    border: 1px solid rgba(15,23,42,.08);
    cursor: not-allowed;
}
.tcb-grid--modern .tcb-grid-cell--blocked {
    background-image: repeating-linear-gradient(135deg, rgba(100,116,139,.16) 0, rgba(100,116,139,.16) 5px, transparent 5px, transparent 10px);
}

/* vergangen / außerhalb Horizont */
.tcb-grid-cell--past,
.tcb-grid-cell--disabled {
    background: #f1f3f6;
    cursor: not-allowed;
}

/* nicht buchbar: kein Preis hinterlegt oder Zeitraum zu kurz */
.tcb-grid-cell--norule,
.tcb-grid-cell--unavail {
    background-color: #f8fafc;
    background-image: repeating-linear-gradient(135deg, rgba(148,163,184,.14) 0, rgba(148,163,184,.14) 5px, transparent 5px, transparent 10px);
    cursor: not-allowed;
}

/* Buchungen in der Vergangenheit (nur mit sichtbaren Namen) */
.tcb-grid-cell--pastbooked { opacity: .65; }
.tcb-grid-cell--busy { cursor: progress; filter: brightness(.9); }

/* Legende */
.tcb-grid-wrap .tcb-leg-dot { border: 1px solid rgba(15,23,42,.15); }
.tcb-grid-wrap .tcb-leg-dot--free     { background: var(--tcb-color-free); }
.tcb-grid-wrap .tcb-leg-dot--occupied { background: var(--tcb-color-occ); }
.tcb-grid-wrap .tcb-leg-dot--mine     { background: var(--tcb-color-mine); }
.tcb-grid-wrap .tcb-leg-dot--blocked  { background: var(--tcb-color-blocked); }

/* ── Zellinhalt ───────────────────────────────────────────────── */
.tcb-grid-cell-inner {
    position: absolute;
    inset: 1px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 1px 3px;
}

.tcb-grid-cell-name {
    font-size: .68rem;
    font-weight: 700;
    color: inherit;
    line-height: 1.2;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.tcb-grid-cell-dur {
    font-size: .62rem;
    color: inherit;
    opacity: .85;
}

/* ── Preis in Zeitachse ───────────────────────────────────────── */
.tcb-grid-time-price {
    font-size: .6rem;
    color: var(--tcb-header-color);
    font-weight: 700;
    opacity: .8;
    display: block;
    line-height: 1;
    padding-right: 3px;
    text-align: right;
}

/* ── Heutige Zeitleiste (roter Strich) ────────────────────────── */
.tcb-grid-now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #ef4444;
    z-index: 5;
    pointer-events: none;
}
.tcb-grid-now-line::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
}

/* ── Placeholder (Lade-Text) ──────────────────────────────────── */
.tcb-grid-placeholder {
    grid-column: 1 / -1;
    padding: 2rem;
    text-align: center;
    color: #94a3b8;
    font-size: .85rem;
}

/* ── Responsiv: Mobil-Fallback ────────────────────────────────── */
@media (max-width: 768px) {
    /* Grid-View auf Mobil: Scroll horizontal erlaubt, aber
       Zeitachse bleibt sticky. Tages-Gruppen schrumpfen minimal. */
    .tcb-grid-day {
        min-width: calc(var(--tcb-court-min-w) * 1.2);
    }
    .tcb-grid-time-col {
        width: 42px;
    }
    .tcb-grid-time-cell {
        font-size: .65rem;
    }
    .tcb-grid-cell-name {
        font-size: .6rem;
    }
    /* "Heute"-Button auf Mobil ausblenden um Platz zu sparen */
    .tcb-grid-today {
        display: none !important;
    }
}

/* ── Tage außerhalb des Buchungshorizonts ─────────────────────── */
.tcb-grid-day--closed .tcb-grid-day-label {
    color: rgba(255,255,255,.8);
}
.tcb-grid-day--closed .tcb-grid-day-label::after {
    content: " \00B7  " attr(data-closed);
    text-transform: none;
    font-weight: 600;
    opacity: .9;
}
.tcb-grid-day--closed .tcb-grid-body {
    background-image: repeating-linear-gradient(
        135deg,
        rgba(148,163,184,.14) 0,
        rgba(148,163,184,.14) 6px,
        transparent 6px,
        transparent 12px
    );
}


/* ── "Heute"-Button im Grid-Kopf: Textbreite statt fester 36px-Quadrat ── */
.tcb-grid-wrap .tcb-grid-today {
    width: auto !important;
    min-width: 0 !important;
    padding: 0 .75rem !important;
    font-size: .8rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}

/* Staff: Tage hinter dem regulären Buchungshorizont (buchbar, aber gekennzeichnet) */
.tcb-grid-day--beyond .tcb-grid-day-label::after {
    content: " \00B7  " attr(data-closed);
    text-transform: none;
    font-weight: 600;
    opacity: .9;
}

/* Staff: vergangene Tage (nur ansehen) */
.tcb-grid-day--past .tcb-grid-day-label::after {
    content: " \00B7  " attr(data-closed);
    text-transform: none;
    font-weight: 600;
    opacity: .9;
}
.tcb-grid-day--past .tcb-grid-day-hd { filter: saturate(.55) brightness(.92); }

/* Fehlermeldung beim Laden */
.tcb-grid-placeholder--error { color: #b91c1c; }

/* ── Preis-Tooltip (nur Desktop) ──────────────────────────────── */
.tcb-grid-tip {
    position: fixed;
    z-index: 100000;
    display: none;
    min-width: 150px;
    max-width: 240px;
    padding: .5rem .7rem;
    border-radius: 8px;
    background: #1e293b;
    color: #f8fafc;
    font-size: .78rem;
    line-height: 1.35;
    box-shadow: 0 6px 18px rgba(15,23,42,.3);
    pointer-events: none;
}
.tcb-grid-tip-head { font-weight: 700; margin-bottom: .25rem; color: #cbd5e1; }
.tcb-grid-tip-row  { display: flex; justify-content: space-between; gap: 1rem; }
.tcb-grid-tip-row strong { color: #fff; }
