/* =====================================================================
   Seat My Guest — stylesheet
   Layered top-to-bottom so cascade order alone resolves precedence:
     tokens → reset → layout → components → states → animations → utils
   ===================================================================== */

/* --- tokens ---------------------------------------------------------- */
:root {
  /* Geometry */
  --seat-size: 30px; /* read by table-calculation.js */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-pill: 999px;

  /* Surfaces */
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-muted: #f5f5f5;
  --bg-elevated: #f8f9fa;
  --bg-grid: #f8f8f8;
  --border: #e0e0e0;
  --border-strong: #d1d5db;

  /* Text */
  --text: #333;
  --text-muted: #666;
  --text-subtle: #999;

  /* Brand & semantic colors */
  --primary: #00b8b8;
  --primary-hover: #009999;
  --primary-soft: #e6f9f9;

  --success: #4caf50;
  --success-hover: #43a047;
  --success-soft: #e8f5e9;
  --success-text: #155724;

  --warning: #ff9800;
  --warning-soft: #fff3cd;
  --warning-text: #856404;

  --danger: #f44336;
  --danger-hover: #c82333;
  --danger-soft: #ffebee;
  --danger-text: #d32f2f;

  --info: #3b82f6;
  --info-hover: #2563eb;

  --secondary: #999999;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 6px 18px rgba(0, 0, 0, 0.18);
  --ring-success: 0 0 0 2px rgba(76, 175, 80, 0.3);
  --ring-warning: 0 0 0 2px rgba(255, 152, 0, 0.3);
  --ring-danger: 0 0 0 2px rgba(244, 67, 54, 0.3);
  --ring-info: 0 0 0 2px rgba(59, 130, 246, 0.25);

  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Z-scale */
  --z-overlay: 1000;
  --z-toast: 10000;
  --z-tag: 12000;
  --z-review: 13000;
}

/* --- reset ----------------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Shared scrollbar treatment (sidebar + rules list) */
.sidebar,
#existingSeatingRules {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 transparent;
}

.sidebar::-webkit-scrollbar,
#existingSeatingRules::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track,
#existingSeatingRules::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
#existingSeatingRules::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: var(--radius-sm);
}

.sidebar::-webkit-scrollbar-thumb:hover,
#existingSeatingRules::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* --- layout ---------------------------------------------------------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

.header-left {
  min-width: 100px;
  flex-shrink: 0;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-grow: 1;
  justify-content: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge.status-unsaved {
  background: #fff3cd;
  color: #856404;
}

.status-badge.status-saving {
  background: #fff3cd;
  color: #856404;
}

.status-badge.status-saving .dot {
  animation: pulse 1s infinite;
}

.status-badge.status-saved {
  background: #d4edda;
  color: #155724;
}

.status-badge.status-error {
  background: #fde8ea;
  color: #b00020;
}

.state-id {
  font-size: 11px;
  opacity: 0.8;
  margin-left: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

.icon-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border: 0.5px solid #e0e0e0;
  background: transparent;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #999;
  font-size: 16px;
  transition: all 0.2s;
}

.icon-btn:hover:not(:disabled) {
  background: white;
  color: #333;
  border-color: #ddd;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn.danger {
  color: #d32f2f;
}

.divider {
  width: 0.5px;
  height: 20px;
  background: #e0e0e0;
}

/* ── view-tabs wrapper (kept for JS compatibility) ─────────────────── */
.view-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Project controls (header right side) ──────────────────────────── */

.project-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.state-badge.state-unsaved {
  background: #fff3cd;
  color: #856404;
}

.state-badge.state-saved {
  background: #d4edda;
  color: #155724;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

.state-id {
  font-size: 11px;
  opacity: 0.8;
  margin-left: 4px;
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.view-tab {
  padding: 8px 24px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-muted);
  transition: all var(--transition);
}

.view-tab:hover {
  background: var(--bg-muted);
}

.view-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.main-container {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tables-area {
  flex: 1;
  background: var(--bg-grid);
  padding: 30px;
  overflow: auto;
  position: relative;
  height: 100%;
}

#tablesArea {
  position: relative;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
}

.tables-area.view-chart .tables-list-view {
  display: none;
}

.tables-area.view-list #tablesArea {
  display: none;
}

.tables-list-view {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 8px 40px;
}

.seating-list-empty {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.seating-list-table {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.seating-list-table:last-of-type {
  border-bottom: none;
}

.seating-list-table-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 12px;
  padding: 4px 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  border-radius: 0;
  cursor: pointer;
  user-select: none;
  appearance: none;
  -webkit-appearance: none;
}

.seating-list-table-toggle:focus {
  outline: none;
}

.seating-list-table-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.seating-list-table-toggle .collapse-arrow {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.seating-list-table-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  transition: color var(--transition);
}

.seating-list-table-body {
  transition: opacity var(--transition-slow);
}

.seating-list-table-body.collapsed {
  display: none;
}

.seating-list-description {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.45;
}

.seating-list-seats {
  margin: 0;
  padding-left: 1.35rem;
  font-size: 14px;
  line-height: 1.65;
}

.seating-list-seats li {
  padding-left: 4px;
}

.seating-list-seat-empty {
  color: var(--text-subtle);
  min-height: 1em;
}

.canvas-toolbar {
  position: sticky;
  top: 0px;
  height: 0;
  overflow: visible;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-right: 16px;
  z-index: 10;
  pointer-events: none;
}

.canvas-toolbar > * {
  pointer-events: all;
}

.floating-btn {
  width: 44px;
  height: 44px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}

.floating-btn:hover:not(:disabled) {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.undo-btn:hover:not(:disabled) {
  background: #ff9800;
  border-color: #ff9800;
}

.redo-btn:hover:not(:disabled) {
  background: var(--success);
  border-color: var(--success);
}

.floating-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- buttons --------------------------------------------------------- */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: var(--bg);
  flex: 1;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text-muted);
  flex: 1;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: var(--bg);
  flex: 1;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

/* Compact action buttons (rule list, group list, etc.) */
.btn-small,
.action-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.btn-small.btn-danger {
  background: var(--danger);
  color: var(--bg);
}

.btn-small.btn-danger:hover {
  background: var(--danger-hover);
}

.action-btn-edit {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid #ddd;
}

.action-btn-edit:hover {
  background: #e9ecef;
  border-color: #999;
}

.btn-icon {
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-muted);
  border-color: #bbb;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn-icon:active {
  transform: translateY(0);
}

.print-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 12px 24px;
  background: var(--bg);
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition);
  z-index: 50;
}

.print-btn:hover {
  background: var(--primary);
  color: var(--bg);
  transform: translateY(-2px);
}

/* --- forms ----------------------------------------------------------- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.form-input,
.number-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.form-input:focus,
.number-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-input:disabled {
  background: var(--bg-muted);
  cursor: not-allowed;
}

.search-box {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 10px;
  font-size: 14px;
}

/* --- modals ---------------------------------------------------------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: var(--z-overlay);
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  position: sticky;
  top: -24px;
  background: var(--bg);
  z-index: 10;
  padding: 24px 0 10px;
}

.modal-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
  transition: background var(--transition);
}

.close-btn:hover {
  background: var(--border);
}

/* --- table picker (sidebar) ----------------------------------------- */
.table-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}

.table-option {
  padding: 12px 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}

.table-option:hover {
  border-color: var(--primary);
  background: #f0fffe;
}

.table-option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.table-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.table-label {
  font-size: 10px;
  color: var(--text-muted);
}

.table-config {
  display: none;
  padding: 10px;
  background: #f0f0f0;
  border-radius: var(--radius-md);
  margin: 10px 0 15px;
}

.table-config.show {
  display: block;
}

.config-option {
  margin-bottom: 10px;
}

.config-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.config-buttons {
  display: flex;
  gap: 5px;
}

.config-btn {
  flex: 1;
  padding: 6px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.config-btn:hover {
  background: var(--bg-muted);
}

.config-btn.active {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
}

.row-col-input {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.row-col-input input {
  flex: 1;
}

/* --- table on canvas ------------------------------------------------- */
.table-wrapper {
  position: absolute;
  cursor: move;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  box-sizing: border-box;
  overflow: visible;
  transform-origin: center center;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.table-wrapper:hover {
  border-color: var(--primary);
  z-index: 100;
}

.table-wrapper.selected {
  border-color: #007bff;
  box-shadow: var(--ring-info);
}

.table-wrapper.dragging,
.table-wrapper.dragging-table {
  opacity: 0.7;
  z-index: 1000;
  border-color: var(--primary);
}

.table-wrapper.drop-target {
  border-style: dashed;
  border-color: var(--success);
}

.table {
  position: relative;
  width: 100%;
  height: 100%;
}

.table-controls {
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 10;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity var(--transition);
}

.table-wrapper:hover .table-controls {
  opacity: 1;
}

.control-btn {
  width: 28px;
  height: 28px;
  background: var(--bg);
  border: 1px solid #ddd;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
}

.control-btn:hover {
  background: var(--bg-muted);
  border-color: #999;
}

.control-btn.delete {
  background: var(--danger);
  color: var(--bg);
  border-color: var(--danger);
}

.control-btn.delete:hover {
  background: var(--danger-hover);
}

/* Table center: round / rect / U-shape / theater */
.table-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  border: 2px solid #ddd;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
  transition: all var(--transition);
}

.table-center.round {
  border-radius: 50%;
}

.table-center.rect {
  border: none;
  box-shadow: inset 0 0 0 2px #ddd;
}

.table-center.u-shape {
  --u-thickness: 60px;
  clip-path: polygon(
    0% 0%,
    var(--u-thickness) 0%,
    var(--u-thickness) calc(100% - var(--u-thickness)),
    calc(100% - var(--u-thickness)) calc(100% - var(--u-thickness)),
    calc(100% - var(--u-thickness)) 0%,
    100% 0%,
    100% 100%,
    0% 100%
  );
}

.table-center.u-shape .table-name,
.table-center.u-shape .table-count {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
}

.table-center.u-shape .table-name {
  bottom: calc(var(--u-thickness) / 2);
}

.table-center.u-shape .table-count {
  bottom: calc(var(--u-thickness) / 4);
  font-size: 12px;
  color: var(--text-muted);
}

.table-center.theater {
  display: none;
}

.table-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}

.table-count {
  font-size: 12px;
  color: var(--text-muted);
}

.theater-label {
  text-align: center;
}

.theater-label .table-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.rotatable-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.seat .rotatable-content {
  pointer-events: none;
  font-size: 11px;
}

/* --- seats ----------------------------------------------------------- */
.seat {
  position: absolute;
  width: var(--seat-size);
  height: var(--seat-size);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  text-align: center;
  padding: 3px;
  overflow: hidden;
  box-sizing: border-box;
  transition: all var(--transition);
}

.seat:hover {
  border-color: var(--primary);
  transform: scale(1.1);
  z-index: 10;
}

.seat.occupied {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary-hover);
}

.seat.dragging {
  opacity: 0.5;
}

/*
 * Drag feedback. `drag-over` is purely geometric (scale + z-index); the
 * color comes from valid-drop / invalid-drop / warning-drop, which the
 * orchestrator applies in tandem with `drag-over`. Keeping color and
 * geometry on different classes lets us stay !important-free.
 */
.seat.drag-over {
  transform: scale(1.15);
  z-index: 10;
}

.seat.valid-drop {
  background: #d4edda;
  border-color: var(--success);
  box-shadow: var(--ring-success);
}

.seat.warning-drop {
  background: var(--warning-soft);
  border-color: var(--warning);
}

.seat.invalid-drop,
.seat.invalid-must,
.seat.violation {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.seat.invalid-drop {
  box-shadow: var(--ring-danger);
}

/*
 * Suggestion tiers. Each tier sets its own color tokens; the shared rule
 * below applies them uniformly. seat-recommended needs no ring or animation
 * so it only defines the two color tokens it actually uses.
 */
.seat.seat-best {
  --tier: var(--success);
  --tier-bg: var(--success-soft);
}

.seat.seat-recommended {
  --tier: var(--success);
  --tier-bg: var(--success-soft);
}

.seat.seat-avoid {
  --tier: var(--danger);
  --tier-bg: var(--danger-soft);
}

.seat.seat-best,
.seat.seat-recommended,
.seat.seat-avoid {
  border: 2px solid var(--tier);
  background: var(--tier-bg);
  transition:
    border-color var(--transition),
    background var(--transition),
    transform var(--transition);
}

.seat.seat-best {
  box-shadow: var(--ring-success);
  animation: pulse-best 2.5s ease-in-out infinite;
}

.seat.seat-avoid {
  box-shadow: var(--ring-danger);
}

/* Auto-arrange newly placed seats */
.seat.new-placement {
  border-color: var(--info);
  animation: pulse-new 0.9s ease-in-out infinite;
}


/* --- guests list ----------------------------------------------------- */
.add-guest-import-section {
  padding: 15px;
  background: #f0f8ff;
  border-radius: var(--radius-lg);
  margin-bottom: 15px;
}

.add-guest-btn {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  color: var(--text);
  border: 2px dashed var(--secondary);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition);
}

.add-guest-btn:hover {
  background: #f0fffe;
}

.suggest-all-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 10px;
  transition: all var(--transition);
}

.suggest-all-btn:hover {
  background: #f0fffe;
  border-color: var(--primary-hover);
  color: var(--primary-hover);
}

.guest-list {
  margin-top: 15px;
}

.guest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: move;
  transition: all var(--transition);
}

.guest-item:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.guest-item.dragging {
  opacity: 0.5;
}

.guest-info {
  flex: 1;
}

.guest-name {
  font-size: 14px;
  color: var(--text);
}

.guest-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.badge-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

/*
 * Badges — `templates.js` builds class names as `${badge.type}-badge`,
 * but only `group` is pushed today, so `group-badge` is the lone live
 * variant. `scope-badge` is set explicitly for adjacency rules.
 */
.group-badge,
.scope-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 5px;
}

.group-badge {
  background: #d1ecf1;
  color: #0c5460;
}

.scope-badge {
  background: #e9ecef;
  color: var(--text-muted);
  font-weight: normal;
}

/* --- guest categories ------------------------------------------------ */
.guest-category {
  margin-bottom: 20px;
}

.guest-category--drop-target {
  outline: 2px dashed var(--primary);
  outline-offset: 4px;
  border-radius: var(--radius-md);
}

.category-header {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.category-header.collapsible {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  padding: 8px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: background var(--transition);
}

.category-header.collapsible:hover {
  background: #e8e8e8;
}

.category-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex: 1;
}

.collapse-arrow {
  margin-right: 8px;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.category-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: normal;
}

.category-content {
  transition: all var(--transition-slow);
}

.category-content.collapsed {
  display: none;
}

/* --- rules list ------------------------------------------------------ */
.rule-section {
  margin-bottom: 15px;
}

.rule-section-header {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-weight: 600;
}

.rule-section-header.collapsible {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.rule-count {
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: normal;
  margin-left: auto;
}

.rule-section-content {
  margin-top: 8px;
}

.rule-item {
  padding: 10px;
  margin-bottom: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  transition: background var(--transition);
}

.rule-item:hover {
  background: #e9ecef;
}

.rule-item.violated {
  background: #ffe8e8;
  border: 1px solid #ffcccc;
}

.rule-text {
  flex: 1;
  font-weight: 500;
}

.group-item {
  padding: 8px;
  background: #d1ecf1;
  border-left: 3px solid #17a2b8;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 12px;
  color: #0c5460;
}

/* --- group members modal -------------------------------------------- */
.member-category-section {
  margin-bottom: 15px;
}

.member-item {
  display: flex;
  align-items: center;
  padding: 6px 4px;
  cursor: pointer;
  margin-bottom: 2px;
  width: 100%;
}

.member-item:hover {
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
}

.group-member-checkbox {
  margin-right: 8px;
  flex-shrink: 0;
}

.member-text {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.member-name {
  font-size: 13px;
}

.member-status {
  color: var(--success);
  font-size: 11px;
}

#selectedMembersPreview {
  margin-bottom: 12px;
  padding: 12px;
  background: var(--success-soft);
  border-radius: var(--radius-md);
  border: 1px solid #c8e6c9;
}

.preview-header {
  font-size: 12px;
  font-weight: 600;
  color: #2e7d32;
  margin-bottom: 8px;
}

.preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preview-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid #a5d6a7;
  border-radius: 16px;
  font-size: 13px;
  color: #1b5e20;
}

.preview-remove {
  width: 16px;
  height: 16px;
  background: none;
  border: none;
  color: var(--danger-text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition);
}

.preview-remove:hover {
  background: #ffcdd2;
}

/* --- category management modal -------------------------------------- */
.category-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.category-item {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.category-item input {
  flex: 1;
  margin-right: 10px;
}

.category-item .category-count {
  margin-right: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.category-form {
  padding: 10px 0;
}

.category-form-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.category-form-section .btn {
  margin-top: 10px;
}

.category-item-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 10px;
}

/* --- context menu ---------------------------------------------------- */
.context-menu {
  position: fixed;
  background: var(--bg);
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: var(--z-toast);
  padding: 4px 0;
}

.menu-item {
  padding: 8px 16px;
  cursor: pointer;
  transition: background var(--transition);
}

.menu-item:hover {
  background: var(--bg-muted);
}

.menu-item.danger {
  color: var(--danger-text);
}

/* --- constraint preview & hover tag --------------------------------- */
.constraint-preview {
  position: fixed;
  background: var(--bg);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  max-width: 300px;
  z-index: var(--z-toast);
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 2px solid #ddd;
  line-height: 1.5;
}

.constraint-preview .constraint-violation {
  color: var(--danger-text);
}

.constraint-preview .constraint-warning {
  color: #f57c00;
}

.constraint-preview .constraint-violation strong,
.constraint-preview .constraint-warning strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.guest-hover-tag {
  position: fixed;
  z-index: var(--z-tag);
  pointer-events: none;
  display: none;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  background: var(--bg);
  color: #111827;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-xl);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- validation panel ----------------------------------------------- */
.validation-panel {
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid #e9ecef;
}

.validation-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.validation-success {
  padding: 10px;
  background: #d4edda;
  border: 1px solid #c3e6cb;
  border-radius: var(--radius-md);
  color: var(--success-text);
  font-size: 12px;
}

.validation-heading {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 6px;
}

.validation-item {
  padding: 10px;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: 12px;
}

.validation-item.error {
  background: #f8d7da;
  border-left-color: #dc3545;
}

.validation-item.warning {
  background: var(--warning-soft);
  border-left-color: #ffc107;
}

.validation-suggestion {
  margin-top: 6px;
  font-size: 11px;
  color: #555;
  font-style: italic;
}

/* --- auto-arrange review banner ------------------------------------- */
/* Block interactions during review, but leave .tables-area itself able to
   receive scroll/wheel events so the user can pan through placed seats. */
body.autoarrange-review .sidebar,
body.autoarrange-review #tablesArea,
body.autoarrange-review .canvas-toolbar,
body.autoarrange-review .print-btn {
  pointer-events: none;
  user-select: none;
}
body.autoarrange-review .main-container {
  filter: saturate(0.9);
}

.autoarrange-review-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: var(--z-review);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  border-radius: var(--radius-xl);
  padding: 12px 14px;
  width: min(720px, calc(100vw - 24px));
  pointer-events: auto;
}

.autoarrange-review-title {
  font-weight: 700;
  font-size: 14px;
  color: #111827;
  margin-bottom: 4px;
}

.autoarrange-review-details {
  font-size: 12px;
  color: #374151;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autoarrange-review-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* --- feedback toasts ------------------------------------------------- */
.feedback-message {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--bg);
  color: #111827;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 2px solid #9ca3af;
  z-index: var(--z-toast);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  animation: slide-in 0.3s ease-out;
}

.feedback-message.feedback-success {
  border-color: #22c55e;
}
.feedback-message.feedback-warning {
  border-color: #f59e0b;
}
.feedback-message.feedback-error {
  border-color: #ef4444;
}
.feedback-message.feedback-info {
  border-color: var(--info);
}

/* --- dormant suggestions panel (HTML still present) ----------------- */
.suggestions-panel {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 250px;
  max-height: 400px;
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 15px;
  display: none;
  z-index: 100;
}

.suggestions-panel.show {
  display: block;
}

/* --- utilities ------------------------------------------------------- */
.empty-state,
.empty-message {
  color: var(--text-subtle);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* --- header issues badge + panel ----------------------------------- */
.rule-stats-btn {
  font: inherit;
  font-weight: 700;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
}
.rule-stats-btn:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.rule-stats-btn:not([aria-expanded='true']):hover {
  text-decoration: underline;
}

.name-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.name-toggle-label {
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}

.name-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.name-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.name-toggle[aria-checked='true'] .name-toggle-thumb {
  transform: translateX(16px);
}

.full-name-mode .seat.occupied {
  overflow: visible;
}

.full-name-mode .seat.occupied .seat-content {
  font-size: 9px;
  overflow-wrap: break-word;
  max-width: calc(var(--seat-size) * 2);
  line-height: 1.3;
  text-shadow: 
    0 0 2px var(--text), 
    -1px 0 var(--text), 
    1px 0 var(--text);
}

.issues-panel {
  margin: 0 20px 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 40vh;
  overflow-y: auto;
}
.issues-panel[hidden] {
  display: none;
}
.issues-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}
.issues-panel-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 12px;
}

.issue-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 0;
  border-left: 4px solid transparent;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  color: var(--text);
}
.issue-item:hover {
  filter: brightness(0.96);
}
.issue-item:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}
.issue-item.violation {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.issue-item.warning {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}
.issue-item-msg {
  flex: 1 1 auto;
}

/* --- animations ------------------------------------------------------ */
@keyframes pulse-best {
  0%,
  100% {
    box-shadow:
      0 0 8px rgba(76, 175, 80, 0.4),
      0 0 0 0 rgba(76, 175, 80, 0.7);
  }
  50% {
    box-shadow:
      0 0 35px rgba(76, 175, 80, 0.9),
      0 0 20px rgba(76, 175, 80, 0.7);
  }
}


@keyframes pulse-new {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.35);
  }
}

@keyframes seat-flash {
  0%,
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
  20%,
  60% {
    box-shadow: 0 0 0 6px var(--flash-color);
  }
}
.seat.flash-violation,
.seat.flash-warning {
  animation: seat-flash 0.6s ease-in-out 2;
  position: relative;
  z-index: 5;
}
.seat.flash-violation {
  --flash-color: rgba(244, 67, 54, 0.55);
}
.seat.flash-warning {
  --flash-color: rgba(255, 152, 0, 0.65);
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* --- combobox (searchable single-select) ---------------------------- */
.combobox {
  position: relative;
}
.combobox-native {
  display: none;
}
.combobox-input {
  width: 100%;
}
.combobox-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 4px 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 1100;
}
.combobox-group {
  padding: 6px 12px 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.combobox-item {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.combobox-item:hover,
.combobox-item.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}
.combobox-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-subtle);
  font-style: italic;
}

/* ── View-only mode ─────────────────────────────────────────────────── */

.view-only-banner {
  display: none;
  background: #fff3cd;
  color: #856404;
  padding: 8px 20px;
  font-size: 13px;
  text-align: center;
  border-bottom: 1px solid #f0cc66;
}

.view-only-banner a {
  color: #856404;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

body.view-only .view-only-banner              { display: block; }
body.view-only .sidebar                       { pointer-events: none; opacity: 0.55; }
body.view-only .canvas-toolbar                { display: none; }
body.view-only .header-right                  { pointer-events: none; opacity: 0.4; }
body.view-only .tables-area .seat             { pointer-events: none; }
body.view-only .tables-area .table-wrapper    { pointer-events: none; }


/* -- FAB Menu ─────────────────────────────────────────────────────── */
.fab-menu { position: fixed; bottom: 20px; right: 20px; z-index: 999; }
/* ── FAB Menu (Floating Action Button) ──────────────────────────────── */

.fab-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  z-index: 900;
}

.fab-options {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.fab-options[hidden] { display: none; }

.fab-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #dbe9f8;
  border: 1px solid #b8d4f0;
  border-radius: 25px;
  color: #3b6cb0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.15s ease;
  text-decoration: none;
}

.fab-option:hover {
  background: #cde0f5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.fab-option:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.fab-option i {
  font-size: 16px;
}

#fab-toggle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #dbe9f8;
  border: 1px solid #b8d4f0;
  color: #3b6cb0;
  font-size: 18px;
  font-weight: 400;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fab-toggle:hover {
  background: #cde0f5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transform: scale(1.05);
}

#fab-toggle:active {
  transform: scale(0.98);
}

/* ── Share modal ─────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* `hidden` attribute must not be overridden by display:flex above */
.modal-overlay[hidden] { display: none !important; }

.modal-box {
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  min-width: 320px;
  max-width: 480px;
  width: 100%;
}

.share-modal-box { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close-btn:hover { background: var(--bg-muted); }

.share-type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.share-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all var(--transition);
}

.share-tab:hover  { background: var(--bg-muted); }
.share-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.share-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.share-url-row {
  display: flex;
  gap: 8px;
}

.share-url-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-soft);
  min-width: 0;
}

/* ── Feedback modal ─────────────────────────────────────────────────────── */

.feedback-modal-box { max-width: 440px; }

.feedback-modal-box .form-group { margin-bottom: 16px; }

.feedback-modal-box textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

.feedback-modal-box .btn-group {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.feedback-form-success {
  padding: 12px;
  background: #d4edda;
  border: 1px solid #c3e6cb;
  border-radius: 6px;
  color: #155724;
  margin-bottom: 16px;
  font-size: 14px;
}

.feedback-form-success:empty { display: none; }

.feedback-form-error {
  padding: 12px;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  color: #721c24;
  margin-bottom: 16px;
  font-size: 14px;
}

.feedback-form-error:empty { display: none; }

.field-error {
  display: block;
  color: #dc3545;
  font-size: 12px;
  margin-top: 4px;
}

.field-error:empty { display: none; }

.feedback-modal-box [data-fs-submit-btn]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
