/* ============================================================
   Housekeeping Board — standalone, plain-HTTP page.
   No Bootstrap dependency for layout; self-contained design.
   ============================================================ */

:root {
    --bg: #0f172a;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .06);
    --radius: 14px;

    /* status colors */
    --st-ready: #16a34a;
    --st-occ-clean: #0d9488;
    --st-occ-dirty: #2563eb;
    --st-vac-dirty: #e11d48;
    --st-ooo: #334155;
    --st-vac-clean: #94a3b8;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--surface-2);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- header ---------- */
.bd-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 22px;
    background: var(--bg);
    color: #fff;
    box-shadow: var(--shadow);
}

.bd-title { display: flex; align-items: baseline; gap: 14px; }
.bd-title h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: .2px; }
.bd-date { color: #cbd5e1; font-size: 14px; font-variant-numeric: tabular-nums; }

.bd-header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.bd-conn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: #cbd5e1;
    background: rgba(255, 255, 255, .08);
    padding: 6px 11px;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
}
.bd-conn .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.bd-conn.is-refreshing .dot { background: #facc15; animation: bd-pulse 1s infinite; }
@keyframes bd-pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.bd-user {
    display: inline-flex; align-items: center; gap: 7px;
    background: rgba(255, 255, 255, .12);
    padding: 6px 13px; border-radius: 999px;
    font-weight: 600; cursor: pointer;
}
.bd-user::before { content: "👤"; font-size: 13px; }

.bd-culture {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
}
.bd-culture option { color: #000; }

/* ---------- body ---------- */
.bd-body { flex: 1; padding: 20px 22px 8px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* ---------- summary stats ---------- */
.bd-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.bd-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--c, var(--muted));
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow);
}
.bd-stat .num { font-size: 26px; font-weight: 750; line-height: 1; color: var(--c, var(--text)); }
.bd-stat .label { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- toolbar ---------- */
.bd-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- by room type ---------- */
.bd-section-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 0 0 8px; font-weight: 700; }
.bd-bytype { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.bd-type {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 3px; min-width: 160px;
}
.bd-type-name { font-weight: 700; font-size: 14px; }
.bd-type-c { font-size: 13px; color: var(--muted); }
.bd-type-c .ready { color: var(--st-ready); font-size: 15px; }
.bd-type-c .dirty { color: var(--st-vac-dirty); font-size: 15px; }
.bd-type-c .muted { opacity: .8; }

/* ---------- status pill (priority list) ---------- */
.bd-pill { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; }
.bd-pill[data-status="vac-dirty"] { background: var(--st-vac-dirty); }
.bd-pill[data-status="occ-dirty"] { background: var(--st-occ-dirty); }

/* ---------- occupancy panel ---------- */
.bd-occupancy {
    display: flex; flex-wrap: wrap; gap: 10px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.bd-occupancy .occ { font-size: 14px; }
.bd-occupancy .occ b { font-size: 16px; }
.bd-occupancy .occ .sub { color: var(--muted); font-size: 13px; }
.bd-occupancy a { color: var(--st-occ-dirty); font-weight: 600; text-decoration: none; }
.bd-occupancy a:hover { text-decoration: underline; }

/* ---------- floors ---------- */
.bd-floor { margin-bottom: 24px; }
.bd-floor-head {
    display: flex; align-items: center; gap: 14px;
    margin: 0 0 12px;
}
.bd-floor-head h2 { font-size: 16px; font-weight: 700; margin: 0; }
.bd-floor-head .counts { color: var(--muted); font-size: 13px; }

.bd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}

/* ---------- room tile ---------- */
.bd-room {
    position: relative;
    text-align: left;
    border: none;
    border-radius: var(--radius);
    padding: 12px 14px 14px;
    min-height: 118px;
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .08s ease, box-shadow .12s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: inherit;
}
.bd-room:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15, 23, 42, .18); }
.bd-room:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.bd-room[data-readonly="1"] { cursor: default; }
.bd-room[data-readonly="1"]:hover { transform: none; box-shadow: var(--shadow); }

.bd-room[data-status="ready"]       { background: var(--st-ready); }
.bd-room[data-status="occ-clean"]   { background: var(--st-occ-clean); }
.bd-room[data-status="occ-dirty"]   { background: var(--st-occ-dirty); }
.bd-room[data-status="vac-dirty"]   { background: var(--st-vac-dirty); }
.bd-room[data-status="ooo"]         { background: var(--st-ooo); }
.bd-room[data-status="vac-clean"]   { background: var(--st-vac-clean); color: #0f172a; }

.bd-room-top { display: flex; align-items: center; justify-content: space-between; }
.bd-room-no { font-size: 22px; font-weight: 800; line-height: 1; }
.bd-room-name { font-size: 12px; opacity: .85; margin-left: 6px; font-weight: 500; }

.bd-badge {
    align-self: flex-start;
    background: rgba(255, 255, 255, .22);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 11.5px;
    font-weight: 600;
    backdrop-filter: blur(2px);
}
.bd-room[data-status="vac-clean"] .bd-badge { background: rgba(15, 23, 42, .12); }

.bd-room-meta { margin-top: auto; font-size: 12px; line-height: 1.5; opacity: .92; }
.bd-room-meta .res { font-weight: 600; }
.bd-room-meta .dates { font-variant-numeric: tabular-nums; }
.bd-room-meta .car, .bd-room-meta .note { display: block; }
.bd-room-meta .note { font-style: italic; }

.bd-busy {
    position: absolute; top: 12px; right: 12px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #f8717155; box-shadow: 0 0 0 3px rgba(255,255,255,.25);
}
.bd-busy.on { background: #fb7185; }

/* ---------- login ---------- */
.bd-login {
    margin: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    width: min(360px, 92vw);
    text-align: center;
}
.bd-login h2 { margin: 0 0 6px; font-size: 18px; }
.bd-login p { color: var(--muted); margin: 0 0 18px; font-size: 13.5px; }
.bd-login input {
    width: 100%; padding: 11px 13px; font-size: 15px;
    border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px;
}
.bd-login input:focus { outline: none; border-color: var(--st-occ-dirty); }

/* ---------- buttons ---------- */
.bd-btn {
    border: none; border-radius: 10px; padding: 10px 16px;
    font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
    background: var(--surface-2); color: var(--text);
}
.bd-btn:hover { filter: brightness(.97); }
.bd-btn-primary { background: var(--st-occ-dirty); color: #fff; width: 100%; }
.bd-btn-clean { background: var(--st-ready); color: #fff; }
.bd-btn-dirty { background: var(--st-vac-dirty); color: #fff; }
.bd-btn-ghost { background: transparent; border: 1px solid var(--border); }

/* ---------- modal ---------- */
.bd-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15, 23, 42, .55);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 40px 16px; overflow: auto;
}
.bd-modal {
    background: var(--surface);
    border-radius: 18px;
    width: min(460px, 96vw);
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
    overflow: hidden;
}
.bd-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; color: #fff;
}
.bd-modal-head h3 { margin: 0; font-size: 17px; }
.bd-modal-head .x { background: rgba(255,255,255,.2); border: none; color: #fff; width: 30px; height: 30px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.bd-modal-body { padding: 18px 20px 22px; }
.bd-info { font-size: 14px; line-height: 1.7; margin-bottom: 14px; }
.bd-info .k { color: var(--muted); }
.bd-info b { font-weight: 650; }

.bd-field { margin-bottom: 14px; }
.bd-field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.bd-field input, .bd-field textarea {
    width: 100%; padding: 9px 12px; font-size: 14px;
    border: 1px solid var(--border); border-radius: 9px; font-family: inherit;
}
.bd-field input:disabled, .bd-field textarea:disabled { background: var(--surface-2); color: var(--muted); }
.bd-busy-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.bd-busy-pill { padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.bd-busy-pill.yes { background: #dbeafe; color: #1d4ed8; }
.bd-busy-pill.no { background: #fee2e2; color: #b91c1c; }
.bd-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- car report ---------- */
.bd-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.bd-table th, .bd-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.bd-table th { background: var(--surface-2); color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- toast ---------- */
.bd-toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 999px;
    font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 200;
}

/* ---------- empty / waiting ---------- */
.bd-empty { margin: auto; text-align: center; color: var(--muted); padding: 60px 20px; }
.bd-empty .spin { width: 36px; height: 36px; border: 4px solid var(--border); border-top-color: var(--st-occ-dirty); border-radius: 50%; margin: 0 auto 16px; animation: bd-spin 1s linear infinite; }
@keyframes bd-spin { to { transform: rotate(360deg); } }

/* ---------- footer ---------- */
.bd-footer {
    padding: 16px 22px;
    color: var(--muted);
    font-size: 12.5px;
    text-align: center;
    border-top: 1px solid var(--border);
}

/* ---------- rtl ---------- */
[dir="rtl"] .bd-room { text-align: right; }
[dir="rtl"] .bd-busy { right: auto; left: 12px; }
[dir="rtl"] .bd-table th, [dir="rtl"] .bd-table td { text-align: right; }

/* ---------- print: only the car report area ---------- */
@media print {
    body * { visibility: hidden; }
    .bd-print-area, .bd-print-area * { visibility: visible; }
    .bd-print-area { position: absolute; top: 0; left: 0; width: 100%; padding: 0; }
    .bd-noprint { display: none !important; }
    .bd-table { box-shadow: none; }
    .bd-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- responsive / mobile ---------- */
@media (max-width: 860px) {
    body { font-size: 14px; }
    .bd-body { padding: 14px 14px 6px; }
    .bd-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .bd-stat { padding: 10px 12px; border-radius: 10px; }
    .bd-stat .num { font-size: 21px; }
    .bd-stat .label { font-size: 10.5px; }
    .bd-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}

@media (max-width: 560px) {
    .bd-header { padding: 10px 14px; gap: 10px; }
    .bd-title { flex-direction: column; gap: 2px; }
    .bd-title h1 { font-size: 17px; }
    .bd-header-right { gap: 8px; }
    /* two columns of rooms on phones, larger touch targets */
    .bd-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
    .bd-room { min-height: 104px; padding: 10px 11px 12px; }
    .bd-room-no { font-size: 19px; }
    .bd-stats { grid-template-columns: repeat(2, 1fr); }
    .bd-occupancy { gap: 8px 18px; padding: 12px 14px; }
    .bd-backdrop { padding: 14px 10px; }
    .bd-modal { width: 100%; border-radius: 14px; }
    .bd-actions .bd-btn { flex: 1; }
}

@media (max-width: 380px) {
    .bd-grid { grid-template-columns: 1fr; }
    .bd-stats { grid-template-columns: repeat(2, 1fr); }
}

/* coarse-pointer (touch) — bigger tap targets, no hover lift */
@media (hover: none) {
    .bd-room:hover { transform: none; box-shadow: var(--shadow); }
    .bd-btn { padding: 12px 16px; }
}
