/* ============================================================
   SIUT ANFORDERUNGSMANAGEMENT – Design System
   Themes: dark (Standard) | light | auto (System)
   Fonts:  Syne (Headlines) + DM Mono (Data/UI)
   ============================================================ */

/* ---- Dark Theme (Standard) ---- */
:root,
[data-theme="dark"] {
  --c-bg: #0d0f12;
  --c-surface: #13161b;
  --c-surface2: #1a1e25;
  --c-border: #262c36;
  --c-border2: #313844;

  --c-text: #e8eaed;
  --c-text2: #9aa5b4;
  --c-text3: #5c6878;

  --c-accent: #3b82f6;
  --c-accent2: #2563eb;
  --c-accent-glow: rgba(59, 130, 246, .18);

  --c-green: #22c55e;
  --c-amber: #f59e0b;
  --c-red: #ef4444;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .5);
}

/* ---- Light Theme ---- */
[data-theme="light"] {
  --c-bg: #f0f2f5;
  --c-surface: #ffffff;
  --c-surface2: #f5f7fa;
  --c-border: #d8dde6;
  --c-border2: #c4cad6;

  --c-text: #111827;
  --c-text2: #4b5563;
  --c-text3: #343942;

  --c-accent: #2563eb;
  --c-accent2: #1d4ed8;
  --c-accent-glow: rgba(37, 99, 235, .12);

  --c-green: #16a34a;
  --c-amber: #d97706;
  --c-red: #dc2626;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .10);
}

/* ---- System-Preference Fallback (wenn theme="auto") ---- */
@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --c-bg: #f0f2f5;
    --c-surface: #ffffff;
    --c-surface2: #f5f7fa;
    --c-border: #d8dde6;
    --c-border2: #c4cad6;
    --c-text: #111827;
    --c-text2: #4b5563;
    --c-text3: #9ca3af;
    --c-accent: #2563eb;
    --c-accent2: #1d4ed8;
    --c-accent-glow: rgba(37, 99, 235, .12);
    --c-green: #16a34a;
    --c-amber: #d97706;
    --c-red: #dc2626;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .10);
  }
}

:root {
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --f-sans: 'Syne', system-ui, sans-serif;
  --f-mono: 'DM Mono', 'Cascadia Code', monospace;
  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--f-mono);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

/* ---- Typography ---- */
h1,
h2,
h3,
h4 {
  font-family: var(--f-sans);
  font-weight: 700;
  line-height: 1.2;
  color: var(--c-text);
}

h1 {
  font-size: 1.8rem;
  font-weight: 800;
}

h2 {
  font-size: 1.3rem;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
}

label {
  display: block;
  font-size: .75rem;
  font-weight: 500;
  color: var(--c-text2);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: .35rem;
}

/* ---- Inputs ---- */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
textarea,
select {
  width: 100%;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: .55rem .75rem;
  color: var(--c-text);
  font-family: var(--f-mono);
  font-size: .875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-glow);
}

input:hover:not(:focus),
textarea:hover:not(:focus),
select:hover:not(:focus) {
  border-color: var(--c-border2);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

select option {
  background: var(--c-surface2);
  color: var(--c-text);
}

/* Select-Pfeil */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
  padding-right: 2rem;
}

/* ---- Toggle Switch ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid var(--c-border);
  gap: 1rem;
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-label {
  font-size: .85rem;
  color: var(--c-text);
  flex: 1;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--c-border2);
  border-radius: 22px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--c-text2);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}

.toggle input:checked+.toggle-slider {
  background: var(--c-accent2);
}

.toggle input:checked+.toggle-slider::after {
  transform: translateX(18px);
  background: #fff;
}

/* ---- Tristate ---- */
.tristate {
  display: flex;
  gap: .3rem;
}

.tristate button {
  flex: 1;
  padding: .3rem .5rem;
  font-family: var(--f-mono);
  font-size: .75rem;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  color: var(--c-text2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.tristate button[data-active="true"] {
  background: var(--c-accent2);
  border-color: var(--c-accent);
  color: #fff;
}

.tristate button:hover:not([data-active="true"]) {
  border-color: var(--c-accent);
  color: var(--c-text);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1.1rem;
  font-family: var(--f-sans);
  font-size: .85rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}

.btn-primary:hover {
  background: var(--c-accent2);
}

.btn-ghost {
  background: transparent;
  color: var(--c-text2);
  border-color: var(--c-border2);
}

.btn-ghost:hover {
  background: var(--c-surface2);
  color: var(--c-text);
}

.btn-danger {
  background: transparent;
  color: var(--c-red);
  border-color: var(--c-red);
}

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

.btn-sm {
  padding: .3rem .7rem;
  font-size: .78rem;
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ---- Cards ---- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
}

.card-section {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  background: var(--c-surface2);
  transition: background var(--transition), border-color var(--transition);
}

.card-section-title {
  font-family: var(--f-sans);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: .85rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.card-section-title::before {
  content: '';
  width: 3px;
  height: 12px;
  background: var(--c-accent);
  border-radius: 2px;
  display: inline-block;
}

/* ---- Form grid ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-field {
  display: flex;
  flex-direction: column;
}

/* ---- Divider ---- */
.divider {
  height: 1px;
  background: var(--c-border);
  margin: 1.25rem 0;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--c-border2);
  border-radius: 3px;
}

/* ---- Utilities ---- */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: .5rem;
}

.gap-3 {
  gap: .75rem;
}

.gap-4 {
  gap: 1rem;
}

.mt-1 {
  margin-top: .25rem;
}

.mt-2 {
  margin-top: .5rem;
}

.mt-4 {
  margin-top: 1rem;
}

.text-sm {
  font-size: .8rem;
}

.text-muted {
  color: var(--c-text2);
}

.text-xs {
  font-size: .72rem;
  color: var(--c-text3);
  letter-spacing: .04em;
}

.font-mono {
  font-family: var(--f-mono);
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade {
  animation: fadeIn .25s ease both;
}

.animate-slide {
  animation: slideIn .2s ease both;
}

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  padding: .65rem 1rem;
  background: var(--c-surface2);
  border: 1px solid var(--c-border2);
  border-radius: var(--r-md);
  font-size: .82rem;
  box-shadow: var(--shadow-md);
  animation: fadeIn .2s ease both;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--c-text);
}

.toast.success {
  border-color: var(--c-green);
}

.toast.error {
  border-color: var(--c-red);
}

/* ---- Theme Transition (sanftes Umschalten) ---- */
*,
*::before,
*::after {
  transition-property: background-color, border-color, color;
  transition-duration: 200ms;
  transition-timing-function: ease;
}

/* Ausnahme: Animationen nicht durch Theme-Transition stören */
.animate-fade,
.animate-slide {
  transition: none;
}