/* lanes.css — teema-ystävällinen versio */

/* Perusrunko */
body {
    font-family: Arial, sans-serif;
    margin: 2em;
    background: var(--bg);
    color: var(--text);
}

h1,
h2,
h3 {
    color: var(--text);
}

/* Valinnat & lomakkeet */
form select,
form input[type="date"],
form input[type="time"],
form input[type="text"],
form button {
    padding: 8px;
    margin: 5px 0;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}

form select {
    min-width: 200px;
}

/* Yhtenäiset napit – käytä globaalia .btn-tyyliä väreihin */
form button,
.btn.btn-sm {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.btn.btn-sm:hover,
form button:hover {
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}

/* Kalenteritaulukko (perus) */
table {
    width: 100%;
    border-collapse: collapse;
    /* margin-top: 1em; */
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 0 5px var(--shadow-weak);
}

table thead {
    background: var(--table-head-bg);
}

table th,
table td {
    padding: 10px;
    border: 1px solid var(--border);
    text-align: center;
}

/* Päivän korostus */
.today-row td {
    background: color-mix(in oklab, var(--accent) 12%, var(--surface));
}

/* Tilat */
td.reserved,
.reserved {
    background: var(--reserved-bg);
    color: var(--text);
    font-weight: 600;
}

td.free,
.free {
    background: var(--surface-2);
    color: var(--text);
    font-weight: 600;
}

td.pending,
.pending {
    background: color-mix(in oklab, var(--warn) 16%, var(--surface));
    color: var(--text);
}

td.closed,
.closed,
.slot-action.closed {
    background: color-mix(in oklab, var(--muted) 12%, var(--surface));
    color: var(--muted);
    text-align: center;
    font-style: italic;
}

/* Varauslinkki */
.book-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

/* Toolbar: kolmen palstan ruudukko + kohdistukset */
.lane-select-form .lane-select-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px 16px;
    align-items: center;
    margin-bottom: 1em;
}

.lane-select-form .left {
    justify-self: start;
    text-align: left;
}

.lane-select-form .center {
    justify-self: center;
    text-align: center;
}

.lane-select-form .right {
    justify-self: end;
    text-align: right;
}

.lane-select-form .inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.lane-select-form .right .inline-form {
    justify-content: flex-end;
}

/* Toolbar-kontrollit teeman mukaan */
.lane-select-form select,
.lane-select-form input[type="date"],
.lane-select-form button {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

/* ------- Modali ------- */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    /* näytetään JS:llä flexiksi */
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .5);
    /* overlay – ei opacitya koko elementille */
    z-index: 9999;
    /* iso arvo > sticky thead */
}

/* Estä taustan rullaus modaalin ollessa auki */
body.modal-open {
    overflow: hidden;
}

.modal-content {
    position: relative;
    max-height: 90vh;
    /* ettei karkaa ruudusta */
    overflow: auto;
    /* rullaus modaliin */
    border-radius: 12px;

    /* UUSI: kortille peittävä tausta ja selkeä kontrasti */
    background: var(--modal-bg, var(--card-bg, #ffffff));
    color: var(--text-color, var(--text, #111111));
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    background-clip: padding-box;

    padding: 20px;
}

/* Tummateema – muokkaa selektoria teeman mukaan */
body.dark .modal .modal-content,
:root[data-theme="dark"] .modal .modal-content {
    background: var(--modal-bg-dark, #1e1f25);
    color: var(--text-on-dark, #f1f1f1);
}

/* Jos jokin yleissääntö asettaa opacitya sisälle, nollataan varmuuden vuoksi */
.modal .modal-content *,
.modal .modal-content {
    opacity: 1;
}

.modal-close {
    float: right;
    cursor: pointer;
}

.modal-actions {
    text-align: right;
    margin-top: 20px;
}

.modal-actions button {
    margin-left: 10px;
}

/* Sticky thead varmuus: pidä aina modalin alla */
.lane-day-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    /* reilusti alle modalin 9999 */
    background: var(--table-head-bg);
}

/* Varmuuden vuoksi: skrolleri ei luo uutta stacking contextia modalin yläpuolelle */
.calendar-scroller {
    z-index: 1;
    transform: none !important;
}

/* Responsiivisuus: pinotaan toolbar mobiilissa */
@media (max-width: 900px) {
    body {
        margin: 1em;
    }

    .lane-select-form .lane-select-row {
        grid-template-columns: 1fr;
    }

    .lane-select-form .left,
    .lane-select-form .center,
    .lane-select-form .right {
        justify-self: stretch;
        text-align: left;
    }
}

.res-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.res-item .label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 16ch;
}

@media (min-width: 1024px) {
    .res-item .label {
        max-width: 22ch;
    }
}