/* =====================================================================
   Praxis-Board – Design-System (modern, token-basiert, offline-tauglich)
   Schriften lokal eingebunden (LAN ohne Internet nutzbar).
   ===================================================================== */

@font-face {
  font-family: 'Inter';
  src: url('../vendor/fonts/inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: 'Sora';
  src: url('../vendor/fonts/sora-latin.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
  font-style: normal;
}

/* ---- Tokens: Hell ---- */
:root {
  /* Markenakzent (per Einstellungen überschreibbar) */
  --accent: #15a06e;
  --accent-2: #0f7d57;          /* tiefere Variante für Verläufe/aktiv */
  --accent-soft: #e6f5ee;       /* zarter Hintergrund */
  --accent-text: #0c6b49;       /* Akzentfarbe auf hellem Grund (lesbar) */
  --on-accent: #ffffff;

  /* Neutrale (leicht kühle Slate-Töne statt Reingrau) */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --surface-3: #e7ebef;
  --text: #131720;
  --text-soft: #59616e;
  --text-faint: #8b94a1;
  --border: #e6e9ee;
  --border-strong: #d3d8e0;
  --danger: #e1483a;
  --danger-soft: #fdecea;
  --warn: #d98a1f;

  /* Form */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Tiefe: weiche, mehrlagige Schatten */
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05), 0 1px 1px rgba(17, 24, 39, .04);
  --shadow: 0 2px 4px rgba(17, 24, 39, .05), 0 6px 16px -4px rgba(17, 24, 39, .10);
  --shadow-lg: 0 12px 28px -8px rgba(17, 24, 39, .22), 0 4px 10px -4px rgba(17, 24, 39, .12);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);

  /* Schrift */
  --font-display: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font: var(--font-sans);

  --topbar-h: 60px;
}

/* ---- Tokens: Dunkel ---- */
:root[data-theme="dark"] {
  --accent-soft: #11352a;
  --accent-text: #5fd6a6;
  --bg: #0d1014;
  --surface: #161b22;
  --surface-2: #1d242d;
  --surface-3: #252e39;
  --text: #e8ecf2;
  --text-soft: #a3adba;
  --text-faint: #6e7884;
  --border: #262e38;
  --border-strong: #36404c;
  --danger: #f0675a;
  --danger-soft: #2a1715;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 2px 6px rgba(0, 0, 0, .4), 0 8px 20px -6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, .65);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.006em;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* Sichtbarer Fokus nur per Tastatur */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.topbar__brand .dot {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--on-accent);
  box-shadow: 0 2px 8px -1px color-mix(in srgb, var(--accent) 55%, transparent);
}
.topbar__brand .dot svg { width: 17px; height: 17px; }

/* Navigation als segmentierte Pille */
.topbar__nav {
  display: flex; gap: 2px; margin-left: 6px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-pill);
}
.navlink {
  appearance: none; border: 0; background: transparent;
  font: inherit; font-weight: 500; color: var(--text-soft);
  padding: 7px 15px; border-radius: var(--radius-pill);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: color .15s, background .15s, box-shadow .15s;
}
.navlink svg { width: 17px; height: 17px; stroke-width: 2; }
.navlink:hover { color: var(--text); }
.navlink.is-active {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}
.topbar__spacer { flex: 1; }

/* Zahnrad-Button (Einstellungen) */
.iconbtn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: var(--text-soft); padding: 8px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.iconbtn svg { width: 19px; height: 19px; stroke-width: 1.8; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn.is-active { background: var(--accent-soft); color: var(--accent-text); }

/* Benutzer-Menü + Dropdown */
.user-menu-wrap { position: relative; }
.topbar__user {
  appearance: none; border: 0; font: inherit; font-weight: 500; color: var(--text);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 5px 8px 5px 5px; border-radius: var(--radius-pill);
  background: transparent; transition: background .15s;
}
.topbar__user:hover { background: var(--surface-2); }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80;
  width: 248px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
  animation: pb-pop .15s cubic-bezier(.2,.8,.25,1);
}
.dropdown-label, .dropdown-loading { font-size: 11.5px; color: var(--text-faint); padding: 8px 10px 4px; text-transform: uppercase; letter-spacing: .03em; }
.dropdown-item {
  appearance: none; border: 0; background: transparent; font: inherit; width: 100%;
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.is-current { background: var(--accent-soft); }
.dropdown-item__text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.dropdown-item__k { font-weight: 500; }
.dropdown-item__n { font-size: 12px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item--action { color: var(--text-soft); font-weight: 500; }
.dropdown-ic { width: 26px; text-align: center; font-size: 16px; color: var(--text-faint); }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* Farbauswahl (z. B. neuer Mitarbeiter) */
.color-row { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.color-swatch.is-active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.color-swatch.is-taken { opacity: .32; cursor: not-allowed; position: relative; }
.color-swatch.is-taken::after {
  content: '✕'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

/* ---- Verbindungsstatus-Pille ---- */
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-soft);
  font-size: 12.5px; font-weight: 500; white-space: nowrap; user-select: none;
}
.sync-pill .sync-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none;
}
.sync-pill[data-state="online"] { color: var(--accent-text); background: var(--accent-soft); }
.sync-pill[data-state="online"] .sync-dot { background: var(--accent); }
.sync-pill[data-state="syncing"] .sync-dot { background: var(--warn); animation: sync-pulse 1s ease-in-out infinite; }
.sync-pill[data-state="offline"] .sync-dot { background: var(--text-faint); }
@keyframes sync-pulse { 50% { opacity: .35; } }
/* ===== Handy-Layout (greift nur < 640px; Desktop bleibt unverändert) ===== */
@media (max-width: 640px) {
  .sync-pill .sync-text { display: none; }

  /* Kompakte Kopfzeile, damit alles in eine Zeile passt */
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar__brand { font-size: 0; gap: 0; }              /* "Praxis-Board"-Text aus, Logo bleibt */
  .topbar__nav { margin-left: 0; padding: 3px; }
  .navlink { font-size: 0; padding: 7px 11px; gap: 0; } /* Navigation nur als Icons */
  .navlink svg { width: 19px; height: 19px; }
  #userKuerzel { display: none; }                       /* im Benutzer-Menü nur der Avatar */
  .topbar__user { padding: 4px; gap: 4px; }

  /* Weniger Rand für mehr Platz */
  #app-view { padding: 12px; }

  /* Formularfelder untereinander statt nebeneinander */
  .row { flex-direction: column; gap: 12px; }

  /* Dialoge dichter an den Rand */
  .modal-overlay { padding: 4vh 10px; }
}

/* ---- Avatar ---- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 12px; flex: none;
  user-select: none; letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), 0 1px 2px rgba(0, 0, 0, .12);
}
.avatar--sm { width: 26px; height: 26px; font-size: 11px; }
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }

/* ---- Buttons ---- */
.btn {
  appearance: none; font: inherit; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  padding: 8px 15px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.btn svg { width: 16px; height: 16px; stroke-width: 2; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  border-color: transparent; color: var(--on-accent);
  box-shadow: 0 2px 10px -2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.btn--primary:hover { filter: brightness(1.07); background: linear-gradient(145deg, var(--accent), var(--accent-2)); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-soft); box-shadow: none; }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { color: var(--danger); border-color: transparent; background: transparent; box-shadow: none; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--danger-solid { color: #fff; background: var(--danger); border-color: transparent; }
.btn--danger-solid:hover { filter: brightness(1.06); background: var(--danger); }
.btn--sm { padding: 5px 11px; font-size: 13px; }
.btn--icon { padding: 8px; }

/* ---- Formfelder ---- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > label { font-size: 12.5px; color: var(--text-soft); font-weight: 500; letter-spacing: 0; }
.input, .select, .textarea {
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: var(--ring);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.row { display: flex; gap: 14px; }
.row > * { flex: 1; }

/* ---- App-Layout ---- */
/* Füllt die volle Resthöhe unter der Topbar; die aktive Ansicht dehnt sich
   darin aus, sodass Kalender/Board nicht in der oberen Hälfte „kleben". */
#app-view {
  flex: 1;
  min-height: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
#app-view > div:not(.hidden) { flex: 1; min-height: 0; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: color-mix(in srgb, #0a0d12 55%, transparent);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px; z-index: 100; overflow-y: auto;
  animation: pb-fade .15s ease;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 460px;
  border: 1px solid var(--border);
  animation: pb-pop .18s cubic-bezier(.2, .8, .25, 1);
}
.modal--wide { max-width: 580px; }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal__head h3 { margin: 0; font-size: 17px; }
.modal__body { padding: 20px; }
.modal__foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 15px 20px; border-top: 1px solid var(--border);
}
@keyframes pb-fade { from { opacity: 0; } }
@keyframes pb-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---- Toasts ---- */
#pb-toasts {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
}
.pb-toast {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow-lg); min-width: 230px; max-width: 360px;
  font-weight: 500;
  opacity: 0; transform: translateY(10px) scale(.98); transition: opacity .2s, transform .2s;
}
.pb-toast.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.pb-toast--success { border-left-color: var(--accent); }
.pb-toast--danger { border-left-color: var(--danger); }

/* ---- Hilfsklassen ---- */
.pb-confirm__msg { margin: 2px 0 0; font-size: 14.5px; line-height: 1.55; color: var(--text); }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.hidden { display: none !important; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.stack { display: flex; flex-direction: column; }
.center-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}

/* Dezente, moderne Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
