/* IceArena — minimalistlik jää-teemaline stiil */
:root {
    --bg: #f3f8fc;
    --surface: #ffffff;
    --ice-1: #e8f4fb;
    --ice-2: #cfe7f5;
    --primary: #0a84c4;
    --primary-dark: #046391;
    --text: #1a2833;
    --muted: #6b7b88;
    --border: #d9e4ee;
    --ok: #1f8a4c;
    --warn: #d08800;
    --danger: #c0392b;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(10, 50, 90, 0.06);
    --px-per-min: 1;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    gap: 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-dark);
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 1.4rem; }
.nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.nav a { color: var(--text); font-weight: 500; }
.user-chip {
    background: var(--ice-1);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--primary-dark);
}

/* Main */
.main {
    padding: 30px 20px 60px;
    min-height: calc(100vh - 140px);
}
h1 { font-size: 1.8rem; margin-top: 0; }
h2 { font-size: 1.3rem; margin-top: 2em; color: var(--primary-dark); }

/* Hero */
.hero {
    background: linear-gradient(135deg, var(--ice-1), var(--ice-2));
    border-radius: var(--radius);
    padding: 40px 30px;
    margin-bottom: 30px;
    text-align: center;
}
.hero h1 { margin: 0 0 8px; color: var(--primary-dark); }
.hero-sub { color: var(--muted); margin: 0; }

/* Day/slot grid */
.day-block { margin-bottom: 28px; }
.day-heading {
    font-size: 1.1rem;
    margin: 10px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--ice-2);
    color: var(--primary-dark);
}
.slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}
.slot-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.12s ease, border-color 0.12s ease;
}
.slot-card:hover { border-color: var(--primary); }
.slot-card.slot-full { opacity: 0.65; }
.slot-time {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-dark);
}
.slot-title { font-weight: 500; }
.slot-notes { font-size: 0.85rem; color: var(--muted); }
.slot-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    color: var(--muted);
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}
.free-tag {
    background: var(--ok);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}
.book-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 6px;
}
.book-form label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: var(--muted);
    flex: 0 0 70px;
}
.book-form input { padding: 6px 8px; }
.book-form button { flex: 1; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    transition: background 0.12s ease, transform 0.08s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--ice-1); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--ice-1); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a02a1e; }
.btn-disabled { background: #d0d7de; color: white; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }

/* Forms */
.form-box, .auth-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 480px;
    margin: 0 auto;
    box-shadow: var(--shadow);
}
.auth-box h1 { margin-top: 0; text-align: center; }
.auth-alt { text-align: center; margin-top: 18px; color: var(--muted); }

form label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}
form label.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
}
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="tel"],
form input[type="number"],
form input[type="datetime-local"],
form textarea,
form select {
    display: block;
    width: 100%;
    padding: 9px 11px;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
}
form input:focus, form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(10, 132, 196, 0.15);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 16px 0;
}
.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.table th {
    background: var(--ice-1);
    color: var(--primary-dark);
    font-weight: 600;
}
.table tr:last-child td { border-bottom: none; }
.row-muted { opacity: 0.55; }
.row-actions { white-space: nowrap; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-ok { background: #dcf2e4; color: var(--ok); }
.badge-muted { background: #e4e9ed; color: var(--muted); }

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--surface);
    border-left: 4px solid var(--primary);
    padding: 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat-num { font-size: 2rem; font-weight: 700; color: var(--primary-dark); }
.stat-lbl { color: var(--muted); font-size: 0.88rem; }

.admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 20px 0;
}

/* Empty / error */
.empty-state, .error-box {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--muted);
}
.error-box h1 { font-size: 4rem; color: var(--primary); margin: 0; }
.muted { color: var(--muted); }

/* Flashes */
.flash-stack { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 11px 16px;
    border-radius: 6px;
    font-size: 0.92rem;
}
.flash-success { background: #dcf2e4; color: var(--ok); border: 1px solid #a9d9b9; }
.flash-danger  { background: #fadedb; color: var(--danger); border: 1px solid #f2b5af; }
.flash-warning { background: #fcf0d1; color: var(--warn); border: 1px solid #f0ceA0; }
.flash-info    { background: var(--ice-1); color: var(--primary-dark); border: 1px solid var(--ice-2); }

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 16px 0;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 640px) {
    .topbar-inner { flex-direction: column; align-items: flex-start; }
    .nav { width: 100%; justify-content: flex-start; gap: 10px; }
    .form-row { grid-template-columns: 1fr; }
    .hero { padding: 28px 20px; }
    h1 { font-size: 1.5rem; }
}

/* ═════════════════════════════════════════════════════════════
   Gantt kalender — vertikaalne aeg × horisontaalsed päevad
   ═════════════════════════════════════════════════════════════ */
.gantt-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 20px;
}

.gantt-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.filter-group strong { color: var(--muted); font-size: 0.85rem; font-weight: 600; }

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--ice-1);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.88rem;
    user-select: none;
    transition: background 0.12s, border-color 0.12s;
}
.filter-chip input { display: none; }
.filter-chip:has(input:checked) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.filter-chip .chip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--chip-color, var(--primary));
    display: inline-block;
    border: 2px solid rgba(255, 255, 255, 0.6);
}
.filter-chip:has(input:checked) .chip-dot {
    border-color: rgba(255, 255, 255, 0.9);
}
.day-chip { min-width: 40px; justify-content: center; font-weight: 600; }

/* Gantti põhi-grid: flex-row, ajatelg vasakul, siis päevad — responsiivne */
.gantt-scroll {
    overflow: auto;
    max-height: 75vh;
    border: 1px solid var(--border);
    border-radius: 6px;
    position: relative;
}
.gantt-grid {
    display: flex;
    align-items: flex-start;
    width: 100%;
    min-width: min-content;
}

/* --- Ajatelg (vasak veerg) --- */
.gantt-time-col {
    flex: 0 0 56px;
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.gantt-time-header {
    height: 56px;  /* võrdne day-header kõrgusega */
    border-bottom: 1px solid var(--border);
    background: var(--ice-1);
    position: sticky;
    top: 0;
    z-index: 4;
}
.gantt-time-axis {
    position: relative;
    height: var(--total-height);
}
.gantt-hour-label {
    position: absolute;
    left: 0;
    right: 0;
    padding-right: 8px;
    text-align: right;
    font-size: 0.72rem;
    color: var(--muted);
    transform: translateY(-50%);
    line-height: 1;
}
.gantt-hour-label:first-child { transform: translateY(0); }

/* --- Päeva veerg (responsiivne: jagab saadavalolevat ruumi) --- */
.gantt-day-col {
    flex: 1 1 0;
    min-width: 120px;       /* 3 väljakut × 40px min */
    border-right: 1px solid var(--border);
}
.gantt-day-col:last-child { border-right: none; }

.gantt-day-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.gantt-day-name {
    padding: 6px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--primary-dark);
    background: var(--ice-1);
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gantt-rink-headers {
    display: flex;
}
.gantt-rink-header {
    flex: 1 1 0;
    min-width: 40px;
    padding: 4px 2px;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    color: var(--text);
    border-right: 1px dashed var(--border);
    border-top: 3px solid var(--primary);
    background: var(--surface);
    container-type: inline-size;
    overflow: hidden;
}
.gantt-rink-header:last-child { border-right: none; }

/* Rink-headeri vaikimisi lühike; pikk kuvatakse kui ruumi on */
.rink-hdr-full { display: none; }
.rink-hdr-short { display: inline; }
@container (min-width: 75px) {
    .rink-hdr-full { display: inline; }
    .rink-hdr-short { display: none; }
}

/* --- Päeva body: kolm väljaku rada kõrvuti --- */
.gantt-day-body {
    display: flex;
    height: var(--total-height);
}
.gantt-rink-track {
    flex: 1 1 0;
    min-width: 40px;
    position: relative;
    border-right: 1px dashed var(--border);
    cursor: crosshair;
    background: var(--bg);
    container-type: inline-size;
}
.gantt-rink-track:last-child { border-right: none; }
.gantt-wrapper[data-editable="0"] .gantt-rink-track { cursor: default; }

.gantt-gridline {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
    opacity: 0.5;
    pointer-events: none;
}

.gantt-booking {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 4px;
    padding: 3px 5px;
    color: white;
    font-size: 0.7rem;
    line-height: 1.15;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
    z-index: 1;
}
.gantt-booking:hover {
    transform: translateX(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    z-index: 2;
}
.gantt-booking-time { font-weight: 700; font-size: 0.72rem; }
.gantt-booking-title {
    font-weight: 500;
    opacity: 0.95;
    overflow: hidden;
    line-height: 1.2;
    word-break: break-word;
}
.gantt-booking-user {
    opacity: 0.85;
    font-size: 0.65rem;
    font-style: italic;
    display: none;       /* vaikimisi peidetud, näidatakse kui ruumi on */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gantt-booking-notes {
    font-size: 0.62rem;
    opacity: 0.8;
    margin-top: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    padding-top: 2px;
    display: none;       /* vaikimisi peidetud */
    overflow: hidden;
    line-height: 1.15;
}

/* Aeg: vaikimisi ainult algus, laias vaates kogu intervall */
.gantt-booking-time .time-full { display: none; }
.gantt-booking-time .time-short { display: inline; }

/* Progressiivne sisu: rohkem ruumi → rohkem infot
   Container queries kuvavad detaile vastavalt track'i laiusele */
@container (min-width: 70px) {
    .gantt-booking-time .time-full { display: inline; }
    .gantt-booking-time .time-short { display: none; }
}
@container (min-width: 85px) {
    .gantt-booking-user { display: block; }
}
@container (min-width: 120px) {
    .gantt-booking-notes { display: block; }
    .gantt-booking-title { font-size: 0.78rem; }
}
@container (min-width: 180px) {
    .gantt-booking-time { font-size: 0.85rem; }
    .gantt-booking-title { font-size: 0.88rem; font-weight: 600; }
}

/* Pikaajalise broneeringu märgis Gantti plokil */
.gantt-booking.is-recurring {
    border-left: 3px solid rgba(255, 255, 255, 0.9);
    background-image: repeating-linear-gradient(
        135deg,
        transparent 0, transparent 8px,
        rgba(255, 255, 255, 0.12) 8px, rgba(255, 255, 255, 0.12) 10px
    );
}
.recurring-badge {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 0.85rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    pointer-events: none;
}

/* Listi tabelis ↻ rosett */
.badge-recurring {
    background: var(--primary);
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 4px;
}

.gantt-empty {
    text-align: center;
    padding: 30px;
    color: var(--muted);
    font-style: italic;
}

/* Nädala navigeerimise riba */
.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.week-nav-label { font-weight: 600; color: var(--primary-dark); }
.week-nav-buttons { display: flex; gap: 8px; }

/* ═════════════════════════════════════════════════════════════
   Vahekaardid (tabs)
   ═════════════════════════════════════════════════════════════ */
.tabs {}
.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 18px;
}
.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: inherit;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Pikaajaline broneering — korduvad iganädalased */
.longterm-section {
    background: var(--ice-1);
    border: 1px solid var(--ice-2);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
}
.longterm-section > label.checkbox {
    margin-bottom: 0;
    font-weight: normal;
    cursor: pointer;
}
.longterm-counter {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 14px 0 10px;
}
.lt-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: var(--surface);
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.12s, transform 0.08s;
    font-family: inherit;
}
.lt-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}
.lt-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.lt-display {
    font-size: 1rem;
    color: var(--primary-dark);
    min-width: 90px;
    text-align: center;
}
.lt-display strong {
    font-size: 1.4rem;
    color: var(--primary);
    margin-right: 4px;
}
.longterm-preview {
    list-style: decimal inside;
    margin: 8px 0 0;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.88rem;
    max-height: 240px;
    overflow-y: auto;
}
.longterm-preview li {
    padding: 4px 0;
    border-bottom: 1px dashed var(--border);
}
.longterm-preview li:last-child { border-bottom: none; }

/* Broneeringu värvi valiku rida */
.color-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--ice-1);
    border-radius: 6px;
}
.color-label {
    margin-bottom: 0 !important;
}
.color-label input[type="color"] {
    width: 60px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: white;
}
.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid var(--border);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    margin-left: auto;
}

/* Värvilaik (nt väljaku haldus lehel) */
.color-swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    vertical-align: middle;
    margin-right: 6px;
}

@media (max-width: 640px) {
    .gantt-filters { flex-direction: column; gap: 10px; }
    .gantt-time-col { flex: 0 0 44px; }
    .gantt-day-col { min-width: 105px; }    /* 3 × 35 */
    .gantt-rink-header,
    .gantt-rink-track { min-width: 35px; }
    .gantt-rink-header { font-size: 0.62rem; padding: 3px 1px; }
    .gantt-hour-label { font-size: 0.62rem; padding-right: 4px; }
    .gantt-day-name { font-size: 0.68rem; padding: 4px 2px; }
    .gantt-booking { padding: 2px 3px; font-size: 0.62rem; }
}
