/* ============================================
   GLOBAL VARIABLES – LIGHT MODE
============================================ */

:root {
  --bg: #f4f4f4;
  --bg-card: #ffffff;
  --bg-elevated: #fafafa;

  --text: #222;
  --text-muted: #777;

  --header-bg: #111;
  --header-text: #fff;

  --accent: #c62828;
  --accent-dark: #8e0000;
  --accent-light: #ef9a9a;

  --table-header: #37474f;
  --table-divider: #ddd;

  --form-bg: #fafafa;
  --form-bg-hover: #f0f0f0;
  --form-border: #ccc;
  --form-border-focus: #4c8bf5;
  --form-text: #222;
  --form-placeholder: #777;
  --form-bg-disabled: #f3f3f3;

  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --success-dark: #1b5e20;

  --error: #c62828;
  --error-bg: #ffebee;
  --error-dark: #8e0000;

  --btn-disabled-bg: #e0e0e0;
  --btn-disabled-border: #d0d0d0;
  --btn-disabled-text: #9e9e9e;

  --info: #1565c0;
  --info-bg: #e3f2fd;
  --info-dark: #0d47a1;

  --shadow-soft: rgba(0, 0, 0, 0.15);
  --shadow-strong: rgba(0, 0, 0, 0.55);

  --footer-bg: #f4f4f4;
  --footer-text: #777;
  --footer-border: #ddd;
}

.mt-30 {
  margin-top: 30px;
}

/* ============================================
   DARK MODE
============================================ */

.dark-mode {
  --bg: #121212;
  --bg-card: #1e1e1e;
  --bg-elevated: #0f1520;

  --text: #e6e6e6;
  --text-muted: #a9b3c5;

  --header-bg: #0a0a0a;
  --header-text: #fff;

  --accent: #e53935;
  --accent-dark: #b71c1c;
  --accent-light: #ff7961;

  --table-header: #222;
  --table-divider: #343b4c;

  --form-bg: #080b11;
  --form-bg-hover: #0d1119;
  --form-border: #343b4c;
  --form-border-focus: #4c8bf5;
  --form-text: #f5f5f5;
  --form-placeholder: #7c869a;
  --form-bg-disabled: #0f1420;

  --success: #2e7d32;
  --success-bg: #0f2a15;
  --success-dark: #1b5e20;
  --error: #c62828;
  --error-bg: #4a1417;
  --error-dark: #ff5252;
  --info: #64b5f6;
  --info-bg: #0d1b2a;
  --info-dark: #2196f3;

  --btn-disabled-bg: #1a1f2b;
  --btn-disabled-border: #2b3142;
  --btn-disabled-text: #6f7a94;

  --shadow-soft: rgba(0, 0, 0, 0.45);
  --shadow-strong: rgba(0, 0, 0, 0.9);

  --footer-bg: #1e1e1e;
  --footer-text: #aaa;
  --footer-border: #333;
}

/* ============================================
   GLOBAL BODY
============================================ */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   GENERAL LAYOUT
============================================ */

.container {
  max-width: 1200px;
  background: var(--bg-card);
  padding: 25px;
  margin: 35px auto;
  border-radius: 12px;
  box-shadow: 0 4px 18px var(--shadow-soft);
}

.section-title {
  font-size: 1.5rem;
  margin-bottom: 20px;
  border-left: 6px solid var(--accent);
  padding-left: 10px;
}

.section-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  opacity: 0.85;
}

/* ============================================
   HEADER (Public + Admin) — modernisiert
============================================ */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--table-divider);
  box-shadow: 0 2px 10px var(--shadow-soft);
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 24px;
}

/* Linker Bereich */
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  height: 48px;
  width: 48px;
  border-radius: 14px;
  padding: 4px;
  background: var(--bg-card);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.dark-mode .header-logo {
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.header-title {
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--header-text);
}

.header-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px 0;
}

.header-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
  opacity: 0.85;
}

/* ============================================
   NAVIGATION BUTTONS
============================================ */

.header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.95rem;
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;

  display: inline-flex;
  align-items: center;
  gap: 8px;

  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.04);

  transition: background 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
}

.nav-btn:hover {
  background: var(--form-bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.nav-btn.danger {
  background: var(--error);
  color: #fff;
}
.nav-btn.danger:hover {
  background: var(--error-dark);
}

/* ============================================
   DARK MODE TOGGLE – final, polished version
============================================ */

.dark-toggle {
  width: 40px;
  height: 40px;

  display: inline-flex;
  justify-content: center;
  align-items: center;

  background: var(--bg-elevated);
  border-radius: 12px;
  border: 1px solid var(--table-divider);
  cursor: pointer;

  transition: background 0.25s ease, border-color 0.25s ease, transform 0.15s ease;
}

/* Hover */
.dark-toggle:hover {
  background: var(--form-bg-hover);
  transform: translateY(-2px);
}

/* Icon */
.dark-toggle i {
  font-size: 1.25rem;
  transition: transform 0.35s ease, color 0.25s ease, opacity 0.25s ease;
}

/* Icon-Farben */
.dark-toggle.icon-sun i {
  color: #f5c84c; /* Helle, gut sichtbare Sonne */
}

.dark-toggle.icon-moon i {
  color: #c4dcff; /* Mond in hellem Modus sichtbar */
}

/* Fokus */
.dark-toggle:focus-visible {
  outline: 3px solid var(--form-border-focus);
  outline-offset: 3px;
}

/* ============================================
   BUTTONS – GLOBAL 
============================================ */

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;

  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.btn-primary {
  background: var(--success);
  color: #fff;
}

.btn-primary:hover {
  background: var(--success-dark);
  color: #fff;
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-danger:hover {
  background: var(--error-dark);
  color: #fff;
}

/* verhindert Vererbung von Form-Hovern */
.btn:hover {
  background-clip: padding-box;
  filter: none;
}

button:disabled,
.btn:disabled,
.btn.disabled {
  background: var(--btn-disabled-bg);
  border-color: var(--btn-disabled-border);
  color: var(--btn-disabled-text);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.85;
}

button:disabled:hover,
.btn:disabled:hover {
  transform: none;
}

/* ============================================
   CARDS
============================================ */

.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px 28px;
  box-shadow: 0 8px 26px var(--shadow-soft);
  margin-bottom: 32px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}

.card-header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title-accent {
  width: 3px;
  height: 18px;
  background: #e53935;
  border-radius: 999px;
}

.card-subtitle {
  font-size: 0.8rem;
  color: #a7b0c2;
}

.card.is-collapsed .card-subtitle {
  font-size: 0.8rem;
  opacity: 0.8;
}

.card.is-collapsed {
  box-shadow: 0 4px 14px var(--shadow-soft);
  padding-bottom: 18px;
}

.card.is-collapsed .card-body {
  display: none;
}

.card-body {
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
}

/* eingeklappt */
.card-body.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.card-body.expanded {
  max-height: 2000px;
  opacity: 1;
  pointer-events: auto;
}

.card-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 6px 14px;
  border-radius: 999px;

  background: linear-gradient(135deg, rgba(76, 139, 245, 0.16), rgba(76, 139, 245, 0.06));
  border: 1px solid rgba(76, 139, 245, 0.45);
  color: var(--text);

  font-size: 0.85rem;
  cursor: pointer;

  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.card-toggle i {
  font-size: 0.85rem;
  transition: transform 0.25s ease;
}

.card-toggle:hover {
  background: rgba(76, 139, 245, 0.28);
  transform: translateY(-1px);
}

.card-toggle[aria-expanded='true'] i {
  transform: rotate(180deg);
  background: rgba(76, 139, 245, 0.22);
}

.card-toggle[aria-expanded='true'] .toggle-label {
  opacity: 0.7;
}

/* ============================================
   GLOBAL TABLE DESIGN — Clean Base Version
============================================ */

/* Tabellencontainer */
.table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto; /* ← lässt Browser flexibel entscheiden */
}

/* Kopf- & Datenzellen */
.table th,
.table td {
  padding: 12px 18px;
  vertical-align: middle;
  white-space: nowrap;
}

/* Tabellenkopf */
.table th {
  background: var(--table-header);
  color: #fff;
  font-weight: 600;
  text-align: left;
}

/* Zebra-Streifen */
.table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.05);
}
.dark-mode .table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

/* Hover */
.table tbody tr:hover {
  background: rgba(0, 0, 0, 0.08);
}
.dark-mode .table tbody tr:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Numerische Spalten */
.table td.num,
.table th.num {
  width: 80px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Namensspalte */
.table td.name {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   OPTIONAL: Action Columns
   Werden nur aktiv, wenn .table-actions am <table> hängt
============================================ */

/* letzte Spalte rechtsbündig */
.table-actions th:last-child,
.table-actions td:last-child {
  text-align: right;
  white-space: nowrap;
}

/* Action Icons nebeneinander */
.table-actions td.actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

/* ============================================
   ACTION COLUMNS (nur mit .table-actions)
============================================ */

/* Buttons in der Action-Spalte */
.table-actions td.actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding-right: 8px;
}

/* ============================================
   ACTION ICONS
============================================ */

.action-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease, color 0.15s ease;
}

.action-icon i {
  font-size: 16px;
}

.action-icon:hover {
  transform: scale(1.15);
  background: var(--form-bg-hover);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* Farbakzente */
.action-icon.edit {
  color: #42a5f5;
}
.action-icon.edit:hover {
  color: #90caf9;
}

.action-icon.danger {
  color: #ef5350;
}
.action-icon.danger:hover {
  color: #ff867c;
}

/* ============================================
   FORMS
============================================ */

.form-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-section-title {
  margin-top: 8px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-control label {
  font-size: 0.9rem;
  color: var(--text);
}

.form-input,
.form-select {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--form-border);
  background: var(--form-bg);
  color: var(--form-text);
  transition: 0.2s ease;
}

.form-input:disabled,
.form-input:read-only {
  background: var(--form-bg-disabled);
  color: #666;
  cursor: not-allowed;
  border-color: #ddd;
}

.form-input:read-only:focus {
  outline: none;
  box-shadow: none;
}

.form-input:hover,
.form-select:hover {
  background: var(--form-bg-hover);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--form-border-focus);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px rgba(76, 139, 245, 0.35);
}

.form-input::placeholder {
  color: var(--form-placeholder);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 8px;
}

.form-checkbox:hover {
  background: var(--form-bg-hover);
}

.form-checkbox input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.masked-input {
  -webkit-text-security: disc;
  text-security: disc;
}

/* ============================================
   CHECKBOX TILES
============================================ */

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.checkbox-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--form-bg);
  border: 1px solid var(--form-border);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.checkbox-tile span {
  line-height: 1.2;
}

.checkbox-tile:hover {
  background: var(--form-bg-hover);
  transform: translateY(-1px);
}

.checkbox-tile input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.checkbox-tile span {
  font-size: 0.95rem;
  color: var(--form-text);
}

/* aktiv */
.checkbox-tile input:checked + span {
  font-weight: 600;
}

/* Auswahl visuell hervorheben */
.checkbox-tile:has(input:checked) {
  border-color: var(--form-border-focus);
  background: rgba(76, 139, 245, 0.12);
}

/* Sonderrolle optisch markiert */
.checkbox-tile.highlight {
  border-style: dashed;
}

/* ============================================
   CUSTOM SELECT (Public + Admin)
============================================ */

.custom-select {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-select-trigger {
  padding: 10px 14px;
  background: var(--form-bg);
  border: 1px solid var(--form-border);
  border-radius: 10px;
  color: var(--form-text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  position: relative;
}

.custom-select-trigger::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--form-text);
  border-bottom: 2px solid var(--form-text);
  transform: translateY(-60%) rotate(45deg);
  pointer-events: none;
  transition: transform 0.2s ease;
  opacity: 0.8;
}
.custom-select-trigger:hover {
  background: var(--form-bg-hover);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--form-border-focus);
  box-shadow: 0 0 0 3px rgba(76, 139, 245, 0.35);
}

.custom-select.open .custom-select-trigger::after {
  transform: translateY(-40%) rotate(-135deg);
}

.custom-select-options {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--form-border);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  z-index: 20;
}

.custom-select.open .custom-select-options {
  display: block;
}

.custom-select-option {
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.custom-select-option:hover {
  background: rgba(76, 139, 245, 0.1);
}

.custom-select-option.selected {
  background: rgba(76, 139, 245, 0.2);
}

/* ============================================
   MODAL – modern, soft, elevated
============================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  display: none;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.25s ease;
  z-index: 9999;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  padding: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);
  transform: scale(0.97);
  animation: modalPop 0.22s ease forwards;
  max-height: 85vh;
  overflow-y: auto;
}

/* Modal Header */
.modal-header {
  padding: 16px 22px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--table-divider);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;

  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Title */
.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* Close Button modern */
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;

  border-radius: 8px;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);

  cursor: pointer;
  font-size: 22px;
  line-height: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  background: var(--form-bg-hover);
  color: var(--text);
}

/* Body */
.modal form,
.modal-body {
  padding: 22px;
  padding-top: 18px;
}

/* Footer */
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 22px;
  border-top: 1px solid var(--table-divider);
}

.modal-form {
  overflow: visible;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalPop {
  0% {
    transform: scale(0.97);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   FOOTER
============================================ */

.public-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--footer-bg);
  color: var(--footer-text);
  text-align: center;
  padding: 12px 0;
  border-top: 1px solid var(--footer-border);
  font-size: 0.9rem;
}

/* ============================================
   TOAST NOTIFICATIONS
============================================ */

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.25s ease, toast-out 0.25s ease 3.25s forwards;
}

/* Farben */
.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--error);
}

.toast-info {
  background: var(--info);
}

/* Animationen */
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}
