/* ==========================================
   css/reservations.css
   Only what is specific to the Reservations website: campus maps, room list, 15-minute timeline,
   slot and status colours. Layout, header, sidebar/drawer, buttons, forms, tables, dialogs and the
   light/dark tokens come from css/core.css + css/portal.css (same as the LMS), and phones are handled
   by core/ui-responsive.js.
   ========================================== */

/* ---------- Campus maps ---------- */
.campus-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    width: 100%;
}

.maps-container {
    flex: 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    min-width: 0;
}

.map-section {
    background: var(--bg-card);
    border-radius: var(--radius-md, 16px);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.map-section-title {
    margin: 0 0 12px;
    color: var(--theme-primary);
    font-size: 1.1rem;
}

.svg-map-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 380px;
    width: 100%;
    overflow: hidden;
}

.svg-map-wrapper svg {
    width: 100%;
    height: 100%;
}

/* Only drawn shapes take clicks; no grey tap flash on phones */
.svg-map-wrapper,
.svg-map-wrapper svg,
.svg-map-wrapper svg * {
    pointer-events: visiblePainted;
    -webkit-tap-highlight-color: transparent;
}

.svg-map-wrapper path[id],
.svg-map-wrapper g[id] {
    cursor: pointer;
    transition: filter 0.3s ease;
}

/* Invisible hit areas (b_*) over the 3D drawings (a_*) */
#b_security, #b_church_0, #b_church_1, #b_market, #b_library,
#b_mechanical, #b_out_room, #b_bakery, #b_play, #b_bathrooms,
#b_tower, #b_basement, #b_utility, #b_service_0, #b_service_1,
#b_service_2, #b_service_3 {
    opacity: 0;
    cursor: pointer;
    pointer-events: all !important;
}

/* Hovering a hit area lights up its drawing */
.svg-map-wrapper svg:has(#b_security:hover) #a_security,
.svg-map-wrapper svg:has(#b_church_0:hover) #a_church_0,
.svg-map-wrapper svg:has(#b_church_1:hover) #a_church_1,
.svg-map-wrapper svg:has(#b_market:hover) #a_market,
.svg-map-wrapper svg:has(#b_library:hover) #a_library,
.svg-map-wrapper svg:has(#b_mechanical:hover) #a_mechanical,
.svg-map-wrapper svg:has(#b_out_room:hover) #a_out_room,
.svg-map-wrapper svg:has(#b_bakery:hover) #a_bakery,
.svg-map-wrapper svg:has(#b_play:hover) #a_play,
.svg-map-wrapper svg:has(#b_bathrooms:hover) #a_bathrooms,
.svg-map-wrapper svg:has(#b_tower:hover) #a_tower,
.svg-map-wrapper svg:has(#b_basement:hover) #a_basement,
.svg-map-wrapper svg:has(#b_utility:hover) #a_utility,
.svg-map-wrapper svg:has(#b_service_0:hover) #a_service_0,
.svg-map-wrapper svg:has(#b_service_1:hover) #a_service_1,
.svg-map-wrapper svg:has(#b_service_2:hover) #a_service_2,
.svg-map-wrapper svg:has(#b_service_3:hover) #a_service_3 {
    filter: drop-shadow(0 0 12px var(--theme-primary)) brightness(1.15);
}

/* Availability search: green = something free in that zone, red = all taken */
.zone-available {
    filter: drop-shadow(0 0 15px var(--theme-success)) brightness(1.1) !important;
    transition: filter 0.3s ease;
}

.zone-booked {
    filter: drop-shadow(0 0 15px var(--theme-danger)) opacity(0.6) grayscale(0.5) !important;
    cursor: not-allowed !important;
    transition: filter 0.3s ease;
}

/* ---------- Room list (next to the maps) ---------- */
.booking-panel {
    flex: 1;
    background: var(--bg-card);
    border-radius: var(--radius-md, 16px);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    display: flex;
    flex-direction: column;
    min-width: 280px;
    max-width: 380px;
}

.room-list-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.room-list-item {
    background: var(--bg-panel);
    padding: 14px;
    border-radius: var(--radius-sm, 12px);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    border: 1px solid transparent;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.room-list-item:hover {
    background: var(--theme-primary);
    color: var(--text-inverse);
    transform: translateY(-2px);
}

/* ---------- Schedule: 15-minute timeline ---------- */
.res-schedule-card {
    background: var(--bg-card);
    border-radius: var(--radius-md, 16px);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    margin-bottom: 20px;
}

.res-schedule-head {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.res-legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 600;
}

.res-legend .is-available { color: var(--theme-success); }
.res-legend .is-pending { color: var(--theme-warning); }
.res-legend .is-booked { color: var(--theme-danger); }
.res-legend .is-selected { color: var(--theme-primary); }

/* As many 15-minute slots per row as fit, on any screen */
.timeline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 8px;
    user-select: none;
}

.time-slot {
    padding: 10px 4px;
    border-radius: var(--radius-sm, 12px);
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s ease, background-color 0.1s ease;
}

.slot-available {
    background-color: color-mix(in srgb, var(--theme-success) 12%, transparent);
    color: var(--theme-success);
    border-color: color-mix(in srgb, var(--theme-success) 35%, transparent);
}

.slot-available:hover {
    background-color: color-mix(in srgb, var(--theme-success) 22%, transparent);
}

.slot-booked {
    background-color: color-mix(in srgb, var(--theme-danger) 12%, transparent);
    color: var(--theme-danger);
    border-color: color-mix(in srgb, var(--theme-danger) 35%, transparent);
    cursor: not-allowed;
    opacity: 0.7;
}

.slot-pending {
    background-color: color-mix(in srgb, var(--theme-warning) 16%, transparent);
    color: var(--theme-warning);
    border-color: color-mix(in srgb, var(--theme-warning) 45%, transparent);
}

.slot-selected {
    background-color: var(--theme-primary);
    color: var(--text-inverse);
    border-color: var(--theme-primary);
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.slot-disabled {
    background-color: var(--bg-panel);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.45;
}

.res-booking-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.res-booking-form label {
    font-weight: 600;
    color: var(--text-main);
    margin-top: 8px;
}

.res-repeat-box {
    margin-top: 12px;
    padding: 14px;
    background: var(--bg-panel);
    border-radius: var(--radius-sm, 12px);
}

.res-selected-time {
    background: var(--bg-panel);
    padding: 14px;
    border-radius: var(--radius-sm, 12px);
    margin: 14px 0 6px;
    text-align: center;
}

.res-selected-time span {
    color: var(--theme-primary);
    font-size: 1.2rem;
    font-weight: 700;
}

/* ---------- Field labels ----------
   A label sits on its own line with a small gap above the field, so tall Arabic letters never touch it.
   Labels placed beside a field in a row (month pickers) keep no bottom gap. */
#dashboard-screen .portal-view label[for],
.modal label[for] {
    display: block;
    margin-bottom: 6px;
    line-height: 1.5;
}

#dashboard-screen .portal-view .u-ai-center > label[for] {
    margin-bottom: 0;
}

/* ---------- Status chips, small actions, misc ---------- */
.res-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--text-inverse);
}

.res-status.is-approved { background: var(--theme-success); }
.res-status.is-rejected { background: var(--theme-danger); }
.res-status.is-pending { background: var(--theme-warning); color: #1f1f1f; }

.res-actions-cell {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.res-btn-sm {
    padding: 5px 10px;
}

.res-btn-danger {
    color: var(--theme-danger);
}

/* portal.css gives the name a 42px min-height, which left it at the top of that box; centre it on the badge's line */
.class-topbar #user-name-display {
    display: inline-flex;
    align-items: center;
}

.res-role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--m-tonal, var(--bg-panel));
    color: var(--m-on-tonal, var(--text-main));
    font-size: 0.75rem;
    font-weight: 700;
}

.res-role-badge:empty {
    display: none;
}

.res-count-badge {
    display: inline-block;
    min-width: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--theme-danger);
    color: var(--text-inverse);
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
}

.res-forced-pass {
    margin: 0 0 15px;
    padding: 10px 12px;
    border-radius: var(--radius-sm, 12px);
    background: color-mix(in srgb, var(--theme-warning) 14%, transparent);
    color: var(--text-main);
    font-size: 0.9rem;
}

.res-detail-label {
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 0.9em;
}

.res-detail-value {
    padding: 8px 12px;
    background: var(--bg-panel);
    border-radius: var(--radius-sm, 12px);
    margin-bottom: 14px;
    color: var(--text-main);
    min-height: 1.4em;
}

.res-login-logo {
    max-width: 150px;
    height: auto;
    display: block;
    margin: 0 auto 18px;
}

.res-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes resFlashRow {
    0% { background-color: transparent; }
    20%, 80% { background-color: color-mix(in srgb, var(--theme-danger) 25%, transparent); }
    100% { background-color: transparent; }
}

.highlight-row {
    animation: resFlashRow 3s ease-in-out;
}

/* Dark theme: primary-coloured text uses the light tonal shade (as .u-c-theme-primary does in core.css) */
[data-theme="dark"] .map-section-title,
[data-theme="dark"] .res-selected-time span,
[data-theme="dark"] .res-legend .is-selected {
    color: var(--m-on-tonal);
}

/* Pending requests on the Reservations menu item (data-count set by listenToAllReservations) */
.class-nav-link[data-count]::after {
    content: attr(data-count);
    margin-inline-start: auto;
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--theme-danger);
    color: var(--text-inverse);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
}

/* ---------- Tablets and phones ---------- */
@media (max-width: 1100px) {
    .campus-layout {
        flex-direction: column;
    }

    .maps-container {
        grid-template-columns: 1fr;
        width: 100%;
        flex: unset;
    }

    .booking-panel {
        max-width: 100%;
        width: 100%;
        flex: unset;
    }
}

/* Tablet icon rail: the count sits on the icon's corner */
@media (min-width: 640px) and (max-width: 1023.98px) {
    .class-nav-link[data-count] {
        position: relative;
    }

    .class-nav-link[data-count]::after {
        position: absolute;
        top: 2px;
        inset-inline-end: 6px;
        margin: 0;
    }
}

@media (max-width: 639.98px) {
    /* Phones: no account type next to the name */
    #user-role {
        display: none !important;
    }

    .svg-map-wrapper {
        min-height: 240px;
    }

    .map-section,
    .booking-panel,
    .res-schedule-card {
        padding: 14px;
    }

    .timeline-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    }

    .time-slot {
        padding: 12px 4px;
    }
}
