/* ==========================================================================
   1. VARIABLES & THEMING
   ========================================================================== */
/* Standard: Light Mode */
:root,
body {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;

  --bg-primary: #F2F2F2 !important;
  --bg-surface: white !important;
  --bg-subtle: #f1f3f5 !important;
  --text-primary: #212529 !important;
  --text-secondary: #6c757d !important;
  --border-color: #e9ecef !important;
  --formfield-background: #F7F7F7;
  --fieldset-background: #dcdcdc75;

  /* Primary Akzentfarbe (Hellmodus: Blau) */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;

  /* Button Variables (Light Mode) */
  --btn-bg: #2563eb;
  --btn-text: #ffffff;
  --btn-border: transparent;
  --btn-hover-bg: #1d4ed8;
  --btn-hover-text: #ffffff;

  --btn-danger-bg: #dc2626;
  --btn-danger-text: #ffffff;
  --btn-danger-hover-bg: #b91c1c;
}

/* Automatisch via Systemeinstellungen (System Dark Mode -> Graustufen) */
@media (prefers-color-scheme: dark) {

  :root:not(.light-mode),
  body:not(.light-mode) {
    --bg-primary: #141414;
    --bg-surface: #1e1e1e;
    --bg-subtle: #2d2d2d;
    --text-primary: #f1f1f1d9;
    --text-secondary: #a0a0a0;
    --border-color: #383838;
    --formfield-background: #2d2d2d;
    --fieldset-background: #1e1e1e;

    /* Primär- und Hover-Farben im Dark Mode */
    --primary: #e0e0e0;
    --primary-hover: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);

    /* Button Variables (Dark Mode) */
    --btn-bg: #e0e0e0;
    --btn-text: #141414;
    /* Dunkle Schrift auf hellem Graustufen-Button */
    --btn-border: transparent;
    --btn-hover-bg: #ffffff;
    --btn-hover-text: #000000;

    --btn-danger-bg: #dc2626;
    --btn-danger-text: #ffffff;
    --btn-danger-hover-bg: #b91c1c;
  }
}

/* Manueller Dark Mode (wird via JS gesetzt) */
body.dark-mode {
  --bg-primary: #141414 !important;
  --bg-surface: #1e1e1e !important;
  --bg-subtle: #2d2d2d !important;
  --text-primary: #f1f1f1d9 !important;
  --text-secondary: #a0a0a0 !important;
  --border-color: #383838 !important;
  --formfield-background: #2d2d2d;
  --fieldset-background: #1e1e1e;

  /* Primär- und Hover-Farben im Dark Mode */
  --primary: #e0e0e0 !important;
  --primary-hover: #ffffff !important;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5) !important;

  /* Button Variables (Dark Mode) */
  --btn-bg: #e0e0e0 !important;
  --btn-text: #141414 !important;
  --btn-border: transparent !important;
  --btn-hover-bg: #ffffff !important;
  --btn-hover-text: #000000 !important;

  --btn-danger-bg: #dc2626 !important;
  --btn-danger-text: #ffffff !important;
  --btn-danger-hover-bg: #b91c1c !important;
}

/* Manueller Light Mode (übersteuert System Dark Mode) */
body.light-mode {
  --bg-primary: #F2F2F2 !important;
  --bg-surface: white !important;
  --bg-subtle: #f1f3f5 !important;
  --text-primary: #212529 !important;
  --text-secondary: #6c757d !important;
  --border-color: #e9ecef !important;
  --formfield-background: #F7F7F7;
  --fieldset-background: #dcdcdc75;

  --primary: #2563eb !important;
  --primary-hover: #1d4ed8 !important;

  --btn-bg: #2563eb !important;
  --btn-text: #ffffff !important;
  --btn-border: transparent !important;
  --btn-hover-bg: #1d4ed8 !important;
  --btn-hover-text: #ffffff !important;

  --btn-danger-bg: #dc2626 !important;
  --btn-danger-text: #ffffff !important;
  --btn-danger-hover-bg: #b91c1c !important;
}

/* ==========================================================================
   2. RESET & BASE STYLES
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  margin-top: 2em;
  margin-bottom: 1em;
  padding-bottom: 8px;
  text-align: center;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 16px;
  text-align: center;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   3. MODERN & MINIMALIST NAVBAR
   ========================================================================== */
.navbar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  backdrop-filter: blur(8px);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 1.25rem;
}

/* Brand / Logo */
.navbar-brand {
  display: flex;
  align-items: center;
}

.navbar-brand img {
  height: 34px;
  width: auto;
  transition: transform 0.2s ease;
}

.navbar-brand:hover img {
  transform: scale(1.02);
}

/* Navigation List */
.navbar-collapse {
  display: flex;
  align-items: center;
}

.navbar-nav {
  display: flex;
  list-style: none;
  gap: 0.25rem;
  align-items: center;
  margin: 0;
  padding: 0;
}

.navbar-nav li {
  position: relative;
}

.navbar-nav a {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.92rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
}

.navbar-nav a:hover,
.navbar-nav li.active>a {
  color: var(--primary);
  background-color: var(--bg-subtle);
}

/* Dropdown Menus */
.navbar-nav li:hover>ul {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.navbar-nav ul {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  list-style: none;
  padding: 0.4rem;
  margin-top: 0.25rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.2s ease;
  z-index: 1001;
}

.navbar-nav ul a {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
}

/* Mobile Hamburger Button */
.navbar-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: var(--transition);
}

.navbar-toggle:hover {
  background-color: var(--bg-subtle);
}

.navbar-toggle .icon-bar {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
}

.navbar-toggle .icon-bar+.icon-bar {
  margin-top: 4px;
}

/* Dark Mode Toggle Button im Menü */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  margin-left: 0.5rem;
}

.theme-toggle-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-secondary);
}

/* ==========================================================================
   RESPONSIVE NAVIGATION (Mobile)
   ========================================================================== */
@media (max-width: 768px) {
  .navbar-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .navbar-collapse {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    box-shadow: var(--shadow-md);
  }

  .navbar-collapse.show {
    display: block;
  }

  .navbar-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
  }

  .navbar-nav a {
    padding: 0.75rem 1rem;
    width: 100%;
  }

  .navbar-nav ul {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    padding-left: 1rem;
    background: transparent;
  }
}

/* ==========================================================================
   4. FORMULARE & FILTER
   ========================================================================== */
form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

fieldset {
  border: 1px solid var(--border-color);
  background-color: var(--fieldset-background);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  line-height: 1;
}

legend {
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

.form-group,
fieldset>div,
p.tabelle>div,
form>div {
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: center;
  gap: 1rem;
}

label {
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
  margin: 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea,
.textbox,
.multiselect {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-color);
  background-color: var(--formfield-background);
  color: var(--text-primary);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

/* Größer/Kleiner-Schaltflächen ausblenden */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Für Firefox */
input[type=number] {
  -moz-appearance: textfield;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.div_text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.div_text input {
  max-width: 180px;
}

.button_div {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

/* ==========================================================================
   BUTTON-STYLES
   ========================================================================== */

/* Standard / Primärer Button */
.button,
a.button,
a.button:visited,
button.button,
input[type="submit"].button {
  display: inline-block !important;
  padding: 8px 16px !important;
  background-color: var(--btn-bg) !important;
  color: var(--btn-text) !important;
  border: 1px solid var(--btn-border) !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: all 0.2s ease-in-out !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
  line-height: 1.4 !important;
  text-align: center;
}

.button:hover,
a.button:hover,
button.button:hover,
input[type="submit"].button:hover {
  background-color: var(--btn-hover-bg) !important;
  color: var(--btn-hover-text) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15) !important;
}

/* Gefährlicher Button (Rot) */
.button-danger,
a.button-danger,
a.button-danger:visited,
button.button-danger {
  background-color: var(--btn-danger-bg) !important;
  color: var(--btn-danger-text) !important;
  border-color: var(--btn-danger-bg) !important;
}

.button-danger:hover,
a.button-danger:hover,
button.button-danger:hover {
  background-color: var(--btn-danger-hover-bg) !important;
  border-color: var(--btn-danger-hover-bg) !important;
  color: #ffffff !important;
}

.button:active,
a.button:active,
button.button:active {
  transform: translateY(0) !important;
}

.button-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  /* 4 gleich breite Spalten */
  gap: 12px;
  /* Abstand zwischen den Buttons */
  max-width: 900px;
  /* Optionale maximale Gesamtbreite */
  margin: 0 auto 3em auto;
  /* Zentriert die gesamte Gruppe */
}

.button-container a {
  text-decoration: none;
  display: flex;
}

.button-container .button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}

/* ==========================================================================
   RESPONSIVE FORMULARE (Mobilgeräte)
   ========================================================================== */
@media (max-width: 768px) {

  .form-group,
  fieldset>div,
  p.tabelle>div,
  form>div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  label {
    text-align: left;
    margin-top: 0.5rem;
  }
}

/* ==========================================================================
   5. RESPONSIVES ERGEBNIS-GRID (Karten-Darstellung)
   ========================================================================== */

.container {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1rem;
}

.section0 {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

p.tabelle,
form[name="komparse_abfragen"] {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

[id^="user_id"] {
  display: inline-block;
  vertical-align: top;
  margin: 6px;
}

.ergebnisbox {
  width: 200px !important;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.ergebnisbox .foto-container {
  width: 100%;
  margin-bottom: 8px;
  padding: 3px;
}

.ergebnisbox img {
  width: 100% !important;
  aspect-ratio: 3 / 4;
  /* Erzwingt bei allen Bildern das Seitenverhältnis 3:4 */
  object-fit: cover;
  /* Schneidet überstehende Ränder sauber ab, ohne zu verzerren */
  object-position: center top;
  /* Zentriert das Bild und richtet es an der Oberkante aus (wichtig für Gesichter) */
  border-radius: 2px;
}

.ergebnisbox .daten-bereich {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 8px;
  text-align: left;
}

.ergebnisbox .daten-bereich strong {
  color: var(--text-primary);
}

.ergebnisbox .link-leiste {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
  margin-top: 6px;
  color: var(--text-secondary);
  text-align: center;
}

.ergebnisbox .link-leiste a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.ergebnisbox .link-leiste a:hover {
  color: var(--primary-hover);
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.ergebnisbox .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.ergebnisbox .delete-btn a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 11px;
  line-height: 1;
  color: var(--text-secondary);
  text-decoration: none !important;
  opacity: 0.7;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.ergebnisbox .delete-btn:hover {
  background-color: var(--danger);
  border-color: var(--danger);
}

.ergebnisbox .delete-btn:hover a {
  color: #ffffff !important;
  opacity: 1;
}

/* ==========================================================================
   6. PAGINIERUNG
   ========================================================================== */

/* Haupt-Container: Richtet Paginierung und Direktsprung in einer Zeile aus */
.pagination-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100vw;
  /* Volle Bildschirmbreite */
  box-sizing: border-box;
  /* Verhindert ungewolltes Scrollen durch Padding */
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 12px 20px;

  background-color: #ffffff;
  border-top: 1px solid #dcdcdc;
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.1);
}

/* Paginierungs-Liste */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Gemeinsames Styling für Links, Buttons und aktive Zahlen */
.pagination-link,
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  min-width: 2.3rem;
  height: 2.3rem;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  background-color: var(--bg-color, #fff);
  color: var(--text-color, #333);
  text-decoration: none;
  font-size: 0.9rem;
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Hover-Zustand für klickbare Elemente */
.pagination-link:hover,
.pagination-btn:hover {
  background-color: var(--primary-hover, #f0f0f0);
  border-color: #aaa;
  color: #000;
}

/* Aktive Seitenzahl */
.pagination-link.active {
  background-color: var(--primary-color, #007bff);
  color: #ffffff;
  border-color: var(--primary-color, #007bff);
  font-weight: bold;
  cursor: default;
}

/* Auslassungspunkte (...) */
.pagination-ellipsis {
  padding: 0 0.3rem;
  color: var(--text-secondary, #888);
  font-size: 0.9rem;
  user-select: none;
  min-width: 2.3rem;
  text-align: center;
}

/* Direktsprung-Formular */
/* Direktsprung-Formular zwingend in einer Zeile halten */
.pagination-goto {
  display: flex !important;
  flex-direction: row !important;
  /* Erzwingt die Ausrichtung nebeneinander */
  align-items: center !important;
  gap: 0.4rem !important;
  margin: 0 !important;
  margin-left: 6em !important;
}

/* Verhindert, dass der Button oder das Input die ganze Breite einnehmen */
.pagination-goto input[type="number"] {
  width: 60px !important;
  min-width: 60px !important;
  display: inline-block !important;
  margin: 0 !important;
}

.pagination-goto .pagination-btn {
  display: inline-flex !important;
  width: auto !important;
  margin: 0 !important;
  white-space: nowrap !important;
  /* Verhindert Zeilenumbruch im Button */
}

.pagination-goto label {
  white-space: nowrap;
  font-size: 0.85rem;
  margin: 0;
}

/* Eingabefeld für die Seitenzahl */
.pagination-goto input[type="number"] {
  width: 65px;
  height: 2.3rem;
  padding: 0 0.4rem;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  text-align: center;
  font-size: 0.9rem;
  background-color: var(--bg-color, #fff);
  color: var(--text-color, #333);
  box-sizing: border-box;
  -moz-appearance: textfield;
  /* Blendet Spinner-Pfeile in Firefox aus */
}

/* Blendet Spin-Buttons in Chrome, Safari, Edge aus */
.pagination-goto input[type="number"]::-webkit-outer-spin-button,
.pagination-goto input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pagination-goto input[type="number"]:focus {
  outline: none;
  border-color: var(--primary-color, #007bff);
}

/* Go-Button im Direktsprung */
.pagination-goto .pagination-btn {
  cursor: pointer;
}

body.dark-mode .pagination-wrapper {
  background-color: #1e1e1e;
  border-top-color: #333333;
  color: #ffffff;
}

/* Anzeige der Suchkriterien */
.filter-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 15px auto 25px auto;
  max-width: 900px;
}

.filter-badge {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
}

.filter-badge:hover {
  background-color: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

.filter-label {
  font-weight: bold;
  color: #64748b;
  font-size: 13px;
  margin-right: 4px;
}

/* ==========================================
   DARK-MODE UNTERSTÜTZUNG
   ========================================== */

body.dark-mode .pagination-link,
body.dark-mode .pagination-btn {
  border-color: #444;
  background-color: #1a1a1a;
  color: #ddd;
}

body.dark-mode .pagination-link:hover,
body.dark-mode .pagination-btn:hover {
  background-color: #333;
  border-color: #666;
  color: #fff;
}

body.dark-mode .pagination-link.active {
  background-color: var(--primary-color, #007bff);
  border-color: var(--primary-color, #007bff);
  color: #fff;
}

body.dark-mode .pagination-ellipsis {
  color: #777;
}

body.dark-mode .pagination-goto label {
  color: #ddd;
}

body.dark-mode .pagination-goto input[type="number"] {
  border-color: #444;
  background-color: #1a1a1a;
  color: #fff;
}

/* ==========================================================================
   7. PRINT STYLES
   ========================================================================== */
@media print {

  .noprint,
  .navbar,
  .button,
  .button_div {
    display: none !important;
  }

  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }

  .section0 .container {
    display: block;
  }

  .ergebnisbox {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
    margin-bottom: 1rem;
  }
}

/* ==========================================================================
   8. a2_komparse_abfragen.php
   ========================================================================== */
.range-inputs {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
}

.range-inputs input {
  width: 140px !important;
}