/*
 * TimeSlotGridWidget. See waitlist/forms/time_slot_grid.py for the widget's other parts.
 *
 * Only the design tokens on :root are shared with the page around it. Every class here
 * belongs to the widget, so dropping the grid into another page needs nothing but the
 * tokens.
 */

.time-slot-grid {
    display: flex;
    flex-direction: column;
    gap: 12px
}

/* `.tg-actions` sets a display of its own, which would otherwise out-specify the
   browser's `[hidden]`, and the progressive enhancements rely on the attribute. */
.time-slot-grid [hidden] {
    display: none !important
}

/* The column count is configurable in Python, so the widget hands it over as a custom
   property rather than the stylesheet assuming a five day week. */
.tg-grid {
    display: grid;
    grid-template-columns:max-content repeat(var(--tg-columns), 1fr);
    gap: 4px;
    /* Adds up to the widget's own 12px rhythm on top of the 6px the field leaves. */
    margin-top: 6px
}

.tg-head {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-canvas);
    border-radius: 6px
}

.tg-time {
    padding: 0 6px;
    white-space: nowrap
}

/* Only once time_slot_grid.js has turned the heads into row and column switches. */
.tg-head[role=button] {
    cursor: pointer
}

.tg-head[role=button]:hover {
    background: var(--bg-canvas-hover)
}

/* The checkbox is the cell: it covers the whole label and `.tg-face` next to it draws
   what the visitor sees, so selecting slots needs no JavaScript at all. */
.tg-slot {
    position: relative;
    display: flex;
    cursor: pointer
}

.tg-slot input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer
}

.tg-face {
    flex: 1;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-inset);
    border: 1px solid var(--border-default);
    transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard)
}

.tg-slot:hover .tg-face {
    border-color: var(--border-accent)
}

.tg-slot input:checked + .tg-face {
    background: var(--bg-slot-on);
    border-color: var(--bg-slot-on)
}

.tg-slot input:focus-visible + .tg-face {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-focus)
}

/* A read-only grid displays a selection, so nothing in it invites a click. */
.tg-slot:has(input:disabled), .tg-slot input:disabled {
    cursor: default
}

.tg-slot:has(input:disabled):hover .tg-face {
    border-color: var(--border-default)
}

.tg-count {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary)
}

.tg-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px
}

.tg-shortcuts {
    display: flex;
    gap: 14px
}

.tg-shortcut {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--text-link);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer
}

.tg-shortcut:hover {
    color: var(--text-link-hover)
}

@media (max-width: 420px) {
    .tg-grid {
        gap: 3px
    }

    .tg-time {
        padding: 0 3px
    }

    .tg-head {
        font-size: 10px
    }

    .tg-face, .tg-head {
        height: 28px
    }
}
