:root {
  --bg-page:        #191D24;
  --bg-panel:       #14171D;
  --bg-surface:     #20242C;
  --bg-surface-alt: #1D222A;
  --border:         #2C323A;
  --border-subtle:  #21262F;

  --text-primary:   #E7E9EC;
  --text-secondary: #8B95A1;
  --text-muted:     #6B7480;
  --text-faint:     #565D68;

  --accent:         #3C94D0;
  --accent-text:    #EAF5FC;

  --status-ok-bg:      #1E332B;
  --status-ok-text:    #6FCF97;
  --status-warn-bg:    #362A16;
  --status-warn-text:  #E5A445;
  --status-danger-bg:  #3A2020;
  --status-danger-text:#E5726B;

  --radius: 6px;
  --radius-lg: 10px;

  --sidebar-width: 240px;
  --sidebar-width-collapsed: 64px;
}

/* Helles Design (Hell-/Dunkel-Umschaltung, siehe app-theme-toggle in header.php).
   Dark bleibt der Standard (:root oben) für nicht-eingeloggte Seiten mit
   eigenem, bewusst dunklem Branding (Login) ohne Umschalter. */
[data-bs-theme="light"] {
  --bg-page:        #F3F5F7;
  --bg-panel:       #FFFFFF;
  --bg-surface:     #FFFFFF;
  --bg-surface-alt: #F1F3F5;
  --border:         #DDE2E7;
  --border-subtle:  #E9ECEF;

  --text-primary:   #1C2126;
  --text-secondary: #5B6570;
  --text-muted:     #7A8390;
  --text-faint:     #A6ACB4;

  --accent:         #2B7CB0;
  --accent-text:    #FFFFFF;

  --status-ok-bg:      #E3F3E9;
  --status-ok-text:    #1E7A46;
  --status-warn-bg:    #FBF0DC;
  --status-warn-text:  #9C6410;
  --status-danger-bg:  #FBE5E3;
  --status-danger-text:#B93A31;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: 'Manrope', sans-serif;
  font-weight: 400;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: var(--text-primary);
}

a {
  color: var(--accent);
}

small, .small {
  color: var(--text-secondary);
}

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/*
 * Die Seitenleiste bleibt beim Scrollen stehen (Nutzerwunsch 2026-09-24):
 * `position: sticky` mit `align-self: flex-start` — ohne letzteres streckt
 * der Flex-Container sie auf die volle Seitenhöhe und sticky greift nicht.
 * Bewusst sticky statt fixed: so bleibt sie im Textfluss, der Inhalt braucht
 * keinen ausgleichenden Rand und die schmale Ansicht funktioniert unverändert.
 * Eigener Scrollbalken, falls die Navigation länger als der Bildschirm wird.
 */
.app-sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.app-sidebar__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 20px;
  text-align: center;
  text-decoration: none;
}

.app-sidebar__logo {
  width: 100%;
  max-width: 188px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 18px;
}

/* Fallback ohne Hell-Modus-Logo: nur die dunkle (weiße) Wortmarke
   existiert. Ohne eigenen Kastenhintergrund ist sie im Dunkel-Modus
   trotzdem lesbar, weil die Sidebar selbst schon dunkel ist
   (--bg-panel); im Hell-Modus verschwindet sie dagegen mangels
   Hell-Modus-Logo — bis eines hochgeladen ist (/admin/branding), siehe
   .app-sidebar__logo-img--light unten. */

.app-sidebar__logo-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.app-sidebar__logo-img--light {
  display: none;
}

[data-bs-theme="light"] .app-sidebar__logo:not(.app-sidebar__logo--dark-only) .app-sidebar__logo-img--dark {
  display: none;
}

[data-bs-theme="light"] .app-sidebar__logo:not(.app-sidebar__logo--dark-only) .app-sidebar__logo-img--light {
  display: block;
}

.app-sidebar__brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.app-sidebar__nav-group {
  margin-bottom: 10px;
}

.app-sidebar__nav-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.app-sidebar__nav-group-label:hover {
  color: var(--text-muted);
}

.app-sidebar__nav-group-chevron {
  font-size: 11px;
  transition: transform 0.15s;
}

.app-sidebar__nav-group-label.collapsed .app-sidebar__nav-group-chevron {
  transform: rotate(-90deg);
}

.dashboard-category-toggle .bi-chevron-down {
  transition: transform 0.15s;
}

.dashboard-category-toggle.collapsed .bi-chevron-down {
  transform: rotate(-90deg);
}

/* Dashboard-Widget-Inhalte: Schrift schrumpft mit der Kartengröße statt
   nur zu umbrechen (Container Queries statt fester rem-Werte). Größere,
   einzelne Anzeige-Elemente (Uhrzeit, Wetter) bringen ihre eigene,
   stärkere Skalierung mit — das hier ist die Basis für alle übrigen
   Widget-Inhalte (Listen, Badges, Überschriften). */
.grid-stack-item-content {
  container-type: inline-size;
  font-size: clamp(0.65rem, 2.6cqi, 1rem);
}

.grid-stack-item-content h1, .grid-stack-item-content h2, .grid-stack-item-content h3,
.grid-stack-item-content h4, .grid-stack-item-content h5, .grid-stack-item-content h6,
.grid-stack-item-content .h1, .grid-stack-item-content .h2, .grid-stack-item-content .h3,
.grid-stack-item-content .h4, .grid-stack-item-content .h5, .grid-stack-item-content .h6 {
  font-size: 1.15em;
}

.grid-stack-item-content .small, .grid-stack-item-content small,
.grid-stack-item-content .badge {
  font-size: 0.85em;
}

.app-sidebar__nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
}

.app-sidebar__nav a i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  color: var(--accent);
}

.app-sidebar__nav a:hover {
  color: var(--text-primary);
  background: var(--bg-surface-alt);
}

.app-sidebar__nav a.is-active {
  color: var(--text-primary);
  background: var(--bg-surface-alt);
  border-left-color: var(--accent);
}

.app-sidebar__shortcuts {
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.app-sidebar__shortcuts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}

.app-sidebar__pin-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 2px 4px;
  line-height: 1;
}

.app-sidebar__pin-toggle:hover {
  color: var(--accent);
}

.app-sidebar__shortcuts-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.app-sidebar__shortcuts-list li {
  display: flex;
  align-items: center;
  border-radius: var(--radius);
}

.app-sidebar__shortcuts-list li:hover {
  background: var(--bg-surface-alt);
}

.app-sidebar__shortcuts-list a {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
}

.app-sidebar__shortcuts-list a span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar__shortcuts-list a:hover,
.app-sidebar__shortcuts-list a.is-active {
  color: var(--text-primary);
}

.app-sidebar__shortcut-remove {
  margin: 0;
}

.app-sidebar__shortcut-remove button {
  background: none;
  border: none;
  color: var(--text-faint);
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1;
}

.app-sidebar__shortcut-remove button:hover {
  color: var(--status-danger-text);
}

.app-sidebar__pin-form {
  display: flex;
  gap: 4px;
  padding: 6px 8px 2px;
}

.app-sidebar__pin-form input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 6px;
}

.app-sidebar__pin-form button {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0 4px;
}

.app-sidebar__bottom {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.app-sidebar__nav--admin {
  margin-bottom: 6px;
}

.app-sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-sidebar__avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-sidebar__user-info {
  min-width: 0;
}

.app-sidebar__user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar__user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.app-sidebar__logout {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.app-sidebar__logout:hover {
  color: var(--status-danger-text);
}

.app-content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 28px 32px;
}

@media (max-width: 900px) {
  .app-sidebar {
    width: var(--sidebar-width-collapsed);
    flex-basis: var(--sidebar-width-collapsed);
    align-items: center;
  }
  .app-sidebar__brand-name,
  .app-sidebar__nav-group-label,
  .app-sidebar__nav a span,
  .app-sidebar__user-info,
  .app-sidebar__logout,
  .app-sidebar__shortcuts-head span,
  .app-sidebar__shortcuts-list a span,
  .app-sidebar__shortcut-remove,
  .app-sidebar__pin-form {
    display: none;
  }
  .app-sidebar__nav a {
    justify-content: center;
    padding: 10px;
  }
  .app-sidebar__nav-group .collapse {
    display: block !important;
  }
  .app-sidebar__user {
    justify-content: center;
  }
  .app-content {
    padding: 20px 16px;
  }
}

/* ---------- Page header ---------- */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.page-header__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-header__meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Buttons ---------- */

.btn {
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13px;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: var(--accent-text) !important;
  filter: brightness(1.08);
}

.btn-outline-light {
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline-light:hover {
  background: var(--bg-surface-alt);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline-secondary:hover {
  background: var(--bg-surface-alt);
  border-color: var(--border);
  color: var(--text-primary);
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none !important;
}

.card .card-title,
.card .card-text {
  color: var(--text-primary);
}

.card .text-muted {
  color: var(--text-secondary) !important;
}

/* ---------- Tables ---------- */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  color: var(--text-primary);
  font-size: 13px;
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--border-subtle);
  background: transparent;
  padding: 10px 12px;
}

.table thead th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom-color: var(--border);
}

.table tbody td {
  color: var(--text-secondary);
}

.table tbody td:first-child,
.table tbody th {
  color: var(--text-primary);
}

/* ---------- Badges / status ---------- */

.badge {
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
}

.badge-status {
  display: inline-block;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
}

.badge-status--ok {
  background: var(--status-ok-bg);
  color: var(--status-ok-text);
}

.badge-status--warn {
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
}

.badge-status--danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}

/* ---------- Forms ---------- */

.form-control,
.form-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-surface);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(60, 148, 208, 0.18);
}

.form-control::placeholder {
  color: var(--text-faint);
}

.form-label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Light-literal Bootstrap utilities ----------
   Diese App hat keinen Light-Mode. .bg-light/.bg-white/.table-light
   bleiben in Bootstrap absichtlich themen-unabhängig hell (per Design),
   was auf unserem dunklen Grund unlesbaren Text erzeugt. Wir binden sie
   stattdessen an unsere dunklen Oberflächen-Tokens. */

.bg-light,
.bg-white {
  background-color: var(--bg-surface) !important;
  color: var(--text-primary);
}

.table-light,
.table-light > * {
  --bs-table-bg: var(--bg-surface);
  --bs-table-color: var(--text-primary);
  color: var(--text-primary);
}

/* ---------- Alerts / flash ---------- */

.alert {
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
}

.alert-success {
  background: var(--status-ok-bg);
  color: var(--status-ok-text);
}

.alert-warning {
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
}

.alert-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}

.alert-info {
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  border-color: var(--border);
}

/* ---------- Login ---------- */

.login-shell {
  display: flex;
  min-height: 100vh;
}

.login-panel {
  position: relative;
  flex: 0 0 46%;
  max-width: 46%;
  overflow: hidden;
  background: var(--bg-panel);
  color: var(--text-primary);
}

.login-panel__bg,
.login-panel__dots,
.login-panel__overlay {
  position: absolute;
  inset: 0;
}

.login-panel__bg {
  background-size: cover;
  background-position: center;
}

.login-panel__dots {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='2' cy='2' r='1' fill='%232C323A'/%3E%3C/svg%3E");
  opacity: 0.6;
}

.login-panel__overlay {
  background: linear-gradient(to bottom, rgba(20, 23, 29, 0.5) 0%, rgba(20, 23, 29, 0.98) 100%);
}

.login-panel__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 40px;
}

.login-panel__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-panel__logo {
  width: 176px;
  height: 48px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 8px;
  /* Fest dunkler Hintergrund statt --bg-surface-alt: das Logo ist eine
     weiße Wortmarke auf transparentem Grund, gedacht für dunklen
     Untergrund — die Login-Seite ist ohnehin fest dunkel (kein
     Hell-/Dunkel-Umschalter), daher hier einfach hartcodiert statt über
     eine Theme-Variable, die sich sonst nie ändert. */
  background: #14171c;
  color: var(--accent);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-panel__title {
  font-size: 22px;
  font-weight: 500;
  margin: 24px 0 6px;
}

.login-panel__claim {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 340px;
  line-height: 1.5;
}

.login-panel__footer {
  margin-top: auto;
}

.login-clock {
  font-size: 32px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.login-coords {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.login-weather {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  margin-top: 16px;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
}

.login-weather i {
  font-size: 16px;
  color: var(--text-muted);
}

.login-status {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.login-status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  background: var(--status-ok-text);
}

.login-status__dot--muted {
  background: var(--text-faint);
}

.login-form-panel {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg-page);
}

.login-form {
  width: 100%;
  max-width: 280px;
}

.login-form h1 {
  font-size: 20px;
  margin-bottom: 4px;
}

.login-form__hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.login-form .btn-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
}

.login-form__forgot {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.login-form__forgot:hover {
  color: var(--text-secondary);
}

@media (max-width: 860px) {
  .login-shell {
    flex-direction: column;
  }
  .login-panel {
    flex: 0 0 auto;
    max-width: 100%;
    min-height: 280px;
  }
  .login-form-panel {
    padding: 32px 20px;
  }
}

/* ---------- Beta-Feedback-Widget ---------- */
.feedback-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.feedback-widget__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.feedback-widget__toggle:hover {
  filter: brightness(1.08);
}

.feedback-widget__panel {
  width: 340px;
  max-width: calc(100vw - 40px);
  max-height: 60vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.feedback-widget__list {
  overflow-y: auto;
  padding: 12px;
  flex: 1;
  min-height: 0;
}

.feedback-widget__item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}

.feedback-widget__item:last-child {
  border-bottom: none;
}

.feedback-widget__form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.feedback-widget__form textarea {
  resize: vertical;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 13px;
}
