/* ═══════════════════════════════════════════════════════════════════════════
   RR Team — global.css
   Zentrale Styles für alle Seiten.
   Einbinden: <link rel="stylesheet" href="/css/global.css">
   Danach nur noch seitenspezifische Styles im jeweiligen <style>-Block.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── CSS-Variablen ───────────────────────────────────────────────────────────── */
:root {
  /* Farben */
  --accent:      #D85A30;
  --accent-d:    #b8481f;
  --bg:          #f2f2f7;
  --card:        #ffffff;
  --border:      #e5e5ea;
  --text:        #111111;
  --muted:       #8e8e93;
  --green:       #34c759;
  --green-d:     #1b5e20;
  --red:         #ff3b30;
  --orange:      #f59e0b;
  --blue:        #007aff;

  /* Abstände & Radien */
  --r:           18px;
  --r-sm:        10px;
  --r-md:        14px;

  /* Schatten */
  --shadow:      0 10px 30px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 20px 40px rgba(16, 24, 40, 0.08);

  /* Safe Areas (iOS) */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bot:    env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);
}

/* ── Basis ───────────────────────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
}

body {
  font-family: Tahoma, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Typografie ──────────────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 800; }
h3 { font-size: 1rem;    font-weight: 700; }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  opacity: .8;
}

/* ── Karten ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 16px;
  font-weight: 800;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Farbige linke Kanten (für Status-Karten) */
.card.bar-orange { --card-bar: var(--accent);  border-left: 4px solid var(--card-bar); }
.card.bar-green  { --card-bar: #34c759;        border-left: 4px solid var(--card-bar); }
.card.bar-blue   { --card-bar: #007aff;        border-left: 4px solid var(--card-bar); }
.card.bar-red    { --card-bar: #ff3b30;        border-left: 4px solid var(--card-bar); }
.card.bar-purple { --card-bar: #af52de;        border-left: 4px solid var(--card-bar); }
.card.bar-teal   { --card-bar: #30b0c7;        border-left: 4px solid var(--card-bar); }
.card.bar-yellow { --card-bar: #f59e0b;        border-left: 4px solid var(--card-bar); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  border: none;
  font-size: 14px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover    { opacity: .88; }
.btn:active   { opacity: .8; transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-d) 100%);
  color: #fff;
}
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-danger {
  background: #fdecea;
  color: #c62828;
}
.btn-danger:hover { background: #ffebeb; }

.btn-success {
  background: #e8f5e9;
  color: var(--green-d);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  border-radius: 12px;
  width: 100%;
}

/* ── Formulare ───────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
}
.form-textarea {
  resize: none;
  min-height: 80px;
}

.form-error {
  color: var(--red);
  font-size: 0.73rem;
  font-weight: 600;
  min-height: 18px;
  margin-top: 4px;
}

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rr-spin .6s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}

.spinner-dark {
  border-color: rgba(0, 0, 0, .15);
  border-top-color: var(--text);
}

@keyframes rr-spin {
  to { transform: rotate(360deg); }
}

/* Ganzseitiger Ladescreen */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity .3s;
}
.page-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(30, 30, 30, .92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 1000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 500;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-bg.open {
  display: flex;
}

.modal-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.75rem;
  width: 100%;
  max-width: 420px;
  margin: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .2);
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 1.25rem;
}

.modal-field {
  margin-bottom: 12px;
}
.modal-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
}
.modal-field input,
.modal-field select,
.modal-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.modal-field input:focus,
.modal-field select:focus,
.modal-field textarea:focus {
  border-color: var(--accent);
}

.modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ── Badges / Status-Pillen ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-neu      { background: #fff3e0; color: #b45309; }
.badge-email    { background: #e3f2fd; color: #1565c0; }
.badge-erledigt { background: #e8f5e9; color: var(--green-d); }
.badge-warn     { background: #fff3e0; color: #b45309; }
.badge-error    { background: #fdecea; color: #c62828; }
.badge-info     { background: #e3f2fd; color: #1565c0; }

/* ── Tabellen ────────────────────────────────────────────────────────────────── */
.tbl-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #fafafa;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg);
}

/* ── Leere Zustände ──────────────────────────────────────────────────────────── */
.empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.empty-icon {
  display: block;
  font-size: 32px;
  margin-bottom: 8px;
}

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  font-family: inherit;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Suchfeld-Wrapper ────────────────────────────────────────────────────────── */
.search-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.search-wrap input,
.search-wrap select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.search-wrap input:focus,
.search-wrap select:focus {
  border-color: var(--accent);
}

/* ── Drop-Zone ───────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.drop-zone.over {
  border-color: var(--accent);
  background: #fff5f0;
}

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--muted); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--green-d); }
.text-danger  { color: #c62828; }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.fw-bold      { font-weight: 700; }
.fw-black     { font-weight: 800; }
.mt-1         { margin-top:  4px; }
.mt-2         { margin-top:  8px; }
.mt-3         { margin-top: 14px; }
.mt-4         { margin-top: 20px; }
.mb-1         { margin-bottom:  4px; }
.mb-2         { margin-bottom:  8px; }
.mb-3         { margin-bottom: 14px; }
.mb-4         { margin-bottom: 20px; }
.gap-1        { gap:  4px; }
.gap-2        { gap:  8px; }
.gap-3        { gap: 14px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.w-full       { width: 100%; }
.sr-only      { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── View Transitions ────────────────────────────────────────────────────────── */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: rr-page-out 130ms ease-out both;
}

::view-transition-new(root) {
  animation: rr-page-in 180ms cubic-bezier(.22,1,.36,1) both;
}

::view-transition-group(root) {
  animation-duration: 180ms;
}

::view-transition-image-pair(root) {
  isolation: auto;
}

@keyframes rr-page-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: .985; transform: translateY(2px); }
}

@keyframes rr-page-in {
  from { opacity: .96; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar (Webkit) ──────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Motion respektieren */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  body {
    animation: none !important;
    opacity: 1 !important;
    transition: none !important;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
}
