/*
 * SB-Terminal Design System
 * --------------------------------------------------
 * Dieses Stylesheet enthält alle Design-Tokens, Layout-Definitionen
 * und Komponenten-Styles für das SB-Terminal Web-Frontend.
 * Struktur:
 *   1. Design Tokens
 *   2. Grundlegendes Layout & Typografie
 *   3. Navigation & Header
 *   4. Container & Karten
 *   5. Auswahl-Panel & Kalender-Erweiterungen
 *   6. Formularelemente & Validierung
 *   7. Statusmeldungen & Feedback
 *   8. Authentifizierungs-Layout
 *   9. Utilities & Responsives Verhalten
 */

/* --------------------------------------------------
 * 1. Design Tokens
 * -------------------------------------------------- */
:root {
  /* Farbpalette */
  --body-bg: #eef2f8;
  --content-bg: #f9fbff;
  --surface-bg: #ffffff;
  --border-subtle: #d4dceb;
  --border-strong: #c2cce0;
  --text-primary: #23304f;
  --text-secondary: #5d6a87;
  --accent: #0078d4;
  --accent-strong: #005ea8;
  --accent-soft: rgba(0, 120, 212, 0.12);
  --danger: #c0392b;
  --danger-soft: rgba(192, 57, 43, 0.12);
  --success: #1e7e34;
  --success-soft: rgba(30, 126, 52, 0.12);
  --warning: #d48b00;
  --warning-soft: rgba(212, 139, 0, 0.12);

  /* Typografie */
  --font-base: 'Segoe UI', 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
  --font-size-base: 0.95rem;
  --font-size-heading-lg: 1.65rem;
  --font-size-heading-md: 1.25rem;
  --font-size-heading-sm: 1.05rem;
  --font-size-meta: 0.82rem;

  /* Abstände & Ecken */
  --space-xs: 0.35rem;
  --space-sm: 0.65rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --radius-card: 14px;
  --radius-pill: 999px;
  --radius-sm: 10px;

  /* Schatten & Transition */
  --shadow-base: 0 6px 18px rgba(28, 38, 67, 0.14);
  --shadow-hover: 0 10px 28px rgba(28, 38, 67, 0.22);
  --shadow-inset: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  --transition: 180ms ease;

  /* Layout */
  --sidebar-width: 240px;
  --max-content-width: 1240px;
}

/* Reduziertes Bewegungsprofil */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------
 * 2. Grundlegendes Layout & Typografie
 * -------------------------------------------------- */
* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--body-bg);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a:hover,
a:focus {
  color: var(--accent-strong);
  text-decoration: underline;
}

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

h1, .h1 { font-size: var(--font-size-heading-lg); }
h2, .h2 { font-size: var(--font-size-heading-md); }
h3, .h3 { font-size: var(--font-size-heading-sm); text-transform: uppercase; letter-spacing: 0.04em; }

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

.main-container {
  width: min(100% - 2rem, var(--max-content-width));
  margin: 0 auto;
  padding: var(--space-lg) 0;
}

section,
.card,
.surface-panel {
  background: var(--surface-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-base);
  border: 1px solid transparent;
}

/* --------------------------------------------------
 * 3. Navigation & Header
 * -------------------------------------------------- */
.sb-nav {
  background: linear-gradient(175deg, #1b2539, #314b73);
  color: #f0f4ff;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 24px rgba(15, 22, 42, 0.32);
}

.sb-nav .navbar {
  color: inherit;
  padding: 0;
}

.sb-nav .navbar-brand {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: #f9fbff;
  transition: opacity var(--transition);
}

.sb-nav .navbar-brand:hover {
  opacity: 0.85;
}

.sb-nav .nav-link {
  color: rgba(249, 251, 255, 0.72);
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color var(--transition), color var(--transition);
}

.sb-nav .nav-link:hover,
.sb-nav .nav-link:focus {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.sb-nav .nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.sb-nav .navbar-text {
  color: rgba(249, 251, 255, 0.8);
  font-size: 0.9rem;
}

.sb-nav .btn-outline-primary {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.45);
  background: transparent;
}

.sb-nav .btn-outline-primary:hover,
.sb-nav .btn-outline-primary:focus {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.6);
}

/* --------------------------------------------------
 * 4. Container & Karten
 * -------------------------------------------------- */
.card {
  border: 1px solid rgba(210, 218, 235, 0.6);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface-bg);
  box-shadow: var(--shadow-base);
}

.card-header {
  background: var(--accent-soft);
  border-bottom: 1px solid rgba(0, 120, 212, 0.16);
  padding: var(--space-md) var(--space-lg);
}

.card-body {
  padding: var(--space-lg);
}

.surface-panel {
  padding: var(--space-lg);
}

.surface-panel + .surface-panel {
  margin-top: var(--space-lg);
}

/* Utility shell for forms inside cards */
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.5rem;
}

/* --------------------------------------------------
 * 5. Auswahl-Panel & Kalender-Erweiterungen
 * -------------------------------------------------- */
.selection-panel {
  background: var(--surface-bg);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-base);
  padding: var(--space-lg);
}

.selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.selection-header h5 {
  font-size: 1.05rem;
  color: var(--text-primary);
}

.selection-items {
  border: 1px dashed rgba(0, 120, 212, 0.25);
  border-radius: var(--radius-sm);
  min-height: 140px;
  padding: var(--space-md);
  background: var(--content-bg);
}

.selection-items .empty-state {
  color: var(--text-secondary);
  text-align: center;
  padding: var(--space-lg) 0;
  font-size: 0.9rem;
}

.selection-items .empty-state svg {
  opacity: 0.45;
}

.selection-panel .border-top {
  border-color: rgba(0, 120, 212, 0.16) !important;
}

#calendar {
  padding: var(--space-md);
}

.fc .fc-toolbar-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.fc .fc-button {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 120, 212, 0.4);
  background: var(--accent);
  color: #ffffff;
  padding: 0.35rem 0.7rem;
  font-size: 0.92rem;
  transition: background-color var(--transition), box-shadow var(--transition);
}

.fc .fc-button:hover,
.fc .fc-button:focus {
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.2);
}

.fc .fc-daygrid-event,
.fc .fc-h-event {
  color: var(--text-primary);
  background: rgba(0, 120, 212, 0.08);
  border: 1px solid rgba(0, 120, 212, 0.22);
  border-radius: var(--radius-sm);
  padding-inline: 0.35rem;
}

.fc .fc-daygrid-event .ev-card {
  padding: 0.5rem;
  gap: var(--space-sm);
  background: rgba(0, 120, 212, 0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 120, 212, 0.22);
}

.fc .fc-daygrid-event .ev-card__title {
  font-size: 0.95rem;
}

.fc .fc-daygrid-event .ev-card__meta {
  font-size: 0.78rem;
}

.fc .fc-daygrid-event .ev-section-title {
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}

.fc .fc-daygrid-event .ev-row {
  gap: 0.45rem;
}

.fc .fc-daygrid-event .media-grid {
  gap: 0.4rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.fc .fc-daygrid-event .media-grid .form-check {
  padding: 0.35rem 0.45rem;
}

.fc .fc-daygrid-event .media-grid .form-check-label {
  font-size: 0.83rem;
}

.fc .fc-daygrid-event .btn-all {
  padding: 0.35rem 0.6rem;
}

.fc .fc-daygrid-event .btn-all svg {
  width: 13px;
  height: 13px;
}

.ev-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.ev-card__header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ev-card__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.ev-card__meta {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.ev-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.ev-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ev-row--media {
  gap: 0.75rem;
}

.ev-row--actions {
  gap: 0.75rem;
}

.ev-row--switch .form-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.ev-row--switch .form-check-input {
  margin-top: 0;
}

.ev-row--actions .btn-all {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.ev-section-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.media-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.media-grid .form-check {
  margin: 0;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--content-bg);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.media-grid .form-check.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.media-grid .form-check:not(.disabled):hover,
.media-grid .form-check:not(.disabled):focus-within {
  border-color: rgba(0, 120, 212, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.16);
  background: rgba(0, 120, 212, 0.08);
}

.media-grid .form-check-input {
  margin-top: 0;
  margin-right: 0;
}

.media-grid .form-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.fc .fc-popover {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-base);
  border: 1px solid var(--border-subtle);
  background: var(--surface-bg);
  overflow: hidden;
  min-width: 240px;
}

.fc .fc-popover.fc-popover--centered {
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
  right: auto !important;
  bottom: auto !important;
  width: min(640px, calc(100vw - 24px)) !important;
  max-width: min(640px, calc(100vw - 24px)) !important;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
}

.fc .fc-popover.fc-popover--centered .fc-popover-body {
  overflow-y: auto;
}

.fc .fc-popover.fc-popover--flip {
  transform-origin: top right;
}

.fc .fc-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--content-bg);
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
  color: var(--text-primary);
}

.fc .fc-popover-title {
  font-size: 0.95rem;
}

.fc .fc-popover-close {
  font-size: 1rem;
  line-height: 1;
  color: var(--text-secondary);
  opacity: 0.8;
  transition: opacity var(--transition);
}

.fc .fc-popover-close:hover,
.fc .fc-popover-close:focus {
  opacity: 1;
}

.fc .fc-popover-body {
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-bg);
}

.fc .fc-popover.fc-popover--compact .fc-popover-body {
  padding: var(--space-sm);
}

.fc .fc-more-popover .ev-card {
  padding: var(--space-sm);
  background: rgba(0, 120, 212, 0.04);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 120, 212, 0.18);
}

.fc .fc-more-popover .ev-row {
  gap: 0.5rem;
}

.fc .fc-more-popover .ev-row--media {
  gap: 0.5rem;
}

.fc .fc-more-popover .media-grid {
  gap: 0.45rem;
}

.fc .fc-popover.fc-popover--compact .media-grid {
  grid-template-columns: 1fr;
}

.fc .fc-popover.fc-popover--compact .ev-row {
  gap: 0.4rem;
}

.fc .fc-more-popover .btn-all svg {
  margin-right: 0;
}

.fc .fc-more-popover .btn-all {
  gap: 0.4rem;
}

.fc .fc-multimonth .fc-daygrid-event .ev-card {
  padding: 0.35rem;
  gap: 0.35rem;
}

.fc .fc-multimonth .fc-daygrid-event .ev-card__title {
  font-size: 0.88rem;
}

.fc .fc-multimonth .fc-daygrid-event .ev-card__meta {
  font-size: 0.72rem;
}

.fc .fc-multimonth .fc-daygrid-event .ev-section-title {
  font-size: 0.7rem;
}

.fc .fc-multimonth .fc-daygrid-event .media-grid {
  grid-template-columns: 1fr;
  gap: 0.3rem;
}

.fc .fc-multimonth .fc-daygrid-event .media-grid .form-check {
  padding: 0.3rem 0.35rem;
}

.fc .fc-multimonth .fc-daygrid-event .media-grid .form-check-label {
  font-size: 0.75rem;
}

.fc .fc-multimonth .fc-daygrid-event .form-check-input {
  width: 1rem;
  height: 1rem;
}

.fc .fc-multimonth .fc-daygrid-event .btn-all {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.fc .fc-more-popover .fc-event {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.fc .fc-more-popover .fc-event .fc-event-main {
  white-space: normal;
}

.fc .fc-more-popover .fc-event:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------
 * 6. Formularelemente & Validierung
 * -------------------------------------------------- */
label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.form-control,
.form-select,
input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-bg);
  color: var(--text-primary);
  padding: 0.7rem 0.85rem;
  font-size: 0.94rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.18);
  outline: none;
}

.form-control::placeholder,
textarea::placeholder {
  color: rgba(35, 48, 79, 0.45);
}

.form-check-input {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 0.4rem;
  border-color: var(--border-subtle);
}

.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.18);
}

.form-check-label {
  color: var(--text-secondary);
}

.password-input-wrapper {
  position: relative;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition);
}

.password-toggle:hover,
.password-toggle:focus {
  color: var(--accent);
}

.input-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

.input-hint.error {
  color: var(--danger);
}

.input-hint.success {
  color: var(--success);
}

.input-missing {
  border-color: var(--danger) !important;
  background: var(--danger-soft) !important;
}

.input-found {
  border-color: var(--success) !important;
  background: var(--success-soft) !important;
}

.dropzone {
  border: 2px dashed rgba(0, 120, 212, 0.3);
  border-radius: var(--radius-card);
  background: rgba(0, 120, 212, 0.04);
  padding: var(--space-xl);
  text-align: center;
  transition: border-color var(--transition), background-color var(--transition);
}

.dropzone:hover,
.dropzone:focus {
  border-color: var(--accent);
  background: rgba(0, 120, 212, 0.08);
}

/* --------------------------------------------------
 * 7. Statusmeldungen & Feedback
 * -------------------------------------------------- */
.btn,
button,
input[type="submit"],
input[type="button"] {
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.btn-primary,
button.btn-primary,
input[type="submit"].btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.btn-secondary,
button.btn-secondary {
  background: #ffffff;
  border-color: rgba(0, 120, 212, 0.3);
  color: var(--accent);
}

.btn-secondary:hover,
.btn-secondary:focus {
  background: rgba(0, 120, 212, 0.08);
  box-shadow: none;
}

.btn-link {
  color: var(--accent);
  font-weight: 500;
}

.btn-link:hover,
.btn-link:focus {
  color: var(--accent-strong);
  text-decoration: underline;
}

.alert {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: var(--space-md);
}

.alert-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(192, 57, 43, 0.3);
}

.alert-success {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(30, 126, 52, 0.3);
}

.toast {
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid rgba(0, 120, 212, 0.18);
  box-shadow: var(--shadow-base);
}

.toast-header {
  font-weight: 600;
  padding: var(--space-sm) var(--space-md);
}

.progress {
  background: rgba(0, 120, 212, 0.08);
  border-radius: var(--radius-pill);
}

.progress-bar {
  border-radius: var(--radius-pill);
}

.badge.bg-primary {
  background: var(--accent);
  color: #ffffff;
  border-radius: var(--radius-pill);
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* --------------------------------------------------
 * 8. Authentifizierungs-Layout
 * -------------------------------------------------- */
body.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #21314d, #47679a);
}

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-md);
  background: linear-gradient(160deg, #21314d, #47679a);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-hover);
  padding: var(--space-xl);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--accent);
  margin: 0 auto var(--space-lg);
  box-shadow: inset 0 0 0 1px rgba(0, 120, 212, 0.18);
}

.login-card .btn-primary {
  width: 100%;
  padding: 0.75rem 1.2rem;
}

.modal-content {
  border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-base);
}

.modal-header {
  background: var(--content-bg);
  border-bottom: 1px solid rgba(0, 120, 212, 0.16);
}

.modal-footer {
  border-top: 1px solid rgba(0, 120, 212, 0.16);
}

/* --------------------------------------------------
 * 9. Utilities & Responsives Verhalten
 * -------------------------------------------------- */
.text-muted { color: var(--text-secondary) !important; }
.fw-medium { font-weight: 600; }
.small { font-size: 0.82rem; }

.button-row {
  display: flex;
  gap: 0.75rem;
}

.button-row.start {
  justify-content: flex-start;
}

@media (max-width: 960px) {
  .sb-nav .navbar {
    padding: var(--space-sm) 0;
  }

  .sb-nav .nav-link {
    padding-inline: var(--space-sm);
  }

  .selection-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  .main-container {
    padding: var(--space-md) 0 var(--space-lg);
  }

  .card,
  .selection-panel {
    padding: var(--space-md);
  }

  .card-body,
  .card-header {
    padding: var(--space-md);
  }

  .login-card {
    padding: var(--space-lg);
  }

  .button-row {
    flex-direction: column;
  }

  .btn,
  button,
  input[type="submit"],
  input[type="button"] {
    width: 100%;
  }
}
