/*
 * Sala del restaurante: el plano (SVG en centímetros, public/js/sala-plano.js), la sala en vivo y el
 * editor del plano. Los colores de las mesas dicen su estado y siempre van con su texto.
 */

/* ---- Estados: relleno (--f), borde y texto (--c) ---------------------------------------------- */
.st-libre { --f: #ffffff; --c: #15803d; }
.st-reservada { --f: #eaf2fe; --c: #1d4ed8; }
.st-llega { --f: #fef3c7; --c: #a16207; }
.st-ocupada { --f: #17152a; --c: #17152a; --t: #ffffff; }
.st-retraso { --f: #ffedd5; --c: #c2410c; }
.st-no-vino { --f: #fef2f2; --c: #b91c1c; }
.st-limpieza { --f: #ccfbf1; --c: #0f766e; }
.st-bloqueada { --f: #e5e7eb; --c: #4b5563; }

/* ---- El plano --------------------------------------------------------------------------------- */
.plano { display: block; width: 100%; height: auto; font-family: var(--display); user-select: none; -webkit-user-select: none; }
.pl-floor { fill: #ffffff; }
.pl-zone rect { stroke: none; }
.pl-zone-name { font-family: var(--mono); font-weight: 600; text-anchor: middle; fill: rgba(23, 21, 42, .45); pointer-events: none; }
.pl-wall { stroke: var(--ink); stroke-width: 12; stroke-linecap: square; }
.pl-gap { stroke: #ffffff; stroke-width: 14; }
.pl-door-leaf { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.pl-door-arc { fill: none; stroke: #9aa0aa; stroke-width: 2; stroke-dasharray: 6 6; }
.pl-glass { stroke: var(--accent); stroke-width: 5; }
.pl-item rect, .pl-item circle { stroke-width: 2; }
.pl-bar rect { fill: #2a2c33; stroke: #2a2c33; }
.pl-plant circle { fill: #dcebd5; stroke: #3f7d3a; }
.pl-column rect { fill: #9aa0aa; stroke: #6b7280; }
.pl-furniture rect { fill: #f4f5f7; stroke: #aeb3bc; }
.pl-item-name { font-weight: 600; text-anchor: middle; fill: var(--ink); pointer-events: none; }
.pl-bar .pl-item-name { fill: #ffffff; }
.pl-combo { stroke: var(--accent); stroke-width: 5; stroke-dasharray: 12 10; stroke-linecap: round; }

.tb { cursor: pointer; outline: none; }
.tb .ring { fill: transparent; stroke: none; }
.tb .chair { fill: #ffffff; stroke: #aeb3bc; stroke-width: 2; }
.tb .top { fill: var(--f, #ffffff); stroke: var(--c, var(--ink)); stroke-width: 4; }
.tb-name { font-weight: 700; text-anchor: middle; fill: var(--t, var(--ink)); pointer-events: none; }
.tb-tag { font-family: var(--mono); font-weight: 600; text-anchor: middle; fill: var(--t, var(--c, var(--ink))); pointer-events: none; }
.tb.st-ocupada .chair { fill: #2a2c33; stroke: #2a2c33; }
.tb.st-bloqueada .top { stroke-dasharray: 10 6; }
.tb:hover .ring { fill: var(--soft); }
.tb:focus-visible .ring { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 4; }
.tb.is-sel .ring { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 5; }
/* Arrastrar una reserva a otra mesa */
.tb.can-move { cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; }
.room.is-dragging, .room.is-dragging .tb { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.tb.is-drop .ring { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 6; stroke-dasharray: 14 8; }
.room-ghost { position: fixed; left: 0; top: 0; z-index: 90; padding: 6px 10px; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); font-size: .85rem; font-weight: 600; white-space: nowrap; pointer-events: none; }

/* ---- Sala en vivo ----------------------------------------------------------------------------- */
.room { background: var(--paper); }
.room-intro { max-width: 72ch; margin: 4px 0 18px; color: var(--ink-2); }
.room-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 2px 0 0; }
.room-clock { margin: 0 auto 0 0; font-family: var(--mono); font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.room-kpis { margin: 14px 0 20px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.room-kpis dd { font-size: 1.6rem; }
.room-main { display: grid; gap: 22px; }
.room-plan { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--paper); }
.room-plan .plano { max-height: 74vh; }
.room-plan.is-zoomed { max-height: 74vh; }
.room-plan.is-zoomed .plano { max-height: none; max-width: none; }
.room-zoom, .room-views { display: flex; gap: 4px; }
.room-views .btn[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.room-note { margin: 8px 0 0; font-size: .86rem; color: var(--muted); }
.room-zoom .btn[data-zoom="-1"], .room-zoom .btn[data-zoom="1"] { width: 34px; padding: 0; font-size: 1.1rem; }
.room-side { display: grid; gap: 22px; align-content: start; min-width: 0; }

.room-card { border-top: 2px solid var(--ink); padding-top: 12px; }
.room-card > p { margin: 4px 0 0; }
.room-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.room-card h2 { margin: 0; font-size: 1.35rem; }
.room-pill { display: inline-block; padding: 2px 10px; border: 1px solid var(--c); border-radius: 99px; background: var(--f); color: var(--t, var(--c)); font-size: .8rem; font-weight: 600; line-height: 1.45; white-space: nowrap; }
.room-facts { margin: 10px 0 0; }
.room-facts div { display: grid; grid-template-columns: 8.2em minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.room-facts dt { color: var(--muted); }
.room-facts dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.room-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.room-actions form { margin: 0; }
.room-form { margin: 14px 0 0; }
.room-form.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.inline-form label { flex: 1 1 130px; font-size: .86rem; }
.inline-form input { min-height: 40px; padding: 7px 10px; }
.inline-form input[type=number] { width: 6em; }
.inline-form select { min-height: 40px; padding: 7px 10px; }
.inline-form .btn { min-height: 40px; }
.room-move { margin: 14px 0 0; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); }
.room-move p { margin: 0 0 4px; }
.room-move .room-actions { margin-top: 10px; }
.room-warn { color: var(--bad); }
.room-hint { flex: 1 0 100%; margin: 0; font-size: .82rem; }

.room-tabs { display: flex; border-bottom: 1px solid var(--line); }
.room-tabs button { flex: 1 1 0; display: flex; justify-content: center; align-items: baseline; gap: 6px; padding: 9px 2px 8px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; }
.room-tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent-line); }
.room-tabs button:focus-visible { outline: 3px solid var(--accent-line); outline-offset: -3px; }
.room-tabs .count { font-family: var(--mono); font-size: .75rem; font-variant-numeric: tabular-nums; }
.room-list { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow: auto; }
.room-list li { display: grid; grid-template-columns: 3.3em minmax(0, 1fr) auto; gap: 4px 10px; align-items: baseline; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.room-list li.muted { display: block; padding: 12px 0; }
.room-list li[data-table] { cursor: pointer; }
.room-list li[data-table]:hover { background: var(--soft); }
.room-list li[data-table]:focus-visible { outline: 3px solid var(--accent-line); outline-offset: -3px; }
.room-list .mono { font-weight: 600; font-variant-numeric: tabular-nums; }
.room-badge { font-family: var(--mono); font-size: .76rem; font-weight: 600; color: var(--late); white-space: nowrap; }

.room-timeline { margin: 26px 0 0; }
.room-timeline > label { font-size: .86rem; }
.room-bars { display: flex; align-items: flex-end; gap: 2px; height: 46px; margin: 8px 0 0; padding: 0 9px; }
.room-bar { flex: 1 1 0; height: var(--h); min-height: 2px; background: var(--line-2); border-radius: 2px 2px 0 0; }
.room-bar.is-now { background: var(--accent); }
.room-timeline input[type=range] { display: block; width: 100%; min-height: 0; margin: 4px 0 0; padding: 0; border: 0; background: none; accent-color: var(--ink); }
.room-ends { display: flex; justify-content: space-between; margin: 2px 0 0; font-family: var(--mono); font-size: .75rem; color: var(--muted); }

.room-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 20px 0 0; padding: 0; font-size: .85rem; }
.room-legend li { display: flex; align-items: center; gap: 7px; }
.room-legend .sw { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--c); border-radius: 4px; background: var(--f); }
/* La mesa ocupada es negra, como en el plano: en modo oscuro se le marca el borde para que se vea. */
.room-legend .sw.st-ocupada { outline: 1px solid var(--line-3); }

/* Vista 3D (public/js/sala-3d.js): el lienzo ocupa la caja y los nombres de las mesas van encima. */
.room-plan.is-3d { position: relative; height: min(74vh, 680px); min-height: 340px; overflow: hidden; background: #f4f5f7; }
.room-3d { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
.room-3d:active { cursor: grabbing; }
.room-3d:focus-visible { outline: 3px solid var(--accent-line); outline-offset: -3px; }
.room-3d-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.room-3d-labels span { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; padding: 1px 7px 2px; border: 1.5px solid var(--c, var(--ink)); border-radius: 6px; background: var(--f, #ffffff); color: var(--t, var(--c, var(--ink))); font-family: var(--display); font-size: .8rem; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.room-3d-labels small { font-family: var(--mono); font-size: .68rem; font-weight: 600; }
.room-3d-labels span.is-sel { outline: 3px solid var(--accent-line); outline-offset: 1px; }

.room:fullscreen, .room.is-max { overflow: auto; padding: 16px 22px 22px; background: var(--paper); }
.room.is-max { position: fixed; inset: 0; z-index: 60; }
.room:fullscreen .room-plan:not(.is-zoomed) .plano, .room.is-max .room-plan:not(.is-zoomed) .plano { max-height: calc(100vh - 230px); }
.room:fullscreen .room-plan.is-zoomed, .room.is-max .room-plan.is-zoomed { max-height: calc(100vh - 230px); }
.room:fullscreen .room-plan.is-3d, .room.is-max .room-plan.is-3d { height: calc(100vh - 230px); max-height: none; }

@media (min-width: 980px) {
    .room-main { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
}
@media (max-width: 640px) {
    .room-plan .plano { max-height: none; }
    .room-plan.is-3d { height: 62vh; min-height: 300px; }
    .room-kpis dd { font-size: 1.35rem; }
}

/* ---- Editor del plano ------------------------------------------------------------------------- */
.plan-intro { max-width: 70ch; }
.plan-tabs { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 18px 0 0; border-bottom: 1px solid var(--line); }
.plan-tabs a { display: inline-flex; align-items: center; padding: 8px 0 7px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 600; text-decoration: none; }
.plan-tabs a:hover { color: var(--ink); }
.plan-tabs a.on { color: var(--ink); border-bottom-color: var(--accent-line); }
.plan-acts { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 16px; }
.plan-acts .box { flex: 1 1 320px; }
.plan-acts .acts.start { flex: 0 1 auto; }

.editor { margin-top: 8px; }
.ed-tools { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 10px 0; border-top: 2px solid var(--ink); }
.ed-group { display: flex; flex-wrap: wrap; gap: 4px; }
.ed-tools .btn[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.ed-status { min-height: 1.5em; margin: 0 0 10px; color: var(--muted); font-size: .92rem; }
.ed-main { display: grid; gap: 22px; }
.ed-canvas { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--paper); touch-action: none; }
.ed-canvas .plano { max-height: 70vh; }
.ed-canvas.is-zoomed { max-height: 70vh; }
.ed-canvas.is-zoomed .plano { max-height: none; }
.ed-canvas[data-tool=wall], .ed-canvas[data-tool=door], .ed-canvas[data-tool=window],
.ed-canvas[data-tool=bar], .ed-canvas[data-tool=plant], .ed-canvas[data-tool=column], .ed-canvas[data-tool=furniture] { cursor: crosshair; }
.ed-canvas[data-tool=move] .tb, .ed-canvas[data-tool=move] .pl-item, .ed-canvas[data-tool=move] .pl-opening, .ed-canvas[data-tool=move] .pl-wall { cursor: grab; }
.ed-canvas .pl-wall { stroke-linecap: round; }
.pl-wall.is-sel { stroke: var(--accent); }
.pl-opening.is-sel .pl-gap { stroke: var(--accent-soft); }
.pl-opening.is-sel .pl-door-leaf, .pl-opening.is-sel .pl-glass { stroke: var(--accent-ink); }
.pl-item.is-sel rect, .pl-item.is-sel circle { stroke: var(--accent); stroke-width: 6; }
.pl-zone.is-sel rect { stroke: var(--accent); stroke-width: 6; stroke-dasharray: 16 10; }
.plano.is-editing .tb.is-sel .ring { stroke-width: 6; }
.ed-handle { fill: #ffffff; stroke: var(--accent-ink); stroke-width: 4; cursor: nwse-resize; }
.ed-end { fill: var(--accent); }
.ed-start { fill: var(--accent-ink); }
.ed-preview { stroke: var(--accent); stroke-width: 12; stroke-dasharray: 18 12; stroke-linecap: round; }

.ed-side { display: grid; gap: 24px; align-content: start; min-width: 0; }
.ed-side h2 { margin: 0 0 6px; font-size: 1.1rem; }
.ed-side section { border-top: 1px solid var(--line); padding-top: 12px; }
.ed-side section.ed-props { border-top: 2px solid var(--ink); }
.ed-side p { margin: 0 0 8px; font-size: .92rem; }
.ed-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px 12px; align-items: end; margin: 8px 0 0; }
.ed-fields .wide { grid-column: 1 / -1; margin: 0; }
.ed-fields .btn { justify-self: start; }
.ed-fields label { font-size: .86rem; }
.ed-unit { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--muted); }
.ed-unit input { min-width: 0; }
.ed-fields input, .ed-fields select, .ed-size input { min-height: 40px; padding: 7px 10px; }
.ed-label { margin: 12px 0 6px; font-size: .86rem; font-weight: 600; }
.ed-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-color { width: 34px; height: 34px; border: 1px solid var(--line-2); border-radius: 50%; cursor: pointer; }
.ed-color[aria-pressed=true] { outline: 3px solid var(--ink); outline-offset: 2px; }
.ed-color:focus-visible { outline: 3px solid var(--accent-line); outline-offset: 2px; }
.ed-note { margin-top: 10px !important; }
.ed-new { margin-top: 10px; }
.ed-new .ed-fields { padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); }
.ed-error { color: var(--bad); font-weight: 600; }
.ed-list { list-style: none; margin: 0; padding: 0; }
.ed-list li { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.ed-list li.muted { display: block; }
.ed-list li > span:first-child { font-weight: 700; }
.ed-size { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-size label { font-size: .86rem; }
.ed-save { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; margin: 22px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); }
.ed-save label { flex: 0 1 320px; }
.ed-dirty { font-size: .86rem; font-weight: 700; color: var(--accent-ink); padding-bottom: 12px; }

@media (min-width: 980px) {
    .ed-main { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
}

