/* Plano de mesas (editor en Configuración y vista Sala en modo Plano) */

.brfp-loading, .brfp-empty { font-size: 12px; color: var(--text-muted); padding: 10px 0; }
.brfp-count { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--bg-base); border: 1px solid var(--border); font-size: 11px; color: var(--text-secondary); text-align: center; margin-left: 4px; font-weight: 500; }
.brfp-side-title { font-size: 12px; font-weight: 600; color: var(--text-main); margin: 0 0 6px; display: flex; align-items: center; }
.brfp-side-help { font-size: 11px; color: var(--text-muted); line-height: 1.45; margin: 8px 0 0; }

/* ───── Lienzo (común) ───── */
.brfp-canvas-wrap { width: 100%; }
.brfp-canvas { position: relative; width: 100%; padding-bottom: 60%; /* 40 × 24 */ background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; }
.brfp-canvas.brfp-grid { background-image: linear-gradient(to right, rgba(0,0,0,0.045) 1px, transparent 1px), linear-gradient(to bottom, rgba(0,0,0,0.045) 1px, transparent 1px); background-size: 2.5% 4.1667%; }
.brfp-canvas.brfp-drop-ok { box-shadow: inset 0 0 0 2px var(--primary); }
.brfp-canvas-inner { position: absolute; inset: 0; }
.brfp-table { position: absolute; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1.5px solid var(--border-hover); border-radius: 8px; background: #fff; color: var(--text-main); font-size: 12px; line-height: 1.2; padding: 2px 4px; overflow: hidden; cursor: pointer; touch-action: none; }
.brfp-table.round { border-radius: 50%; }
.brfp-tname { font-weight: 600; font-size: 1.08em; }
.brfp-tcap { font-size: .92em; color: var(--text-muted); }
.brfp-canvas-help { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ───── Editor ───── */
.brfp-editor { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.brfp-side { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-base); padding: 12px; }
.brfp-unplaced { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow: auto; }
.brfp-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 9px; border: 1px solid var(--border-hover); border-radius: 8px; background: #fff; font-size: 12px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.brfp-chip-name { font-weight: 600; }
.brfp-chip-cap { color: var(--text-muted); font-size: 11px; }
.brfp-chip-del { border: 0; background: transparent; color: var(--text-muted); font-size: 15px; line-height: 1; padding: 0 2px; cursor: pointer; }
.brfp-chip-del:hover { color: var(--red-text); }
.brfp-add { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.brfp-add-row { display: flex; gap: 6px; margin-bottom: 6px; }
.brfp-add-row input, .brfp-add-row select { min-width: 0; font-size: 12px; padding: 6px 8px; border: 1px solid var(--border-hover); border-radius: 6px; background: #fff; }
.brfp-add-name { flex: 1; }
.brfp-add-cap { width: 64px; }
.brfp-add-shape { flex: 1; }
.brfp-add small { font-size: 11px; color: var(--text-muted); }
.brfp-main { min-width: 0; }
.brfp-zones { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 8px; }
.brfp-zone { border: 1px solid transparent; background: transparent; padding: 6px 10px; border-radius: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.brfp-zone:hover { background: var(--bg-base); }
.brfp-zone.active { background: #fff; border-color: var(--border-hover); color: var(--text-main); font-weight: 600; }
.brfp-zone-n { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.brfp-zone-add { border: 1px dashed var(--border-hover); background: transparent; padding: 5px 9px; border-radius: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.brfp-zone-tools { margin-left: auto; display: inline-flex; gap: 4px; }
.brfp-zone-tools button { border: 0; background: transparent; font-size: 11px; color: var(--text-muted); cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.brfp-zone-tools button:hover { background: var(--bg-base); color: var(--text-main); }
.brfp-zone-del:hover { color: var(--red-text) !important; }
.brfp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 34px; margin-bottom: 8px; font-size: 12px; }
.brfp-toolbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.brfp-toolbar input, .brfp-toolbar select { font-size: 12px; padding: 5px 8px; border: 1px solid var(--border-hover); border-radius: 6px; height: 30px; background: #fff; }
.brfp-tb-name { width: 90px; }
.brfp-tb-cap { width: 64px; }
.brfp-tb-name.is-invalid { border-color: var(--red); }
.brfp-tb-hint { color: var(--text-muted); }
.brfp-table.brfp-edit { cursor: grab; }
.brfp-table.brfp-edit.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); z-index: 2; }
.brfp-table.brfp-out { opacity: 0.4; border-style: dashed; }
.brfp-resize { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 55%, var(--border-hover) 55%, var(--border-hover) 70%, transparent 70%, transparent 80%, var(--border-hover) 80%); display: none; }
.brfp-table.brfp-edit.selected .brfp-resize { display: block; }
.brfp-table.round .brfp-resize { right: 12%; bottom: 12%; }
.brfp-ghost { position: fixed; z-index: 10000; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--text-main); color: #fff; font-size: 12px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

/* ───── Sala en modo Plano ───── */
.brfp-sala-empty { padding: 40px 20px; text-align: center; color: var(--text-secondary); font-size: 13px; }
.brfp-sala-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.brfp-zones-sala { margin-bottom: 0; }
.brfp-times { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; }
.brfp-times-scroll { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding: 2px; }
.brfp-times-scroll::-webkit-scrollbar { display: none; }
.brfp-time { flex: 0 0 auto; border: 1px solid var(--border); background: #fff; padding: 5px 9px; border-radius: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; font-variant-numeric: tabular-nums; }
.brfp-time.now { border-color: var(--primary); color: var(--blue-text); }
.brfp-time.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.brfp-time-nav { border: 1px solid var(--border); background: #fff; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; color: var(--text-secondary); flex: 0 0 auto; }
.brfp-sala-body { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 16px; align-items: start; }
.brfp-canvas-sala { background: var(--bg-base); }
.brfp-sala-stats { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.brfp-sala-side { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-base); padding: 12px; }
.brfp-res { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 7px 8px; margin-bottom: 4px; border: 1px solid var(--border-hover); border-radius: 8px; background: #fff; font-size: 12px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.brfp-res.at-time { border-color: var(--primary); }
.brfp-res.orphan { border-style: dashed; }
.brfp-res-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.brfp-res-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brfp-res-pax { color: var(--text-muted); font-size: 11px; white-space: nowrap; }

.brfp-table.brfp-live { cursor: pointer; }
.brfp-table.brfp-live.free { background: #fff; border-style: dashed; }
.brfp-table.brfp-live.free:hover { border-color: var(--green); }
.brfp-table.brfp-live.booked { background: linear-gradient(rgba(99,102,241,0.12), rgba(99,102,241,0.12)), #fff; border-color: rgba(99,102,241,0.5); color: #3730a3; }
.brfp-table.brfp-live.pending { background: linear-gradient(rgba(245,158,11,0.12), rgba(245,158,11,0.12)), #fff; border-color: rgba(245,158,11,0.5); color: #92400e; }
.brfp-table.brfp-live.seated { background: linear-gradient(rgba(16,185,129,0.14), rgba(16,185,129,0.14)), #fff; border-color: rgba(16,185,129,0.55); color: #065f46; }
.brfp-table.brfp-live .brfp-tname { font-size: 1em; }
.brfp-tguest { font-weight: 600; font-size: 1em; max-width: 100%; white-space: normal; line-height: 1.15; }
.brfp-tmeta { font-size: .92em; }
.brfp-tnext { font-size: .84em; color: var(--text-muted); max-width: 100%; white-space: normal; line-height: 1.15; }
/* Último recurso del ajuste de texto (fitTableText): partir palabras */
.brfp-table.brfp-break .brfp-tguest, .brfp-table.brfp-break .brfp-tnext { overflow-wrap: anywhere; }
.brfp-flags { position: absolute; top: 3px; right: 4px; display: flex; gap: 2px; }
.brfp-flag { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; font-size: 10px; font-weight: 700; }
.brfp-flag.allergy { background: var(--red); color: #fff; }
.brfp-flag.vip { background: #f59e0b; color: #fff; }
.brfp-over { color: var(--red-text); }
.brfp-more { position: absolute; left: 4px; top: 3px; font-size: 10px; background: var(--text-main); color: #fff; border-radius: 8px; padding: 0 5px; }
.brfp-sala.brfp-dragging .brfp-table.brfp-live { outline: 1px dashed var(--border-hover); }
.brfp-sala .brfp-drop-hover { box-shadow: 0 0 0 3px var(--primary) !important; }
.brfp-sala-side.brfp-drop-hover { box-shadow: 0 0 0 2px var(--primary); }

@keyframes brfpFlash { 0% { box-shadow: 0 0 0 4px var(--primary); } 100% { box-shadow: 0 0 0 0 transparent; } }
.brfp-flash { animation: brfpFlash .9s ease-out; }

/* Sala: interruptor Plano / Lista */
.brfp-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.brfp-switch button { border: 0; background: #fff; padding: 5px 10px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.brfp-switch button.active { background: var(--text-main); color: #fff; }

@media (max-width: 900px) {
    .brfp-editor { grid-template-columns: 1fr; }
    .brfp-unplaced { max-height: 140px; }
    .brfp-sala-body { grid-template-columns: 1fr; }
    .brfp-sala-side { order: -1; }
    .brfp-sala-side .brfp-res { display: inline-grid; margin-right: 4px; }
    .brfp-table { padding: 1px 2px; }
}

/* El panel resetea el fondo de todos los botones en :hover (y en tableta el hover se queda tras tocar):
   estados explícitos con más especificidad */
body .bookings-backoffice .brfp-time:hover { background-color: var(--bg-base); color: var(--text-main); }
body .bookings-backoffice .brfp-time.active, body .bookings-backoffice .brfp-time.active:hover { background-color: var(--primary); color: #fff; }
body .bookings-backoffice .brfp-time-nav:hover { background-color: var(--bg-base); color: var(--text-main); }
body .bookings-backoffice .brfp-zone:hover { background-color: var(--bg-base); color: var(--text-main); }
body .bookings-backoffice .brfp-zone.active, body .bookings-backoffice .brfp-zone.active:hover { background-color: #fff; color: var(--text-main); }
body .bookings-backoffice .brfp-switch button:hover { background-color: var(--bg-base); color: var(--text-main); }
body .bookings-backoffice .brfp-switch button.active, body .bookings-backoffice .brfp-switch button.active:hover { background-color: var(--text-main); color: #fff; }
body .bookings-backoffice .brfp-zone-add:hover, body .bookings-backoffice .brfp-zone-tools button:hover { background-color: var(--bg-base); color: var(--text-main); }
body .bookings-backoffice .brfp-chip-del:hover { background-color: transparent; color: var(--red-text); }

/* Editor: posición no válida (se solapa con otra mesa) */
.brfp-table.brfp-collide { border-color: var(--red) !important; background: var(--red-bg) !important; }

/* Lista de mesas (roles sin acceso al plano) */
.brfp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; margin-bottom: 12px; }
.brfp-list-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--border-hover); border-radius: 8px; background: #fff; }
.brfp-list-row input { min-width: 0; font-size: 12px; padding: 5px 8px; border: 1px solid var(--border-hover); border-radius: 6px; height: 30px; }
.brfp-l-name { flex: 1; font-weight: 600; }
.brfp-l-name.is-invalid { border-color: var(--red); }
.brfp-l-cap { width: 60px; }
.brfp-l-unit { font-size: 11px; color: var(--text-muted); }
.brfp-add-inline { margin-top: 0; padding-top: 0; border-top: 0; max-width: 420px; }

/* Sala: zona sin mesas colocadas */
.brfp-zone-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center; font-size: 13px; color: var(--text-secondary); }

/* Sala: reservas en cada zona a la hora elegida (mismo color que una mesa reservada; #3730a3 sobre su fondo > 7:1) */
.brfp-zone-busy { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: rgba(99,102,241,0.14); color: #3730a3; font-size: 11px; font-weight: 600; text-align: center; line-height: 18px; }

/* Horas con reservas asignadas: punto discreto bajo la hora */
.brfp-time { position: relative; }
.brfp-time.has-res::after { content: ''; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--blue-text); opacity: .55; }
.brfp-time.has-res.active::after { background: #fff; opacity: .9; }

/* Interruptor Plano / Lista dentro de la banda de filtros: misma altura que los demás controles */
.bookings-filter .brfp-switch { height: 36px; border-radius: 8px; }
.bookings-filter .brfp-switch button { padding: 0 14px; font-size: 13px; }

/* Más comensales que plazas en la mesa */
.brfp-table.brfp-live.over { border: 2px solid var(--red); }

/* ───── Juntar mesas ───── */
.brfp-canvas-col { min-width: 0; }
.brfp-joinbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 8px; padding: 8px 10px 8px 12px; border: 1px solid rgba(239,68,68,0.35); background: var(--red-bg); border-radius: 8px; font-size: 13px; color: var(--text-main); }
.brfp-joinbar.picking { border-color: rgba(99,102,241,0.45); background: var(--blue-bg); }
.brfp-jb-txt { flex: 1 1 260px; }
.brfp-jb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.brfp-jb-lbl { color: var(--text-secondary); font-size: 12px; }
.brfp-jb-cap { color: var(--text-muted); font-weight: 400; margin-left: 2px; }
.brfp-jb-x { border: 0; background: transparent; font-size: 18px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 2px 4px; }
body .bookings-backoffice .brfp-jb-x:hover { background: transparent; color: var(--text-main); }
/* Línea que une las mesas juntas (mismo color que el estado de la reserva) */
.brfp-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.brfp-links line { stroke-width: 4; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.brfp-links line.booked { stroke: rgba(99,102,241,0.55); }
.brfp-links line.pending { stroke: rgba(245,158,11,0.6); }
.brfp-links line.seated { stroke: rgba(16,185,129,0.6); }
.brfp-table.brfp-live { z-index: 1; }
.brfp-tjoin { font-size: .84em; opacity: .9; }
/* Eligiendo mesas */
.brfp-table.pick-sel { box-shadow: 0 0 0 3px var(--primary); }
.brfp-table.pick-busy { opacity: .45; }

/* ───── Asignación automática ───── */
.brfp-auto { display: inline-block; vertical-align: 1px; width: 1.25em; height: 1.25em; border-radius: 50%; background: rgba(0,0,0,0.08); color: var(--text-secondary); font-size: .72em; font-weight: 700; line-height: 1.25em; text-align: center; }
.brfp-table.preview { outline: 2px dashed var(--primary); outline-offset: 2px; }
.brfp-sala-bar .brfp-assign { flex: 0 0 auto; }
.brfp-res { grid-template-columns: 42px minmax(0, 1fr) auto; }
.brfp-res-pref { grid-column: 2 / -1; font-size: 11px; color: var(--text-secondary); }
.brfp-tb-feat { width: 200px; }
/* Preferencia de mesa en la ficha */
.tld-pref-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.tld-pref-form select { font-size: 13px; padding: 4px 8px; border: 1px solid var(--border-hover); border-radius: 6px; }
.tld-pref-chk { display: inline-flex; align-items: center; gap: 4px; }
.tld-pref-btns { display: inline-flex; gap: 6px; }
