@import url('../theme.css');

:root {
  --bg: #10141B;
  --bg-alt: #171C25;
  --panel: #1B212B;
  --panel-alt: #232A35;
  --border: #313A47;
  --border-soft: #262D38;
  --text: #E7EBF0;
  --text-muted: #8B93A3;
  --text-dim: #5F6673;
  --accent: #29B6D8;
  --accent-strong: #1C93B0;
  --accent-soft: rgba(41, 182, 216, 0.14);
  --assigned-bg: #22345F;
  --assigned-border: #16234A;
  --assigned-text: #E8EEFC;
  --conflict-bg: #6E4A1E;
  --conflict-border: #4E3414;
  --conflict-text: #FCE9C9;
  --success-bg: #1F5C3A;
  --success-text: #BFF3D0;
  --danger-bg: #5C1F1F;
  --danger-text: #F3BFBF;
  --muted-bg: #2A303B;
  --muted-text: #9AA3B2;
  --frei-bg: #232A35;
  --frei-border: #313A47;
  --frei-text: #8B93A3;
  --edit-bg: #16232B;
  --edit-border: #29B6D8;
  --edit-text: #7FE3FF;
  --birthday-tint: rgba(230, 180, 60, 0.12);
  --select-shadow: rgba(41, 182, 216, 0.35);
}

[data-theme="light"] {
  --bg: #F3F5F8;
  --bg-alt: #E9ECF1;
  --panel: #FFFFFF;
  --panel-alt: #F1F3F6;
  --border: #D7DDE5;
  --border-soft: #E6E9EE;
  --text: #1C222C;
  --text-muted: #626A78;
  --text-dim: #8A93A2;
  --accent: #0E93B4;
  --accent-strong: #0C7A96;
  --accent-soft: rgba(14, 147, 180, 0.10);
  --assigned-bg: #DCE6FA;
  --assigned-border: #9FB6E8;
  --assigned-text: #1B2E5C;
  --conflict-bg: #F5E3C2;
  --conflict-border: #D8B368;
  --conflict-text: #5C3F12;
  --success-bg: #DFF3E6;
  --success-text: #1F5C3A;
  --danger-bg: #F8DEDE;
  --danger-text: #8C2E2E;
  --muted-bg: #E7EAEE;
  --muted-text: #6B7280;
  --frei-bg: #F1F3F6;
  --frei-border: #D7DDE5;
  --frei-text: #626A78;
  --edit-bg: #E6F6FA;
  --edit-border: #0E93B4;
  --edit-text: #0C7A96;
  --birthday-tint: rgba(214, 158, 46, 0.16);
  --select-shadow: rgba(14, 147, 180, 0.30);
}

body { transition: background-color .15s ease, color .15s ease; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.app { padding: 16px 16px 40px; max-width: 1640px; margin: 0 auto; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 3px;
}
h1 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: clamp(22px, 4vw, 30px);
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}
.sync-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 6px var(--accent); }
.sync-label { font-size: 12px; font-weight: 600; color: var(--text); }
.sync-time { font-size: 11px; color: var(--text-muted); }

.theme-toggle {
  display: flex; align-items: center; gap: 6px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.theme-toggle:hover { border-color: var(--accent-strong); color: var(--text); }

.search-bar { position: relative; margin-bottom: 16px; }
.search-bar input {
  width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 14px; font-size: 14px; color: var(--text);
}
.search-bar input:focus { outline: none; border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text-dim); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  max-height: 320px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.35); display: none;
}
.search-results.open { display: block; }
.search-result-item {
  width: 100%; text-align: left; background: transparent; border: none; border-bottom: 1px solid var(--border-soft);
  padding: 10px 14px; color: var(--text); display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-alt); }
.search-result-item .sr-name { font-weight: 700; font-size: 13px; }
.search-result-item .sr-meta { font-size: 11px; color: var(--text-muted); }
.search-empty { padding: 12px 14px; font-size: 12px; color: var(--text-muted); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(6, 9, 13, 0.6); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 22px; max-width: 420px; width: 100%; max-height: 85vh; overflow-y: auto;
}
.modal-close {
  float: right; background: transparent; border: none; color: var(--text-muted);
  font-size: 18px; line-height: 1; padding: 2px 4px;
}
.modal-close:hover { color: var(--text); }
.modal-title { font-size: 18px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.modal-sub { font-size: 12px; color: var(--accent); margin-bottom: 16px; }

.btn { background: var(--accent-strong); color: #06131A; border: none; border-radius: 6px; padding: 7px 12px; font-size: 12px; font-weight: 700; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--accent); }
.btn-outline { background: transparent; color: #F0A8A0; border: 1px solid #5C3630; border-radius: 6px; padding: 6px 10px; font-size: 12px; font-weight: 600; margin-top: 4px; }

.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-actions-row { display: flex; align-items: center; gap: 10px; }

/* Reiter-Leiste im Sihot-Stil: dunkel, aktiver Reiter mit Cyan-Unterstrich */
.tabs { display: flex; gap: 2px; margin-bottom: 18px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  padding: 10px 16px; display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px; color: var(--text-muted); border-radius: 6px 6px 0 0;
}
.tab:hover { background: var(--bg-alt); color: var(--text); }
.tab.active { background: var(--panel); color: var(--text); border-bottom: 2px solid var(--accent); }
.tab.archive-active { background: var(--panel); color: var(--accent); border-bottom: 2px solid var(--accent); }
.tab-divider { width: 1px; align-self: stretch; background: var(--border); margin: 4px 4px; }
.tab-label { font-weight: 700; font-size: 13px; }
.tab-time { font-size: 10px; opacity: 0.75; }

.body-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 860px) {
  .body-grid { grid-template-columns: 1fr; }
}

.plan-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.plan-header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.plan-title { font-family: 'Inter', sans-serif; font-size: 17px; font-weight: 700; margin: 0; color: var(--text); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid; display: inline-block; }

.view-toggle { display: flex; gap: 6px; margin-bottom: 14px; }
.view-toggle-btn { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 7px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.view-toggle-btn:hover { border-color: var(--accent-strong); color: var(--text); }
.view-toggle-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.room-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.room-tab {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
}
.room-tab:hover { border-color: var(--accent-strong); color: var(--text); }
.room-tab .r-range { font-size: 10px; font-weight: 500; opacity: 0.7; }
.room-tab.active { background: var(--accent); border-color: var(--accent); color: #071319; }
.room-tab.active .r-range { opacity: 0.8; }

.plan { position: relative; width: 100%; aspect-ratio: 2 / 1; min-height: 460px; max-height: 720px; background: var(--bg-alt); border: 1px dashed var(--border); border-radius: 8px; overflow-x: hidden; overflow-y: auto; }
@media (max-width: 860px) {
  .plan { min-height: 320px; aspect-ratio: 4 / 3; }
}
.table-shape {
  position: absolute; border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 3px 4px; text-align: center;
  transition: box-shadow .15s ease, transform .15s ease; border-width: 2px; border-style: solid;
  overflow: hidden; line-height: 1.1;
}
.table-shape:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.table-shape .t-num,
.table-shape .t-name,
.table-shape .t-seats {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.table-shape .t-num { font-weight: 700; font-size: clamp(9px, 2.2vw, 12px); }
.table-shape .t-name { font-size: clamp(7px, 1.6vw, 9px); opacity: 0.9; }
.table-shape .t-seats { font-size: clamp(7px, 1.6vw, 9px); opacity: 0.75; }

.sidebar { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; }
.stat-row.split { border-top: 1px solid var(--border-soft); margin-top: 8px; padding-top: 10px; }
.stat-num { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 21px; color: var(--accent); }
.stat-lbl { font-size: 12px; color: var(--text-muted); }

.card-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; margin-bottom: 10px; }
.detail-empty { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.detail-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--border-soft); color: var(--text); }

.guest-row { border-bottom: 1px solid var(--border-soft); padding-bottom: 10px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.guest-name { font-weight: 700; font-size: 13px; color: var(--text); }
.guest-meta { font-size: 11px; color: var(--text-muted); }
.assign-row { display: flex; gap: 6px; }
.num-input { width: 78px; padding: 6px 8px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; color: var(--text); }
.num-input:focus { outline: none; border-color: var(--accent); }

.archive-dates { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.date-chip { background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.date-chip.active { background: var(--accent); border-color: var(--accent); color: #071319; }
.archive-meal-row { display: flex; gap: 8px; margin-bottom: 14px; }
.archive-meal-btn { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.archive-meal-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ledger-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px; overflow-x: auto; }
table.ledger { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ledger th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.ledger td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); color: var(--text); }
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }

.guest-list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.guest-list-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.guest-list-table td { padding: 10px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; color: var(--text); }
.guest-list-table tr.birthday-row td { background: var(--birthday-tint); }
.guest-list-table .cell-name { font-weight: 700; }
.guest-list-table .cell-comment { color: var(--text-muted); font-size: 12px; max-width: 260px; }
.guest-list-table .cell-muted { color: var(--text-dim); }
.table-badge { display: inline-block; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 600; color: var(--text-muted); }
.table-badge.assigned { background: var(--accent-soft); border-color: var(--accent-strong); color: var(--accent); }

/* ---------- Smartphone-Ansicht ---------- */
@media (max-width: 640px) {
  .app { padding: 12px 10px 32px; }
  .header { margin-bottom: 14px; padding-bottom: 10px; gap: 10px; }
  h1 { font-size: 20px; }
  .eyebrow { font-size: 10px; }
  .header-actions { width: 100%; flex-direction: column; align-items: stretch; gap: 8px; }
  .sync-box { width: 100%; }
  .header-actions-row { width: 100%; }
  .header-actions-row .btn,
  .header-actions-row .theme-toggle { flex: 1; justify-content: center; text-align: center; }

  .search-bar { margin-bottom: 12px; }
  .search-bar input { padding: 10px 12px; font-size: 13px; }

  /* Reiter-Leisten scrollen horizontal statt umzubrechen — spart Höhe */
  .tabs, .view-toggle, .room-tabs, .archive-dates, .archive-meal-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar, .view-toggle::-webkit-scrollbar,
  .room-tabs::-webkit-scrollbar, .archive-dates::-webkit-scrollbar,
  .archive-meal-row::-webkit-scrollbar { display: none; }
  .tab, .view-toggle-btn, .room-tab, .date-chip, .archive-meal-btn { flex: 0 0 auto; }
  .tab-divider { display: none; }

  .plan-wrap, .card { padding: 12px; }
  .plan-title { font-size: 15px; }
  .plan { min-height: 260px; aspect-ratio: 1 / 1; }

  .stat-num { font-size: 18px; }
  .card-title { font-size: 10px; }

  .guest-list-table th, .guest-list-table td { padding: 8px 6px; font-size: 12px; }
  .guest-list-table .cell-comment { max-width: 140px; }

  .modal-card { padding: 16px; }
}
