/* =========================================================
   Room Booking Module – Styles
   ========================================================= */

/* ── Calendar wrapper ── */
.room-booking-calendar,
.room-booking-approval,
.room-booking-rooms,
.room-booking-slots,
.room-booking-admin,
.room-booking-room-form,
.room-booking-slot-form,
.room-booking-detail {
    width: 80%;
    margin: 0 auto;
}

/* ── Calendar grid ── */
.rb-calendar-table {
    width: 100%;
    table-layout: fixed;
}

.rb-calendar-table thead th {
    background: #f8f9fa;
    white-space: nowrap;
    vertical-align: middle;
    font-size: 0.82rem;
    padding: 6px 8px;
}

.rb-room-col {
    width: 200px;
    font-size: 1rem;
    font-weight: 700;
    padding-left: 20px !important;
}

.rb-slot-col {
    /* slots distribute the remaining space equally */
}

.rb-room-name {
    vertical-align: middle;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 8px 6px 20px;
}

.rb-room-child {
    padding-left: 36px !important;
    background: #fafafa;
    font-size: 0.85rem;
    font-weight: 400;
}

.rb-cell {
    padding: 4px !important;
    vertical-align: middle;
}

/* ── Cell buttons ── */
.rb-cell-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

.rb-cell-btn:not(:disabled):hover {
    opacity: 0.85;
    transform: scale(1.08);
}

.rb-cell-btn:disabled {
    cursor: default;
    opacity: 0.55;
}

/* ── Merged group block ── */
.rb-cell-merged {
    width: 100% !important;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 4px;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-merged-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-merged-time {
    opacity: 0.85;
    font-size: 0.7rem;
}

/* Vertical merged block (week view — rowspan) */
.rb-cell-merged-v {
    width: 100% !important;
    height: 100% !important;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 4px;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Merged cell background (room weekly rowspan) ── */
.rb-merged-td {
    padding: 0 !important;
    cursor: pointer;
}
.rb-merged-td-booked  { background-color: #dc3545 !important; }
.rb-merged-td-pending { background-color: #fd7e14 !important; }
.rb-merged-td-blocked { background-color: #adb5bd !important; }

.rb-merged-td .rb-cell-merged-v {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #fff;
}

/* ── Group indicator ── */
.rb-group-icon {
    font-size: 8px;
    position: relative;
    top: -6px;
    right: -1px;
    opacity: 0.8;
}

.rb-group-highlight {
    outline: 2px solid #ffc107 !important;
    outline-offset: 1px;
    box-shadow: 0 0 6px rgba(255, 193, 7, 0.6);
    z-index: 1;
    position: relative;
}

/* ── Status colour overrides (ensure contrast) ── */
.rb-cell-btn.btn-success  { background-color: #28a745; border-color: #28a745; color: #fff; }
.rb-cell-btn.btn-warning  { background-color: #fd7e14; border-color: #fd7e14; color: #fff; }
.rb-cell-btn.btn-danger   { background-color: #dc3545; border-color: #dc3545; color: #fff; }
.rb-cell-btn.btn-secondary{ background-color: #adb5bd; border-color: #adb5bd; color: #fff; }

/* ── Legend badges ── */
.rb-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 0.82rem;
}

.rb-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.rb-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.rb-legend-dot.available  { background: #28a745; }
.rb-legend-dot.pending    { background: #fd7e14; }
.rb-legend-dot.booked     { background: #dc3545; }
.rb-legend-dot.blocked    { background: #adb5bd; }

/* ── Grid loading / empty states ── */
#rb-grid .rb-loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 1rem;
}

/* ── Alert area ── */
#rb-alerts .alert {
    margin-bottom: 12px;
}

/* ── Room name link in daily grid ── */
.rb-room-link {
    color: inherit;
    text-decoration: none;
}
.rb-room-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* ── Week view ── */
.rb-week-table thead th {
    background: #f0f4ff;
    text-align: center;
    font-size: 0.82rem;
    white-space: nowrap;
}

.rb-week-table td {
    text-align: center;
    padding: 4px !important;
    vertical-align: middle;
}

/* ── Approval table ── */
.rb-approval-table td {
    vertical-align: middle;
    font-size: 0.88rem;
}

.rb-status-badge {
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 10px;
    color: #fff;
}

.rb-status-pending   { background-color: #fd7e14; }
.rb-status-approved  { background-color: #28a745; }
.rb-status-rejected  { background-color: #dc3545; }
.rb-status-cancelled { background-color: #007bff; }

.btn-xs {
    padding: 1px 5px;
    font-size: 0.7rem;
    line-height: 1.5;
    border-radius: 3px;
}

/* ── Room type badges ── */
.rb-type-independent { background: #e2f0ff; color: #004085; }
.rb-type-parent      { background: #fff3cd; color: #856404; }
.rb-type-child       { background: #f8f9fa; color: #495057; }

/* ── Forms ── */
#rb-parent-id-group {
    transition: opacity 0.2s;
}

/* ── Room checkboxes in create modal ── */
#rb-modal-room-checkboxes {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    background: #fafafa;
}

#rb-modal-room-checkboxes .form-check {
    margin-bottom: 2px;
}

/* ── Modal tweaks ── */
#rb-reservation-modal .modal-header {
    background: #007bff;
    color: #fff;
}

#rb-reservation-modal .modal-header .close {
    color: #fff;
    opacity: 0.8;
}

#rb-reservation-modal .rb-info-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

#rb-reservation-modal .rb-info-label {
    min-width: 80px;
    font-weight: 600;
    color: #495057;
    font-size: 0.88rem;
}

/* ── Weekly view (all rooms) ── */
.rb-weekly-cell {
    padding: 2px 4px !important;
    vertical-align: top;
    min-width: 100px;
}

.rb-weekly-block {
    display: block;
    padding: 2px 5px;
    margin-bottom: 2px;
    background: #f8f9fa;
    border-radius: 3px;
    font-size: 0.75rem;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.rb-weekly-block:hover {
    background: #e9ecef;
    text-decoration: none;
    color: inherit;
}

.rb-weekly-name {
    font-weight: 500;
    margin-left: 3px;
}

.rb-weekly-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    text-decoration: none;
}

.rb-today-col {
    background-color: #fffde7 !important;
}

/* ── Monthly view ── */
.rb-monthly-table {
    table-layout: fixed;
}

.rb-monthly-table thead th {
    background: #f8f9fa;
    text-align: center;
    font-size: 0.85rem;
    padding: 8px;
}

.rb-monthly-cell {
    height: 90px;
    vertical-align: top;
    padding: 4px 6px !important;
}

.rb-monthly-empty {
    background: #fafafa;
}

.rb-monthly-day-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.rb-monthly-day-link:hover {
    background: #f0f4ff;
    text-decoration: none;
    color: inherit;
    border-radius: 4px;
}

.rb-monthly-day-num {
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-block;
    margin-bottom: 3px;
}

.rb-today-badge {
    background: #007bff;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
}

.rb-monthly-rooms {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.rb-monthly-room-tag {
    display: block;
    background: #e8f0fe;
    color: #1a73e8;
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.rb-monthly-room-tag small {
    color: #5f6368;
    margin-left: 2px;
}

.rb-monthly-room-tag.rb-more {
    background: #f0f0f0;
    color: #666;
}

/* ── Responsive tweaks ── */
@media (max-width: 768px) {
    .room-booking-calendar,
    .room-booking-approval,
    .room-booking-rooms,
    .room-booking-slots,
    .room-booking-admin,
    .room-booking-room-form,
    .room-booking-slot-form,
    .room-booking-detail {
        width: 100%;
    }

    .rb-calendar-table {
        font-size: 0.78rem;
        table-layout: auto;
    }
    .rb-cell-btn {
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
    }
    .rb-room-col {
        width: 120px;
    }
}

/* ── Audit timeline ─────────────────────────────────────────── */
.rb-timeline {
    list-style: none;
    padding-left: 0;
    margin: 0;
}
.rb-timeline-item {
    padding: 6px 0 6px 24px;
    position: relative;
    border-left: 2px solid #dee2e6;
    margin-left: 8px;
}
.rb-timeline-item:last-child {
    border-left-color: transparent;
}
.rb-timeline-icon {
    position: absolute;
    left: -9px;
    top: 8px;
    background: #f8f9fa;
    padding: 2px;
}
.rb-timeline-changes {
    list-style: disc;
    padding-left: 20px;
    margin: 4px 0 0 0;
    font-size: 0.9em;
    color: #555;
}
.rb-timeline-comment {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
    margin-top: 2px;
}
.rb-timeline-container {
    max-height: 300px;
    overflow-y: auto;
}
.rb-history-trigger:hover {
    background-color: #f8f9fa;
}
