/* ===== EDEN Kitchen Bell — Dark Theme ===== */

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1e2f4f;
  --text: #e0e0e0;
  --text-muted: #8892a6;
  --accent: #0f3460;
  --ready: #00c853;
  --ready-bg1: #1b5e20;
  --ready-bg2: #2e7d32;
  --ready-text: #ffffff;
  --ready-glow: rgba(0, 200, 83, 0.4);
  --ready-pulse: rgba(0, 200, 83, 0.15);
  --picked-up: #455a64;
  --border: #2a2a4a;
  --danger: #ff5252;
  --warning: #ffd740;
  --radius: 16px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --header-bg: #16213e;
  --queue-bg1: #1b5e20;
  --queue-bg2: #2e7d32;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

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

.header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header .role-badge {
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.role-badge.kitchen {
  background: #e65100;
  color: #fff;
}

.role-badge.service {
  background: #1565c0;
  color: #fff;
}

.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
  margin-right: 8px;
  transition: background 0.3s;
}

.connection-dot.connected {
  background: var(--ready);
}

/* ===== Queue Banner (Service only) ===== */
.queue-banner {
  display: none;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--queue-bg1), var(--queue-bg2));
  overflow-x: auto;
  white-space: nowrap;
  gap: 10px;
  align-items: center;
  font-weight: 600;
  font-size: 1.1rem;
  animation: slideDown 0.3s ease;
}

.queue-banner.visible {
  display: flex;
}

.queue-banner .queue-label {
  color: #a5d6a7;
  margin-right: 6px;
  flex-shrink: 0;
}

.queue-banner .queue-item {
  background: rgba(255,255,255,0.15);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  flex-shrink: 0;
}

/* ===== Table Grid ===== */
.table-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 10px;
  padding: 14px;
  height: calc(100vh - 60px);
}

.table-grid.with-queue {
  height: calc(100vh - 110px);
}

/* ===== Table Button ===== */
.table-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  min-height: 80px;
}

.table-btn:active {
  transform: scale(0.95);
}

.table-btn .table-name {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  padding: 4px;
}

.table-btn .table-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Ready state */
.table-btn.ready {
  background: linear-gradient(135deg, var(--ready-bg1), var(--ready-bg2));
  border-color: var(--ready);
  box-shadow: 0 0 20px var(--ready-glow);
}

.table-btn.ready .table-name {
  color: var(--ready-text);
}

.table-btn.ready .table-status {
  color: var(--ready-text);
  opacity: 0.8;
}

/* Pulse animation for service view */
.table-btn.ready.pulse {
  animation: tablePulse 1.5s ease-in-out infinite;
}

@keyframes tablePulse {
  0%, 100% {
    box-shadow: 0 0 20px var(--ready-glow);
  }
  50% {
    box-shadow: 0 0 40px var(--ready-glow), 0 0 60px var(--ready-pulse);
  }
}

/* New alert flash */
.table-btn.flash {
  animation: tableFlash 0.4s ease-in-out 3;
}

@keyframes tableFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== Grid Placement (matches restaurant floor plan) ===== */

/* Row 1: Steinwand 4er + 6er links, Rundtisch, Torbogen Fenster rechts */
.table-btn[data-table="steinwand-4er"]    { grid-column: 1; grid-row: 1; }
.table-btn[data-table="steinwand-6er"]    { grid-column: 1; grid-row: 2; }
.table-btn[data-table="rundtisch"]        { grid-column: 2; grid-row: 1; }
.table-btn[data-table="torbogen-fenster"] { grid-column: 4 / 6; grid-row: 1; }

/* Row 2: Bistro-Tisch Mitte, Torbogen 1+2 rechts */
.table-btn[data-table="bistro"]      { grid-column: 2 / 4; grid-row: 2; }
.table-btn[data-table="torbogen-1"]  { grid-column: 4; grid-row: 2; }
.table-btn[data-table="torbogen-2"]  { grid-column: 5; grid-row: 2; }

/* Row 3: Pastel 3 links, Empore 1+2 rechts */
.table-btn[data-table="pastel-3"]  { grid-column: 1; grid-row: 3; }
.table-btn[data-table="empore-1"]  { grid-column: 4; grid-row: 3; }
.table-btn[data-table="empore-2"]  { grid-column: 5; grid-row: 3; }

/* Row 4: Pastel 4, Eckbank rechts */
.table-btn[data-table="pastel-4"]  { grid-column: 1; grid-row: 4; }
.table-btn[data-table="eckbank"]   { grid-column: 2 / 4; grid-row: 4; }

/* Row 5: Pastel 2 links */
.table-btn[data-table="pastel-2"]  { grid-column: 1; grid-row: 5; }

/* ===== Fullscreen Button ===== */
.fullscreen-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
}

.fullscreen-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ===== Animations ===== */
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .table-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px;
  }
  .table-btn .table-name {
    font-size: 0.9rem;
  }
  .header h1 {
    font-size: 1rem;
  }
}

@media (min-width: 1024px) {
  .table-btn .table-name {
    font-size: 1.4rem;
  }
}

/* ===== Edit Mode (free positioning) ===== */
.table-grid.edit-mode {
  display: block;
  position: relative;
}

.table-grid.edit-mode .table-btn {
  position: absolute;
  border: 2px dashed var(--ready) !important;
  cursor: move;
  touch-action: none;
  min-height: 0;
}

.table-grid.edit-mode .table-btn.dragging {
  opacity: 0.7;
  z-index: 100;
}

/* Resize handles */
.resize-handle {
  position: absolute;
  background: var(--ready);
  border-radius: 3px;
  z-index: 10;
}

.rh-nw, .rh-ne, .rh-sw, .rh-se { width: 14px; height: 14px; border-radius: 50%; }
.rh-n, .rh-s { height: 6px; left: 20%; right: 20%; }
.rh-e, .rh-w { width: 6px; top: 20%; bottom: 20%; }

.rh-nw { top: -4px; left: -4px; cursor: nw-resize; }
.rh-ne { top: -4px; right: -4px; cursor: ne-resize; }
.rh-sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.rh-se { bottom: -4px; right: -4px; cursor: se-resize; }
.rh-n  { top: -3px; cursor: n-resize; }
.rh-s  { bottom: -3px; cursor: s-resize; }
.rh-e  { right: -3px; cursor: e-resize; }
.rh-w  { left: -3px; cursor: w-resize; }

/* ===== HUD Overlay ===== */
.hud-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.hud-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.hud-panel {
  background: #1e1e2e;
  border: 1px solid #3a3a5a;
  border-radius: 20px;
  width: 90%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #3a3a5a;
}

.hud-header h2 {
  font-size: 1.2rem;
  color: #e0e0e0;
}

.hud-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.hud-close:hover { color: #fff; }

.hud-body {
  padding: 16px 20px 20px;
}

.hud-body h3 {
  font-size: 0.85rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #282840;
  padding: 8px 12px;
  border-radius: 10px;
}

.color-row label {
  font-size: 0.8rem;
  color: #bbb;
}

.color-row input[type="color"] {
  width: 32px;
  height: 28px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 0;
}

.hud-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.hud-btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid #3a3a5a;
  background: #282840;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.hud-btn:hover { background: #3a3a5a; }
.hud-btn.active { background: var(--ready); color: #000; border-color: var(--ready); }
.hud-btn.reset { color: #ff8a80; border-color: #5a2a2a; }
.hud-btn.reset:hover { background: #4a2020; }

.hud-hint {
  margin-top: 10px;
  font-size: 0.75rem;
  color: #666;
  line-height: 1.4;
}

/* Delete button on tables in edit mode */
.delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #d32f2f;
  color: #fff;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-btn:hover {
  background: #f44336;
  transform: scale(1.1);
}

.rename-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1565c0;
  color: #fff;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rename-btn:hover {
  background: #1976d2;
  transform: scale(1.1);
}

/* Edit mode banner */
.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: linear-gradient(135deg, #e65100, #bf360c);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

.edit-banner .hud-btn {
  background: #fff;
  color: #e65100;
  border: none;
  font-weight: 700;
}

/* Settings gear button */
.settings-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.settings-btn:hover {
  border-color: var(--text);
  color: var(--text);
}
