/* ═══════════════════════════════════════════════
   Retter-Trainer – Rotkreuz Stylesheet
   ═══════════════════════════════════════════════ */

:root {
  --rk-red:       #CC0000;
  --rk-red-dark:  #990000;
  --rk-red-light: #ff3333;
  --rk-white:     #ffffff;
  --rk-bg:        #f4f4f4;
  --rk-text:      #1a1a1a;
  --rk-border:    #ddd;
  --rk-success:   #28a745;
  --rk-warning:   #ffc107;
  --rk-info:      #17a2b8;
  --rk-shadow:    0 2px 8px rgba(0,0,0,.18);
  --rk-radius:    6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--rk-bg);
  color: var(--rk-text);
  font-size: 15px;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  background: var(--rk-red);
  color: var(--rk-white);
  padding: .65rem 1rem;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1rem;
  flex-wrap: wrap;
  box-shadow: var(--rk-shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--rk-white);
}

.topbar .brand .brand-logo { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; }

.topbar nav { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }

.topbar nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: .4rem .85rem;
  border-radius: var(--rk-radius);
  font-size: .9rem;
  transition: background .2s;
}
.topbar nav a:hover,
.topbar nav a.active { background: rgba(255,255,255,.2); color: #fff; }

/* ── Info-Banner (GPS-Hinweis) ──────────────────── */
.info-banner {
  background: var(--rk-red);
  color: var(--rk-white);
  text-align: center;
  padding: .55rem 1rem;
  font-weight: 600;
  font-size: .9rem;
  letter-spacing: .02em;
}
.info-banner .icon { margin-right: .4rem; }

/* ── Layout ─────────────────────────────────────── */
.main-layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--rk-border);
  overflow-y: auto;
  padding: 1rem 0;
  position: sticky;
  top: 56px;
  max-height: calc(100vh - 56px);
  max-height: calc(100dvh - 56px);
  z-index: 2;
}

.content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 1.2rem;
  position: relative;
  z-index: 1;
}

/* ── Sidebar-Nav ────────────────────────────────── */
.sidebar-nav { list-style: none; }

.sidebar-nav li { }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .65rem 1rem;
  color: var(--rk-text);
  text-decoration: none;
  font-size: .9rem;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.sidebar-nav a:hover { background: #fef2f2; border-left-color: var(--rk-red); color: var(--rk-red); }
.sidebar-nav a.active { background: #fef2f2; border-left-color: var(--rk-red); color: var(--rk-red); font-weight: 600; }
.sidebar-nav .section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #999;
  padding: .8rem 1rem .3rem;
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--rk-white);
  border-radius: var(--rk-radius);
  box-shadow: var(--rk-shadow);
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: .65rem;
  border-bottom: 2px solid var(--rk-red);
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--rk-red-dark);
  display: flex;
  align-items: center;
  gap: .45rem;
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem 1rem;
  border: none;
  border-radius: var(--rk-radius);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}
.btn-primary   { background: var(--rk-red);   color: #fff; }
.btn-primary:hover { background: var(--rk-red-dark); }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #545b62; }
.btn-success   { background: var(--rk-success); color: #fff; }
.btn-success:hover { background: #1e7e34; }
.btn-warning   { background: var(--rk-warning); color: #212529; }
.btn-warning:hover { background: #d39e00; }
.btn-danger    { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #bd2130; }
.btn-danger:disabled { opacity: .55; cursor: not-allowed; }
.btn-outline   { background: transparent; border: 2px solid var(--rk-red); color: var(--rk-red); }
.btn-outline:hover { background: var(--rk-red); color: #fff; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg { padding: .65rem 1.4rem; font-size: 1rem; }

/* ── Forms ──────────────────────────────────────── */
.form-group { margin-bottom: .9rem; }
.form-label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .88rem; }
.form-control {
  width: 100%;
  padding: .45rem .7rem;
  border: 1px solid var(--rk-border);
  border-radius: var(--rk-radius);
  font-size: .9rem;
  transition: border-color .2s;
  background: #fff;
}
.form-control:focus { outline: none; border-color: var(--rk-red); box-shadow: 0 0 0 2px rgba(204,0,0,.15); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Grid ───────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }

/* ── Stat-Kacheln ───────────────────────────────── */
.stat-tile {
  background: var(--rk-white);
  border-radius: var(--rk-radius);
  box-shadow: var(--rk-shadow);
  padding: 1rem;
  text-align: center;
  border-top: 3px solid var(--rk-red);
}
.stat-tile .value { font-size: 2rem; font-weight: 800; color: var(--rk-red); }
.stat-tile .label { font-size: .8rem; color: #666; margin-top: .2rem; }

/* ── Map-Container ──────────────────────────────── */
#map, #overview-map, #admin-map {
  width: 100%;
  border-radius: var(--rk-radius);
  border: 1px solid var(--rk-border);
}
#map         { height: 350px; }
#overview-map { height: calc(100vh - 130px); }
#admin-map   { height: 400px; }

/* ── QR-Code-Anzeige ────────────────────────────── */
.qr-display {
  text-align: center;
  padding: 1rem;
}
.qr-display img {
  max-width: 200px;
  border: 3px solid var(--rk-red);
  border-radius: var(--rk-radius);
  padding: 8px;
  background: #fff;
}
.qr-display p { font-size: .8rem; color: #666; margin-top: .5rem; word-break: break-all; }

/* ── Szenen-Grid ────────────────────────────────── */
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 1rem; }
.scene-card {
  background: #fff;
  border-radius: var(--rk-radius);
  box-shadow: var(--rk-shadow);
  overflow: hidden;
  border: 1px solid var(--rk-border);
  transition: transform .15s;
}
.scene-card:hover { transform: translateY(-2px); }
.scene-card img { width: 100%; height: 140px; object-fit: cover; background: #eee; }
.scene-card .scene-body { padding: .75rem; }
.scene-card .scene-name { font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
.scene-card .scene-desc { font-size: .78rem; color: #666; margin-bottom: .6rem; }
.scene-card .scene-actions { display: flex; gap: .4rem; }
.scene-card .scene-actions { flex-wrap: wrap; }

/* ── User-Liste (Übersicht) ─────────────────────── */
.user-list { list-style: none; }
.user-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .8rem;
  border-radius: var(--rk-radius);
  margin-bottom: .4rem;
  background: #fff;
  border-left: 4px solid var(--rk-success);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  font-size: .88rem;
}
.user-item.inactive { border-left-color: #ccc; opacity: .6; }
.user-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--rk-success);
  flex-shrink: 0;
}
.user-dot.inactive { background: #ccc; }
.user-role { font-weight: 700; color: var(--rk-red-dark); }
.user-time { font-size: .75rem; color: #888; margin-left: auto; }

/* ── Login-Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
.modal-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  padding: 2rem;
  width: 90%;
  max-width: 420px;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  animation: slideUp .25s ease;
}
.modal-box h2 { color: var(--rk-red); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── QR-Scanner ─────────────────────────────────── */
#qr-reader { width: 100%; border-radius: var(--rk-radius); overflow: hidden; }
#qr-reader video { border-radius: var(--rk-radius); }

/* ── Panorama-Viewer ────────────────────────────── */
#panorama {
  width: 100%;
  height: calc(100vh - 56px);
  height: calc(100dvh - 56px);
  background: #111;
}

/* ── Tabs ───────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--rk-red); margin-bottom: 1.2rem; }
.tab-btn {
  padding: .55rem 1.1rem;
  background: none;
  border: none;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  color: #666;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}
.tab-btn.active { color: var(--rk-red); border-bottom-color: var(--rk-red); }
.tab-btn:hover  { color: var(--rk-red); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Alerts ─────────────────────────────────────── */
.alert {
  padding: .65rem 1rem;
  border-radius: var(--rk-radius);
  margin-bottom: .8rem;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--rk-success); }
.alert-danger   { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }
.alert-warning  { background: #fff3cd; color: #856404; border-left: 4px solid var(--rk-warning); }
.alert-info     { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--rk-info); }

/* ── GPS-Badge ──────────────────────────────────── */
.gps-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .8rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
}
.gps-badge.active   { background: #d4edda; color: #155724; }
.gps-badge.inactive { background: #f8d7da; color: #721c24; }
.gps-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Toggle ─────────────────────────────────────── */
.toggle { display: flex; align-items: center; gap: .6rem; }
.toggle input[type=checkbox] { width: 36px; height: 20px; cursor: pointer; accent-color: var(--rk-red); }

/* ── Tabelle ────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { background: var(--rk-red); color: #fff; padding: .55rem .8rem; text-align: left; font-weight: 600; }
td { padding: .5rem .8rem; border-bottom: 1px solid #eee; }
tr:hover td { background: #fef2f2; }

/* ── Koordinaten-Eingabe ────────────────────────── */
.coord-input { display: flex; gap: .5rem; }
.coord-input .form-control { flex: 1; }

/* ── Upload-Bereich ─────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--rk-border);
  border-radius: var(--rk-radius);
  padding: 2rem;
  text-align: center;
  color: #888;
  cursor: pointer;
  transition: all .2s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--rk-red); color: var(--rk-red); background: #fef2f2; }
.drop-zone .icon { font-size: 2rem; margin-bottom: .5rem; display: block; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 1024px) {
  .main-layout { flex-direction: column; height: auto; }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--rk-border);
    padding: .75rem 0;
    max-height: none;
  }
  .sidebar-nav {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    padding: 0 .75rem .25rem;
    scrollbar-width: thin;
  }
  .sidebar-nav li { flex: 0 0 auto; }
  .sidebar-nav .section-title { display: none; }
  .sidebar-nav a {
    border-left: none;
    border: 1px solid var(--rk-border);
    border-bottom: 3px solid transparent;
    border-radius: 999px;
    background: #fff;
    white-space: nowrap;
    padding: .6rem .95rem;
  }
  .sidebar-nav a:hover,
  .sidebar-nav a.active {
    border-left-color: var(--rk-border);
    border-color: rgba(204,0,0,.2);
    border-bottom-color: var(--rk-red);
  }
  .content { padding: 1rem; }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .coord-input { flex-direction: column; }
  .card { padding: 1rem; }
  .drop-zone { padding: 1.35rem; }
  .scene-grid { grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); }
  .user-item { flex-wrap: wrap; align-items: flex-start; }
  .user-time { width: 100%; margin-left: 0; }
  .topbar .brand { font-size: .92rem; }
  .topbar .brand .brand-logo { width: 24px; height: 24px; }
  .topbar nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: .1rem;
  }
  .topbar nav a {
    flex: 1 0 auto;
    text-align: center;
    padding: .5rem .75rem;
  }
  #map { height: 280px; }
  #admin-map { height: 320px; }
  #overview-map { height: 55vh; }
}

@media (max-width: 480px) {
  .topbar { padding: .75rem; }
  .content { padding: .75rem; }
  .btn,
  .btn-lg { width: 100%; justify-content: center; }
}

/* ── Rotkreuz-Zeichen ───────────────────────────── */
.rk-cross {
  display: inline-block;
  width: 32px; height: 32px;
  background:
    linear-gradient(var(--rk-white) 0%, var(--rk-white) 100%) center/10px 100% no-repeat,
    linear-gradient(var(--rk-white) 0%, var(--rk-white) 100%) center/100% 10px no-repeat;
  background-color: var(--rk-red);
  border-radius: 3px;
}

/* ── Spinner ─────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid #eee;
  border-top-color: var(--rk-red);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── User-Marker-Popup ───────────────────────────── */
.user-popup .role { font-weight: 700; color: var(--rk-red); }
.user-popup .time { font-size: .75rem; color: #888; }
