/* ==========================================================
   FYNBIZ · FYN.chat — geteilte Basis (Kunde + Host)
   Design-System übernommen aus fynbiz-kpi-dashboard
   ========================================================== */

@font-face { font-family: 'All Round Gothic'; src: url('../assets/fonts/AllRoundGothic-XLig.ttf');   font-weight: 300; font-display: swap; }
@font-face { font-family: 'All Round Gothic'; src: url('../assets/fonts/AllRoundGothic-Book.ttf');   font-weight: 400; font-display: swap; }
@font-face { font-family: 'All Round Gothic'; src: url('../assets/fonts/AllRoundGothic-Medium.ttf'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'All Round Gothic'; src: url('../assets/fonts/AllRoundGothic-Demi.ttf');   font-weight: 600; font-display: swap; }
@font-face { font-family: 'All Round Gothic'; src: url('../assets/fonts/AllRoundGothic-Bold.ttf');   font-weight: 700; font-display: swap; }

:root {
  --c-bg-0:   #041f23;
  --c-bg-1:   #063439;
  --c-bg-2:   #0a4750;
  --c-accent:   #125d7a;
  --c-accent-2: #1a7ba0;
  --c-bright:   #2fe0c9;
  --c-bright-dim: rgba(47,224,201,0.3);
  --c-gold:     #e6b768;
  --c-positive: #4ade80;
  --c-warning:  #f59e0b;
  --c-negative: #ff7a7a;

  --c-text-hi:       #f4fbfa;
  --c-text-readable: rgba(244,251,250,0.88);
  --c-text-mid:      rgba(244,251,250,0.60);
  --c-text-low:      rgba(244,251,250,0.38);

  --surface:         rgba(255,255,255,0.045);
  --surface-2:       rgba(255,255,255,0.075);
  --surface-border:  rgba(255,255,255,0.09);
  --surface-border-hi: rgba(255,255,255,0.16);

  --shadow-ambient: 0 30px 60px -20px rgba(0,0,0,0.55);
  --ease-out: cubic-bezier(0.16,1,0.3,1);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --font-brand: 'All Round Gothic', 'Inter', system-ui, sans-serif;
  --font-body:  system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

  /* Von tastaturHandling() gesetzt: sichtbare Viewport-Höhe (Mobile-Tastatur) */
  --vh: 100vh;
  --vv-offset: 0px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--c-text-hi);
  background: var(--c-bg-1);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.brand-title, .btn-primary, .btn-secondary, .btn-ghost, .btn-icon,
.section-label, .toast, label, h1, h2, h3 { font-family: var(--font-brand); }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Ambient background ── */
.bg-scene {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 90% at 82% -10%, #0f5d6e55 0%, transparent 55%),
    linear-gradient(160deg, var(--c-bg-0) 0%, var(--c-bg-1) 45%, #052a2f 100%);
}
.bg-blob { position: fixed; border-radius: 50%; filter: blur(80px); pointer-events: none; z-index: -1; }
.bg-blob.b1 { width:62vw; height:62vw; right:-18vw; top:-22vw; background: radial-gradient(circle at 35% 35%, var(--c-accent-2) 0%, transparent 70%); opacity:0.5; }
.bg-blob.b2 { width:46vw; height:46vw; left:-12vw; bottom:-16vw; background: radial-gradient(circle at 60% 40%, var(--c-bright) 0%, transparent 70%); opacity:0.14; }
.bg-mark { position: fixed; right: -4vw; bottom: -6vw; width: 34vw; opacity: 0.035; pointer-events: none; z-index: -1; }
.noise-veil {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Brand ── */
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand > img { height: 20px; width: auto; flex-shrink: 0; }
.brand-divider { width: 1px; height: 20px; background: var(--surface-border-hi); flex-shrink: 0; }
.brand-title { font-size: 1.05rem; font-weight: 400; letter-spacing: 0.01em; white-space: nowrap; }
.brand-title b { font-weight: 600; }
.brand-title i { font-style: italic; color: var(--c-bright); }

/* ── Buttons ── */
.btn-primary, .btn-secondary, .btn-ghost {
  font-size: 0.92rem; font-weight: 500; letter-spacing: 0.01em;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 13px 22px; min-height: 48px;
  cursor: pointer; transition: all 0.2s var(--ease-out);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--c-bright) 0%, #22c3ae 100%);
  color: #04262b; font-weight: 600;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 24px -8px var(--c-bright-dim); }
.btn-secondary { background: var(--surface-2); color: var(--c-text-hi); border-color: var(--surface-border-hi); }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.11); }
.btn-ghost { background: transparent; color: var(--c-text-mid); padding: 10px 14px; min-height: 40px; }
.btn-ghost:hover:not(:disabled) { color: var(--c-text-hi); background: var(--surface); }
.btn-primary:disabled, .btn-secondary:disabled, .btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-icon {
  background: var(--surface-2); border: 1px solid var(--surface-border-hi);
  color: var(--c-text-hi); border-radius: var(--radius-sm);
  width: 48px; height: 48px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s var(--ease-out);
}
.btn-icon:hover:not(:disabled) { background: rgba(255,255,255,0.11); }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-icon svg { width: 20px; height: 20px; }

/* ── Formularfelder ── */
.field-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field-label { font-size: 0.78rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-text-mid); }

input[type="text"], input[type="email"], input[type="date"], input[type="time"], textarea, select {
  width: 100%;
  font-family: var(--font-body); font-size: 1rem;
  color: var(--c-text-hi); background: rgba(0,0,0,0.22);
  border: 1px solid var(--surface-border-hi); border-radius: var(--radius-sm);
  padding: 14px 16px; min-height: 48px;
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--c-bright); background: rgba(0,0,0,0.32);
}
input::placeholder, textarea::placeholder { color: var(--c-text-low); }
textarea { resize: none; line-height: 1.5; }
select { appearance: none; cursor: pointer; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23f4fbfa' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.field-hint { font-size: 0.82rem; color: var(--c-text-mid); line-height: 1.5; }
.field-error { font-size: 0.85rem; color: var(--c-negative); line-height: 1.5; }

/* ── Card / Panel ── */
.card {
  background: var(--surface); border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg); padding: 26px;
  backdrop-filter: blur(14px); box-shadow: var(--shadow-ambient);
}

/* ── Pills / Badges ── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 500; letter-spacing: 0.03em;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--surface-border-hi);
  color: var(--c-text-mid); white-space: nowrap;
}
.pill-live   { color: var(--c-bright); border-color: var(--c-bright-dim); background: rgba(47,224,201,0.10); }
.pill-warten { color: var(--c-gold);   border-color: rgba(230,183,104,0.3); background: rgba(230,183,104,0.10); }
.pill-aktiv  { color: var(--c-positive); border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.10); }
.pill-fertig { color: var(--c-text-low); }
.pill-zu     { color: var(--c-negative); border-color: rgba(255,122,122,0.3); background: rgba(255,122,122,0.10); }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--c-bright);
  box-shadow: 0 0 0 0 var(--c-bright-dim); animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(47,224,201,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(47,224,201,0); }
  100% { box-shadow: 0 0 0 0 rgba(47,224,201,0); }
}

/* ── Vertrauenssignal ── */
.trust-note {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.82rem; color: var(--c-text-mid); line-height: 1.4;
}
.trust-note svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--c-bright); }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 200; max-width: calc(100vw - 32px);
  padding: 14px 22px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  background: rgba(6,52,57,0.97); color: var(--c-text-hi);
  border: 1px solid var(--surface-border-hi);
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  animation: toast-in 0.3s var(--ease-out);
}
.toast-fehler { border-color: rgba(255,122,122,0.45); color: #ffd9d9; }
.toast-ok     { border-color: var(--c-bright-dim); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(12px); } }

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.22); border-top-color: var(--c-bright);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lade-zustand {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 60px 20px; color: var(--c-text-mid); font-size: 0.92rem;
}

.leer-zustand {
  text-align: center; padding: 56px 24px;
  color: var(--c-text-mid); font-size: 0.95rem; line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════
   CHAT — von Kunden- und Host-Ansicht gemeinsam genutzt
   ══════════════════════════════════════════════════════════ */

.chat-shell {
  display: flex; flex-direction: column;
  height: var(--vh); max-height: var(--vh);
  max-width: 780px; margin: 0 auto;
}

.chat-kopf {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; flex-shrink: 0;
  background: rgba(4,31,35,0.75); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--surface-border);
}
.chat-kopf-mitte { flex: 1; min-width: 0; }
.chat-kopf-titel {
  font-family: var(--font-brand); font-size: 0.98rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-kopf-sub { font-size: 0.78rem; color: var(--c-text-mid); margin-top: 2px; }

.chat-verlauf {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 18px 8px;
  display: flex; flex-direction: column; gap: 4px;
}

.chat-tag-trenner {
  align-self: center; margin: 14px 0 10px;
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--c-text-low);
}

.bubble-reihe { display: flex; flex-direction: column; max-width: 82%; margin-bottom: 10px; }
.bubble-reihe.von-mir     { align-self: flex-end;   align-items: flex-end; }
.bubble-reihe.von-anderen { align-self: flex-start; align-items: flex-start; }

.bubble-absender {
  font-size: 0.74rem; font-weight: 500; color: var(--c-text-mid);
  margin: 0 4px 4px; letter-spacing: 0.02em;
}

.bubble {
  padding: 12px 16px; border-radius: 18px;
  font-size: 0.95rem; line-height: 1.55;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: normal;
}
.von-mir .bubble {
  background: linear-gradient(135deg, var(--c-accent-2) 0%, var(--c-accent) 100%);
  color: var(--c-text-hi); border-bottom-right-radius: 6px;
}
.von-anderen .bubble {
  background: var(--surface-2); border: 1px solid var(--surface-border);
  color: var(--c-text-readable); border-bottom-left-radius: 6px;
}
.bubble a { color: var(--c-bright); text-decoration: underline; }

.bubble-zeit {
  font-size: 0.7rem; color: var(--c-text-low);
  margin: 4px 6px 0; font-variant-numeric: tabular-nums;
}
.bubble-zeit .status-icon { margin-left: 4px; }

/* Optimistisch gerendert, noch nicht bestätigt */
.bubble-reihe.unterwegs { opacity: 0.55; }
.bubble-reihe.fehlgeschlagen .bubble { border: 1px solid var(--c-negative); }
.bubble-reihe.fehlgeschlagen .bubble-zeit { color: var(--c-negative); }

.chat-eingabe {
  flex-shrink: 0; display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: rgba(4,31,35,0.85); backdrop-filter: blur(14px);
  border-top: 1px solid var(--surface-border);
}
.chat-eingabe textarea {
  flex: 1; min-height: 48px; max-height: 130px;
  border-radius: 24px; padding: 13px 18px;
}
.chat-eingabe .btn-icon { border-radius: 50%; background: var(--c-bright); border-color: transparent; color: #04262b; }
.chat-eingabe .btn-icon:hover:not(:disabled) { background: #22c3ae; }
.chat-eingabe .btn-icon:disabled { background: var(--surface-2); border-color: var(--surface-border-hi); color: var(--c-text-low); }

.chat-hinweis {
  flex-shrink: 0; text-align: center;
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  font-size: 0.88rem; color: var(--c-text-mid); line-height: 1.55;
  background: rgba(4,31,35,0.85); backdrop-filter: blur(14px);
  border-top: 1px solid var(--surface-border);
}

/* Avatar */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-brand); font-size: 0.8rem; font-weight: 600;
  color: #04262b;
}

@media (max-width: 560px) {
  .chat-verlauf { padding: 16px 14px 6px; }
  .chat-kopf, .chat-eingabe { padding-left: 14px; padding-right: 14px; }
  .bubble-reihe { max-width: 88%; }
  .card { padding: 22px 18px; border-radius: var(--radius-md); }
}

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