/* ============================================================================
   KassenFlow – Tischverwaltung Styles
   ============================================================================ */

/* ── Overlay & Modal ── */
.tm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: tmFadeIn 0.2s ease;
}

@keyframes tmFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tm-modal {
  background: var(--bg-secondary, #1a1d23);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  width: 95vw;
  max-width: 1100px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  overflow: hidden;
}

/* ── Header ── */
.tm-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}

.tm-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  flex: 1;
}

.tm-view-toggle {
  display: flex;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.tm-toggle-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.tm-toggle-btn.active {
  background: var(--accent, #6C5CE7);
  color: white;
  box-shadow: 0 2px 8px rgba(108,92,231,0.3);
}

.tm-toggle-btn:hover:not(.active) {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
}

.tm-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.tm-close-btn:hover {
  background: rgba(255,0,0,0.15);
  color: #ff6b6b;
}

/* ── Toolbar ── */
.tm-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.tm-btn {
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.tm-btn-primary {
  background: var(--accent, #6C5CE7);
  color: white;
}

.tm-btn-primary:hover {
  background: #5a4bd6;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108,92,231,0.3);
}

.tm-btn-secondary {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
}

.tm-btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.tm-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
}

/* ── Content ── */
.tm-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.tm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: rgba(255,255,255,0.4);
  text-align: center;
}

/* ── Groups ── */
.tm-group {
  margin-bottom: 20px;
}

.tm-group-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.tm-group-count {
  font-weight: 400;
  opacity: 0.5;
}

.tm-group-empty {
  color: rgba(255,255,255,0.25);
  font-style: italic;
  font-size: 0.85rem;
  padding: 8px 0;
}

/* ── Table Cards (Listenansicht) ── */
.tm-table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.tm-table-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  position: relative;
  cursor: default;
}

.tm-table-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(108,92,231,0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.tm-table-number {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent, #6C5CE7);
  line-height: 1;
}

.tm-table-info {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

.tm-table-name {
  color: rgba(255,255,255,0.7);
}

.tm-badge {
  background: rgba(108,92,231,0.2);
  color: var(--accent, #6C5CE7);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
}

.tm-table-shape {
  width: 40px;
  height: 28px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  margin: 4px 0;
}

.tm-shape-round { border-radius: 50%; width: 32px; height: 32px; }
.tm-shape-square { border-radius: 4px; width: 32px; height: 32px; }
.tm-shape-rectangle { border-radius: 4px; }

.tm-table-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.tm-table-card:hover .tm-table-actions {
  opacity: 1;
}

.tm-action-btn {
  background: rgba(255,255,255,0.06);
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.tm-action-btn:hover {
  background: rgba(255,255,255,0.12);
}

.tm-action-delete:hover {
  background: rgba(255,68,68,0.2);
}

/* ── Raumplan ── */
.tm-plan-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  border-radius: 10px 10px 0 0;
}

.tm-zoom-btn {
  background: rgba(255,255,255,0.06);
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.tm-zoom-btn:hover {
  background: rgba(255,255,255,0.12);
  color: white;
}

.tm-zoom-label {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  min-width: 40px;
  text-align: center;
}

.tm-plan-area {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: 
    radial-gradient(circle at 50% 50%, rgba(108,92,231,0.03) 0%, transparent 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0px, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, transparent 1px, transparent 40px);
  cursor: grab;
  border-radius: 0 0 10px 10px;
  min-height: 400px;
}

.tm-plan-area:active { cursor: grabbing; }

.tm-plan-canvas {
  position: relative;
  width: 2000px;
  height: 1200px;
  transform-origin: 0 0;
}

.tm-plan-table {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(108,92,231,0.15), rgba(108,92,231,0.08));
  border: 2px solid rgba(108,92,231,0.3);
  cursor: move;
  transition: box-shadow 0.2s;
  user-select: none;
  z-index: 1;
}

.tm-plan-table:hover {
  border-color: var(--accent, #6C5CE7);
  box-shadow: 0 0 20px rgba(108,92,231,0.3);
  z-index: 10;
}

.tm-plan-table:active {
  box-shadow: 0 0 30px rgba(108,92,231,0.5);
  z-index: 100;
}

/* „Scharf" nach kurzem Halten – der Tisch ist zum Verschieben aufgenommen. */
.tm-plan-table--dragging {
  z-index: 200;
  transform: scale(1.06);
  border-color: #22c55e;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45), 0 0 0 2px rgba(34,197,94,0.6);
  cursor: grabbing;
}

/* Toolbar: Speichern/Zurücksetzen/Hinweis */
.tm-plan-toolbar { flex-wrap: wrap; }
.tm-plan-sep { width: 1px; align-self: stretch; background: rgba(255,255,255,0.1); margin: 0 4px; }
.tm-zoom-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tm-plan-save:not(:disabled) { background: rgba(34,197,94,0.18); color: #4ade80; }
.tm-plan-dirty { font-size: 0.72rem; color: #f59e0b; font-weight: 700; }
.tm-plan-hint { font-size: 0.72rem; color: rgba(255,255,255,0.4); margin-left: auto; }

.tm-plan-shape-round { border-radius: 50%; }
.tm-plan-shape-square { border-radius: 6px; }
.tm-plan-shape-rectangle { border-radius: 8px; }

.tm-plan-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  line-height: 1;
}

.tm-plan-cap {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
}

/* ── Dialog ── */
.tm-dialog {
  background: var(--bg-secondary, #1a1d23);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 24px;
  width: 90vw;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

.tm-dialog h3 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
}

.tm-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tm-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
}

.tm-form input, .tm-form select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  color: white;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.tm-form input:focus, .tm-form select:focus {
  border-color: var(--accent, #6C5CE7);
}

.tm-form-row {
  display: flex;
  gap: 10px;
}

.tm-form-row label { flex: 1; }

.tm-checkbox {
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  cursor: pointer;
}

.tm-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent, #6C5CE7);
}

.tm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ── TimeBlocks Sync ── */
.tm-btn-sync {
  background: linear-gradient(135deg, #0EA5E9, #6366F1);
  color: white;
  margin-left: auto;
}

.tm-btn-sync:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}

.tm-btn-sync-active {
  box-shadow: 0 0 0 2px rgba(14,165,233,0.4);
}

.tm-sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

.tm-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: inline-block;
}

.tm-sync-dot.tm-sync-connected {
  background: #22C55E;
  box-shadow: 0 0 6px rgba(34,197,94,0.5);
  animation: tmPulse 2s infinite;
}

@keyframes tmPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.tm-btn-danger {
  background: rgba(239,68,68,0.15);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.2);
}

.tm-btn-danger:hover {
  background: rgba(239,68,68,0.25);
}

/* ── TB Status Cards ── */
.tb-status-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.tb-status-card.tb-connected {
  border-color: rgba(34,197,94,0.3);
  background: rgba(34,197,94,0.05);
}

.tb-status-card.tb-found {
  border-color: rgba(14,165,233,0.3);
  background: rgba(14,165,233,0.05);
}

.tb-status-card.tb-success {
  border-color: rgba(34,197,94,0.3);
  background: rgba(34,197,94,0.05);
}

.tb-status-card.tb-error {
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.05);
}

.tb-status-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.tb-status-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tb-status-text strong {
  font-size: 0.9rem;
}

.tb-status-text span {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}

.tb-status-text small {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
}

/* ── TB Actions ── */
.tb-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

/* ── TB Compare ── */
.tb-compare-stats {
  display: flex;
  gap: 8px;
}

.tb-stat {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

.tb-stat span {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: white;
}

.tb-stat-warn span {
  color: #F59E0B;
}

.tb-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.tb-compare-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  font-weight: 600;
}

.tb-compare-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.tb-row-conflict {
  background: rgba(245,158,11,0.08);
}

.tb-row-only {
  background: rgba(14,165,233,0.05);
}

/* ============================================================================
   RESERVIERUNGS-STATUS
   ============================================================================ */

/* ── Status Badge (Listenansicht) ── */
.tm-res-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--badge-color, rgba(255,255,255,0.1));
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.7rem;
}

.tm-res-badge:hover {
  background: rgba(255,255,255,0.08);
  transform: scale(1.05);
}

.tm-res-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tm-res-label {
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
}

/* ── Raumplan Status-Farben ── */
.tm-plan-status-green {
  background: linear-gradient(135deg, rgba(34,197,94,0.2), rgba(34,197,94,0.08)) !important;
  border-color: rgba(34,197,94,0.4) !important;
}

.tm-plan-status-blue {
  background: linear-gradient(135deg, rgba(59,130,246,0.25), rgba(59,130,246,0.1)) !important;
  border-color: rgba(59,130,246,0.5) !important;
}

.tm-plan-status-orange {
  background: linear-gradient(135deg, rgba(249,115,22,0.25), rgba(249,115,22,0.1)) !important;
  border-color: rgba(249,115,22,0.5) !important;
  animation: tmPulseTable 1.5s infinite;
}

.tm-plan-status-red {
  background: linear-gradient(135deg, rgba(239,68,68,0.3), rgba(239,68,68,0.1)) !important;
  border-color: rgba(239,68,68,0.6) !important;
  animation: tmPulseTable 1s infinite;
}

.tm-plan-status-yellow {
  background: linear-gradient(135deg, rgba(234,179,8,0.2), rgba(234,179,8,0.08)) !important;
  border-color: rgba(234,179,8,0.4) !important;
}

.tm-plan-status-dim {
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)) !important;
  border-color: rgba(255,255,255,0.15) !important;
}

@keyframes tmPulseTable {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(249,115,22,0); }
  50% { opacity: 0.85; box-shadow: 0 0 20px 4px rgba(249,115,22,0.2); }
}

/* ── Tisch-Detail Popup ── */
.tm-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  margin: -24px -24px 16px -24px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px 14px 0 0;
}

.tm-detail-status {
  font-size: 1rem;
  font-weight: 700;
}

.tm-detail-resos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 350px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.tm-detail-reso {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  transition: all 0.15s;
}

.tm-detail-reso:hover {
  background: rgba(255,255,255,0.06);
}

.tm-reso-active {
  border-color: rgba(59,130,246,0.4);
  background: rgba(59,130,246,0.06);
}

.tm-reso-free {
  opacity: 0.5;
  border-color: rgba(34,197,94,0.3);
  background: rgba(34,197,94,0.03);
}

.tm-reso-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.tm-reso-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tm-reso-info strong {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-reso-info span {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
}

.tm-btn-free {
  background: rgba(34,197,94,0.15);
  color: #22C55E;
  border: 1px solid rgba(34,197,94,0.25);
  font-size: 0.75rem;
  padding: 5px 10px;
  white-space: nowrap;
}

.tm-btn-free:hover {
  background: rgba(34,197,94,0.3);
}

.tm-btn-reset {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  padding: 5px 10px;
}

.tm-btn-reset:hover {
  background: rgba(255,255,255,0.12);
  color: white;
}

.tm-detail-empty {
  text-align: center;
  padding: 24px;
  color: rgba(255,255,255,0.3);
  font-style: italic;
}
