/* ═══════════════════════════════════════════════════════════
   calendar.css — Weekly calendar, Entity picker (reports),
                  Operator calendar, Seminar calendars,
                  Embed calendar
   ═══════════════════════════════════════════════════════════ */

/* ========== Weekly Calendar ========== */
.week-calendar {
    display: grid;
    grid-template-columns: 48px repeat(7, 1fr);
    gap: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.75rem;
}

.week-calendar-header {
    background: #f1f5f9;
    padding: 0.3rem 0.15rem;
    text-align: center;
    font-weight: 600;
    border-bottom: 2px solid #d1d5db;
    font-size: 0.7rem;
}

.week-calendar-header.today {
    background: var(--brand-muted, #edf7ee);
    color: var(--brand-dark, #367f39);
}

.week-calendar-header.time-col {
    border-right: 1px solid #d1d5db;
}

.week-calendar-time {
    background: #f8fafc;
    padding: 0 0.2rem;
    text-align: right;
    font-size: 0.65rem;
    color: #6b7280;
    border-right: 1px solid #d1d5db;
    border-bottom: 1px solid #f0f0f0;
    height: 1.2rem;
    line-height: 1.2rem;
}

.week-calendar-time.hour-start {
    border-top: 1px solid #d1d5db;
}

.week-calendar-cell {
    border-bottom: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
    height: 1.2rem;
    position: relative;
    cursor: pointer;
    transition: background 0.1s;
}

.week-calendar-cell.hour-start {
    border-top: 1px solid #d1d5db;
}

.week-calendar-cell:hover {
    background: var(--brand-muted, #edf7ee);
}

.week-calendar-cell.past {
    background: #f9fafb;
    cursor: default;
}

.week-calendar-cell.past:hover {
    background: #f9fafb;
}

.week-calendar-cell.range-selecting {
    background: var(--brand-muted, #edf7ee);
}

.week-calendar-cell.range-start {
    background: var(--brand, #45a349);
}

.week-calendar-cell.range-end {
    background: var(--brand, #45a349);
}

/* Multi-day date selection mode */
.week-calendar-cell.multiday-selected {
    background: #d1fae5;
    border-color: #6ee7b7;
}

.week-calendar-header.multiday-selected {
    background: #10b981;
    color: #fff;
}

.week-cal-event {
    position: absolute;
    left: 1px;
    right: 1px;
    background: #fee2e2;
    border-left: 3px solid var(--status-reserved-fill);
    border-radius: 2px;
    padding: 0px 3px;
    font-size: 0.6rem;
    line-height: 1.15;
    overflow: hidden;
    z-index: 2;
    color: var(--status-reserved-text);
}

.week-cal-event.pending {
    background: var(--status-pending-bg);
    border-left-color: var(--status-pending-fill);
    color: var(--status-pending-text);
}

.week-cal-event.recurring {
    background: var(--status-completed-bg);
    border-left-color: var(--status-completed-fill);
    color: var(--status-completed-text);
}

.week-cal-event.recurring.pending {
    background: var(--status-pending-bg);
    border-left-color: var(--status-pending-fill);
    color: var(--status-pending-text);
}

.week-cal-event.guest {
    background: var(--guest-bg);
    border-left-color: var(--guest-fill);
    color: var(--guest-text);
}

.week-cal-event.starting-soon {
    background: var(--status-starting-soon-bg);
    border-left-color: var(--status-starting-soon-fill);
    color: var(--status-starting-soon-text);
}

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.week-nav button {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.week-nav button:hover {
    background: #f1f5f9;
}

.week-nav .week-label {
    font-weight: 600;
    font-size: 0.85rem;
}

.week-nav .week-datepicker {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.week-nav .week-datepicker input[type="date"] {
    padding: 0.15rem 0.4rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.8rem;
}

.week-nav .week-datepicker button {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
}

/* ========== Entity Picker (Reports) ========== */
.entity-picker {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    max-width: 600px;
    height: 310px;
    min-height: 180px;
    max-height: 600px;
    resize: vertical;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.entity-picker-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 6px 6px 0 0;
    flex-shrink: 0;
}

.entity-picker-toolbar .form-control {
    margin-bottom: 0;
}

.entity-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.entity-picker-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.8rem;
    color: #1e293b;
    padding: 0.4rem 0.75rem 0.15rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f0f4f8;
    border-top: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1;
    cursor: pointer;
}

.entity-picker-group:first-child .entity-picker-group-header {
    border-top: none;
}

.entity-picker-subgroup-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.78rem;
    color: #64748b;
    padding: 0.3rem 0.75rem 0.1rem 1.25rem;
    cursor: pointer;
}

.entity-picker-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem 0.25rem 2rem;
    cursor: pointer;
    font-size: 0.88rem;
    transition: background 0.1s;
}

.entity-picker-item:hover {
    background: var(--brand-muted, #edf7ee);
}

.entity-picker-item input[type="checkbox"] {
    flex-shrink: 0;
}

.entity-picker-name {
    flex: 1;
    min-width: 0;
}

.entity-picker-type {
    flex-shrink: 0;
    font-size: 0.75rem;
}

.entity-picker-parent-group {
    border-left: 2px solid #e2e8f0;
    margin-left: 1.25rem;
    margin-top: 0.15rem;
    margin-bottom: 0.15rem;
}

.entity-picker-parent-item {
    padding-left: 0.75rem !important;
    font-weight: 600;
}

.entity-picker-child-item {
    padding-left: 1.5rem !important;
    font-size: 0.84rem;
}

.picker-hidden {
    display: none !important;
}

/* ========== Calendar View (Operator Gantt) ========== */
.cal-wrapper {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}

.cal-table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    font-size: 0.8rem;
}

.cal-table thead {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f9fafb;
}

.cal-table tfoot {
    position: sticky;
    bottom: 0;
    z-index: 3;
    background: #f9fafb;
    border-top: 2px solid #d1d5db;
}

/* Bed rows: visually indented under their parent hotel room */
.cal-bed-row .cal-entity-cell {
    background: #f8fafc;
}

.cal-bed-row .cal-entity-name {
    font-size: 0.82rem;
    color: #475569;
    padding-left: 0.25rem;
}

.cal-entity-header {
    position: sticky;
    left: 0;
    z-index: 9;
    background: #f9fafb;
    min-width: 220px;
    max-width: 260px;
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-right: 2px solid #d1d5db;
    border-bottom: 2px solid #d1d5db;
    font-weight: 600;
}

.cal-date-header {
    min-width: 36px;
    max-width: 36px;
    padding: 0.25rem 0.15rem;
    text-align: center;
    border-bottom: 2px solid #d1d5db;
    border-right: 1px solid #f3f4f6;
    font-weight: 500;
    line-height: 1.2;
    vertical-align: bottom;
}

.cal-day-name {
    display: block;
    font-size: 0.65rem;
    color: #9ca3af;
    text-transform: uppercase;
}

.cal-day-num {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
}

.cal-month {
    display: block;
    font-size: 0.6rem;
    color: #6b7280;
    font-weight: 400;
}

.cal-weekend {
    background: #f9fafb;
}

.cal-today-col {
    background: var(--brand-muted, #edf7ee) !important;
    border-bottom-color: var(--brand, #45a349);
}

.cal-entity-cell {
    position: sticky;
    left: 0;
    z-index: 8;
    background: #fff;
    padding: 0.4rem 0.75rem;
    border-right: 2px solid #d1d5db;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-entity-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-entity-meta {
    font-size: 0.65rem;
    color: #9ca3af;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-cell {
    min-width: 36px;
    max-width: 36px;
    height: 32px;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #f3f4f6;
    padding: 2px;
}

/* ── Gantt-style span cells ── */
.cal-span {
    height: 32px;
    border-bottom: 1px solid #f3f4f6;
    border-right: 1px solid #f3f4f6;
    padding: 0;
    position: relative;
    overflow: hidden;
}

/* Non-available spans get a left accent border */
.cal-span.cal-RESERVED    { border-left: 3px solid var(--cal-reserved-border); }
.cal-span.cal-PENDING     { border-left: 3px solid var(--cal-pending-border); }
.cal-span.cal-MAINTENANCE { border-left: 3px solid var(--cal-maintenance-border); }
.cal-span.cal-UNAVAILABLE { border-left: 3px solid var(--status-unavailable-stroke); }

.cal-span-label {
    position: absolute;
    top: 0;
    left: 4px;
    right: 4px;
    bottom: 0;
    display: flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    line-height: 32px;
}

.cal-AVAILABLE    { background: var(--cal-available-bg); }
.cal-RESERVED     { background: var(--cal-reserved-bg); }
.cal-PENDING      { background: var(--cal-pending-bg); }
.cal-MAINTENANCE  { background: var(--cal-maintenance-bg); }
.cal-UNAVAILABLE  { background: var(--cal-unavailable-bg); }

/* ── Hotel calendar per-cell split (TL morning / BR afternoon) ──
   Each hotel day is two triangles that tile the cell perfectly.
   TL = top-left  = 0:00–14:00 (checkout morning or free morning)
   BR = bottom-right = 14:00–24:00 (checkin afternoon or free afternoon)
   Same-day turnaround: TL = checkout reservation, BR = checkin reservation. */

.cal-hotel-cell {
    height: 32px;
    min-width: 36px;
    max-width: 36px;
    padding: 0;
    position: relative;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    border-right: 1px solid #f3f4f6;
}

.cal-half {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

/* TL: upper-left triangle (diagonal from top-right to bottom-left) */
.cal-half-tl { clip-path: polygon(0 0, 100% 0, 0 100%); }
/* BR: lower-right triangle */
.cal-half-br { clip-path: polygon(100% 0, 100% 100%, 0 100%); }

.cal-half.cal-AVAILABLE   { background: var(--cal-available-bg); }
.cal-half.cal-RESERVED    { background: var(--cal-reserved-bg); }
.cal-half.cal-PENDING     { background: var(--cal-pending-bg); }
.cal-half.cal-MAINTENANCE { background: var(--cal-maintenance-bg); }
.cal-half.cal-UNAVAILABLE { background: var(--cal-unavailable-bg); }

/* Unified reservation hover: brighten fill (SVG border added by JS) */
.cal-half.cal-res-hover { filter: brightness(1.12); }

/* Available half hover (JS-applied class via td mousemove) */
.cal-half.cal-avail-hover { background: #86efac !important; filter: none; }

/* ── Reservation label overlay (injected by JS into check-in <td>) ── */
.cal-hotel-label {
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
    z-index: 5;
    display: flex;
    align-items: center;
    font-size: 0.63rem;
    font-weight: 600;
    color: #7f1d1d;
    white-space: nowrap;
    overflow: hidden;
}

/* ── SVG hover border (injected by JS, shown on mouseenter) ── */
.cal-hotel-hover-svg {
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
    z-index: 6;
    overflow: visible;
    visibility: hidden;
}

/* ── Same-day turnaround separator (permanent diagonal line) ── */
.cal-cell-separator {
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
    z-index: 7;
    overflow: visible;
}

/* ── Instant custom tooltip (replaces browser title to avoid ~1s delay) ── */
.cal-hotel-tooltip {
    position: fixed;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    padding: 5px 9px;
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1.45;
    pointer-events: none;
    white-space: pre-line;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    max-width: 260px;
}

/* Label color overrides for readability */
.cal-RESERVED .cal-span-label    { color: var(--status-reserved-text); }
.cal-PENDING .cal-span-label     { color: var(--status-pending-text); }
.cal-MAINTENANCE .cal-span-label { color: var(--status-maintenance-text); }
.cal-UNAVAILABLE .cal-span-label { color: var(--status-unavailable-text); }

.cal-clickable:hover {
    opacity: 0.8;
    outline: 2px solid var(--brand, #45a349);
    outline-offset: -2px;
    cursor: pointer;
}

.cal-clickable-create {
    cursor: pointer;
    transition: background 0.15s;
}

.cal-clickable-create:hover {
    background: #86efac !important;
    outline: 2px solid #16a34a;
    outline-offset: -2px;
}

/* Alternate row striping */
.cal-table tbody tr:nth-child(even) .cal-entity-cell {
    background: #fafafa;
}

/* ── Seminar calendar (operator) ───────────────────── */
.sem-cal-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.sem-cal-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 600px;
    font-size: 0.75rem;
    table-layout: fixed;
}
.sem-cal-time-header {
    width: 55px;
    min-width: 55px;
    text-align: right;
    padding: 4px 6px;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
    position: sticky;
    left: 0;
    z-index: 2;
}
.sem-cal-room-header {
    text-align: center;
    padding: 4px 6px;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
    min-width: 85px;
}
.sem-cal-room-name {
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sem-cal-room-meta {
    font-size: 0.65rem;
    color: #6b7280;
}
.sem-cal-time-cell {
    width: 55px;
    min-width: 55px;
    text-align: right;
    padding: 0 6px;
    color: #6b7280;
    font-size: 0.7rem;
    border-right: 1px solid #e5e7eb;
    background: #fafafa;
    position: sticky;
    left: 0;
    z-index: 1;
    height: 16px;
}
.sem-cal-cell {
    height: 16px;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #f9fafb;
    position: relative;
}
.sem-cal-hour-row .sem-cal-cell,
.sem-cal-hour-row .sem-cal-time-cell {
    border-top: 1px solid #e5e7eb;
}
.sem-cal-event {
    position: absolute;
    left: 1px;
    right: 1px;
    background: #fee2e2;
    border-left: 3px solid var(--status-reserved-fill);
    border-radius: 2px;
    padding: 1px 4px;
    font-size: 0.65rem;
    line-height: 1.2;
    overflow: hidden;
    z-index: 3;
}
.sem-cal-event.recurring {
    background: var(--status-completed-bg);
    border-left-color: var(--status-completed-fill);
}
.sem-cal-event.guest {
    background: var(--guest-bg);
    border-left-color: var(--guest-fill);
}
.sem-cal-event.pending {
    background: var(--status-pending-bg);
    border-left-color: var(--status-pending-fill);
}
.sem-cal-event:hover {
    opacity: 0.85;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* ── Embed seminar calendar ───────────────────────── */
.embed-sem-cal-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.embed-sem-cal-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 600px;
    font-size: 0.75rem;
    table-layout: fixed;
}
.embed-sem-cal-time-header {
    width: 55px;
    min-width: 55px;
    text-align: right;
    padding: 4px 6px;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
    position: sticky;
    left: 0;
    z-index: 2;
}
.embed-sem-cal-room-header {
    text-align: center;
    padding: 4px 6px;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
    min-width: 85px;
}
.embed-sem-cal-room-name {
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.embed-sem-cal-room-meta {
    font-size: 0.65rem;
    color: #6b7280;
}
.embed-sem-cal-time-cell {
    width: 55px;
    min-width: 55px;
    text-align: right;
    padding: 0 6px;
    color: #6b7280;
    font-size: 0.7rem;
    border-right: 1px solid #e5e7eb;
    background: #fafafa;
    position: sticky;
    left: 0;
    z-index: 1;
    height: 16px;
}
.embed-cell {
    height: 16px;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #f9fafb;
    position: relative;
}
.embed-sem-cal-hour-row .embed-cell,
.embed-sem-cal-hour-row .embed-sem-cal-time-cell {
    border-top: 1px solid #e5e7eb;
}

/* ── Embed navigation & layout ── */
.embed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.embed-nav-btn {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
}
.embed-nav-btn:hover {
    background: #f1f5f9;
}
.embed-week-label {
    font-weight: 600;
    font-size: 0.85rem;
}
.embed-day-header {
    font-size: 0.7rem;
    text-align: center;
}
.embed-cell {
    position: relative;
}
.embed-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
}
.embed-footer {
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: #9ca3af;
    text-align: center;
}

/* ── Seminar calendar day tabs (operator) ── */
.sem-cal-day-tabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.sem-cal-day-tab { text-align: center; line-height: 1.3; min-width: 44px; }
.sem-cal-day-tab.active { background: var(--brand, #45a349) !important; color: #fff !important; border-color: var(--brand-dark, #367f39) !important; }
.sem-cal-day-tab.is-today:not(.active) { border-color: var(--brand, #45a349); color: var(--brand-dark, #367f39); }

/* ── Seminar calendar day tabs (embed) ── */
.embed-day-tabs {
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}
.embed-day-tab { text-align: center; line-height: 1.3; min-width: 36px; }
.embed-day-tab.active { background: var(--brand, #45a349) !important; color: #fff !important; border-color: var(--brand-dark, #367f39) !important; }
.embed-day-tab.is-today:not(.active) { border-color: var(--brand, #45a349); color: var(--brand-dark, #367f39); }

/* ── Embed event blocks and free-slot interaction (shared with seminar_list page) ── */
.embed-event {
    position: absolute;
    left: 1px;
    right: 1px;
    border-radius: 2px;
    padding: 1px 3px;
    font-size: 0.6rem;
    line-height: 1.2;
    overflow: hidden;
    z-index: 3;
}
.embed-event.booked    { background: #fee2e2; border-left: 3px solid #ef4444; }
.embed-event.recurring { background: #e0e7ff; border-left: 3px solid #6366f1; }
.embed-event.guest     { background: #f3e8ff; border-left: 3px solid #9333ea; }
.embed-event.pending   { background: #fef9c3; border-left: 3px solid #eab308; }
.embed-event:hover     { opacity: 0.85; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.embed-cell-free { cursor: pointer; }
.embed-cell-free:hover { background: rgba(59,130,246,0.08); }
.embed-cell-blocked { cursor: not-allowed !important; }
.embed-cell-blocked--maintenance { background: #fff7ed !important; }
.embed-cell-blocked--maintenance::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--status-maintenance-fill);
    z-index: 2;
}
.embed-cell-blocked--unavailable {
    background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 3px, #e2e8f0 3px, #e2e8f0 6px) !important;
}
.embed-cell-blocked--unavailable::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--status-unavailable-fill);
    z-index: 2;
}
.sem-cal-cell-blocked { cursor: not-allowed !important; }
.sem-cal-cell-blocked--maintenance { background: #fff7ed !important; }
.sem-cal-cell-blocked--maintenance::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--status-maintenance-fill);
    z-index: 2;
}
.sem-cal-cell-blocked--unavailable {
    background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 3px, #e2e8f0 3px, #e2e8f0 6px) !important;
}
.sem-cal-cell-blocked--unavailable::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--status-unavailable-fill);
    z-index: 2;
}
