:root {
  --primary: #2ecc71;
  --secondary: #95a5a6;
  --bg: #ffffff;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --light-gray: #f0f0f0;
  --light-green: #d4edda;
  --light-brown: #f5e6d4;
  --light-salmon: #ffdddd;
  --border: #e9ecef;
  --primary-dark: #27ae60;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: sans-serif;
  background-color: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  background: var(--primary);
  color: #fff;
  padding: 1rem;
}

header h1 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.controls input,
.controls select {
  padding: 0.5rem;
  border: none;
  border-radius: 4px;
}

/* Search Container with Clear Button */
.search-container {
  position: relative;
  display: inline-block;
}

.search-container input[type="text"] {
  padding-right: 35px;
  /* Platz für X-Button */
}

.clear-search-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.clear-search-btn:hover {
  background-color: #f0f0f0;
  color: #666;
}

.clear-search-btn:active {
  background-color: #e0e0e0;
  transform: translateY(-50%) scale(0.95);
}

/* Barcode Button und Modal entfernt - automatische Erkennung mit {..} */

.btn-save {
  background-color: #27ae60;
  color: white;
}

.btn-save:hover {
  background-color: #229954;
}

.btn-cancel {
  background-color: #95a5a6;
  color: white;
}

.btn-cancel:hover {
  background-color: #7f8c8d;
}

main {
  flex: 1;
  padding: 1rem;
  overflow: auto;
}

/* Tabelle Reservierungen */
#resTable {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

#resTable th,
#resTable td {
  padding: 0.3rem;
  border: 1px solid var(--light-gray);
  text-align: center;
  /* alle Spalten zentrieren */
}

/* Name-Spalte (4. Spalte) links ausrichten */
#resTable th:nth-child(5),
#resTable td:nth-child(5) {
  text-align: left;
  cursor: pointer;
  /* Mauszeiger ändern bei Hover über Name-Spalte */
}

/* Namen ohne Nachname hervorheben */
.name-missing-lastname {
  font-weight: bold !important;
  color: #8b0000 !important;
  /* dunkelrot */
}

/* Bemerkung-Spalte (8. Spalte) klickbar machen */
#resTable th:nth-child(8),
#resTable td:nth-child(8) {
  cursor: pointer;
}

/* Origin-Spalte (9. Spalte) klickbar machen */
#resTable th:nth-child(9),
#resTable td:nth-child(9) {
  cursor: pointer;
}

/* Origin-Text Styling für dynamische mehrzeilige Darstellung */
.orig-text {
  font-size: 0.7em;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  width: 100%;
  max-height: 2.4em;
  /* 2 Zeilen * 1.2 line-height */
  text-overflow: ellipsis;
}

/* Bem-Text Styling für dynamische mehrzeilige Darstellung */
.bem-text {
  font-size: 0.7em;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  width: 100%;
  max-height: 2.4em;
  /* 2 Zeilen * 1.2 line-height */
  text-overflow: ellipsis;
}

.orig-cell,
.bem-cell {
  padding: 2px 2px !important;
  vertical-align: middle !important;
  position: relative;
  cursor: pointer;
  height: 45px;
  display: table-cell;
  text-align: center;
}

/* Visuelle Anzeige für Zellen mit Overflow */
.has-overflow {
  position: relative;
}

.has-overflow::after {
  content: "⋯";
  position: absolute;
  right: 4px;
  bottom: 2px;
  background: rgba(255, 255, 255, 0.8);
  font-weight: bold;
  color: #666;
  font-size: 12px;
}

.has-overflow:hover {
  background-color: #f0f0f0;
}

/* Spaltenbreiten für bessere Raumnutzung */
#resTable th:nth-child(8),
/* Bem */
#resTable td:nth-child(8) {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

#resTable th:nth-child(9),
/* Orig */
#resTable td:nth-child(9) {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

/* ANam-Spalte (7. Spalte) klickbar machen für QR-Code */
#resTable th:nth-child(7),
#resTable td:nth-child(7) {
  cursor: pointer;
}

tr[data-storno="true"] {
  background-color: var(--light-salmon);
}

tr[data-storno="false"] {
  background-color: var(--light-green);
}

.dog-icon,
.info-icon,
.pie-chart {
  vertical-align: middle;
}

.info-icon,
.dog-icon {
  width: 1.5em;
  cursor: pointer;
}

/* Pie-Chart (kein Cursor-Pointer, da nicht klickbar) */
.pie-chart {
  width: 1.5em;
  height: 1.5em;
  vertical-align: middle;
  cursor: default;
  /* explizit auf default setzen */
}

/* ===========================
   Modal-Grundstil
   =========================== */
/* beide Modals (#modal und #qrModal) haben class="modal" */
.modal {
  display: none;
  /* initial versteckt */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* wenn per JS .visible dran, wird eingeblendet */
.modal.visible {
  display: flex;
}

/* Inhalt der Box (für beide Modals) */
.modal .modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  max-width: 90%;
  width: 360px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  position: relative;
}

/* Close-Button für beide Modals */
.modal .close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text);
}

/* ===========================
   Info-Modal spezifisch
   =========================== */
/* Textbereich */
#modalText {
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 70vh;
  overflow-y: auto;
  color: var(--text);
}

/* Icon-Klassen: Pointer-Cursor */
.info-icon,
.originBtn {
  cursor: pointer;
}

/* Container für Hinweis und QR-Code – flex & zentriert */
#qrContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* horizontal zentrieren */
  justify-content: center;
  /* vertikal zentrieren, falls nötig */
  text-align: center;
  /* Fallback, falls kein Flex */
}

/* Das <div id="qrCode"> selbst als Block zentrieren */
#qrCode {
  display: inline-block;
  /* damit margin:auto wirkt */
  margin: 0 auto;
}

/* Toggle-Button für Anreise/Abreise */
.toggle-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  margin-right: 0.5rem;
}

.toggle-btn.arrival {
  background-color: var(--light-green);
  /* hellgrün */
  color: var(--text);
}

.toggle-btn.departure {
  background-color: #d0ebff;
  /* hellblau */
  color: var(--text);
}

/* Storno-Toggle */
.toggle-btn.no-storno {
  background-color: var(--light-green);
  /* hellgrün */
}

.toggle-btn.storno {
  background-color: var(--light-salmon);
  /* hellrot */
}

/* GastDetail.html Formular */
.form-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
  background: var(--light-gray);
  border-radius: 8px;
}

#gastForm .form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

#gastForm .form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#gastForm .form-group-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  justify-content: center;
  flex-direction: column;
}

#gastForm .form-row .form-group-checkbox {
  margin-bottom: 0;
  justify-content: flex-start;
  flex-direction: row;
}

#gastForm .form-group-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

#gastForm .form-group-checkbox label {
  margin-bottom: 0;
  font-weight: normal;
}

#gastForm label {
  margin-bottom: 0.25rem;
  font-weight: bold;
  font-size: 0.9rem;
}

#gastForm input[type="text"],
#gastForm input[type="date"],
#gastForm select,
#gastForm textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

#gastForm textarea {
  resize: vertical;
}

#gastForm .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}

#gastForm .btn-save,
#gastForm .btn-close {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
}

#gastForm .btn-save {
  background-color: var(--primary);
  color: white;
}

#gastForm .btn-close {
  background-color: var(--secondary);
  color: white;
}

/* Transport-Controls Styling */
.transport-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.transport-input {
  width: 100px !important;
  margin-bottom: 0 !important;
  flex-shrink: 0;
}

.transport-buttons {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.transport-btn {
  padding: 0.25rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  background-color: #f8f8f8;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: bold;
  min-width: 2rem;
  text-align: center;
  transition: background-color 0.2s;
}

.transport-btn:hover {
  background-color: #e0e0e0;
}

.transport-btn:active {
  background-color: #d0d0d0;
}

.transport-btn.clear {
  background-color: #ff6b6b;
  color: white;
  border-color: #e55656;
}

.transport-btn.clear:hover {
  background-color: #e55656;
}

/* Verbindungsstatus in der Navigation */
.connection-status-nav {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.3s ease;
}

.connection-status-nav:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
}

.connection-status-nav .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
  background-color: #6c757d;
  transition: background-color 0.3s ease;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }

  100% {
    opacity: 1;
  }
}

.connection-status-nav .status-text {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Connection Status Indicator - DISABLED: Now in navigation */
.connection-status {
  display: none !important;
  /* Hidden - now using navigation indicator */
}

.connection-status:hover {
  transform: translateY(-1px);
}

.connection-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6c757d;
  display: inline-block;
  margin-right: 8px;
}

.connection-status .status-text {
  font-size: 0.85rem;
  color: #2c3e50;
}

/* Modal für neue Reservierung */
#newReservationModal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
}

#newReservationModal .modal-content {
  background-color: var(--bg);
  margin: 5% auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

#newReservationModal h2 {
  margin-bottom: 20px;
  color: var(--text);
}

#newReservationModal .form-row {
  margin-bottom: 15px;
}

#newReservationModal label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: var(--text);
}

#newReservationModal input,
#newReservationModal select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
}

#newReservationModal .form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

#newReservationModal .btn-save {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
}

#newReservationModal .btn-save:hover {
  background-color: var(--primary-dark);
}

#newReservationModal .btn-cancel {
  background-color: var(--secondary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
}

#newReservationModal .btn-cancel:hover {
  background-color: #7f8c8d;
}

.toggle-btn.new-res {
  background-color: #3498db;
  color: white;
}

.toggle-btn.new-res:hover {
  background-color: #2980b9;
}

/* Sync Button */
.toggle-btn.sync {
  background-color: #9b59b6;
  color: white;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  min-width: auto;
  animation: none;
}

.toggle-btn.sync:hover {
  background-color: #8e44ad;
}

.toggle-btn.sync.syncing {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}