/* "Mit Ihrem CRM verbunden" auf maklerbridgeos.html - Stylesheet der React-Insel
   src/components/os/CrmVerbindung.tsx. Uhr und Pause kommen aus src/components/ablauf/.

   Eine Bahn, wechselndes Ziel. Der Puls ist ein wandernder Strich auf einer Linie - dieselbe
   Technik wie bei Magic UIs AnimatedBeam, nur ohne Animationsbibliothek und ohne SVG: hier
   genuegt ein Kind, das von links nach rechts laeuft. */

.os-verbindung {
  --os-akzent: #2453ff;
  --os-puls: 900ms;   /* muss zu ANKUNFT in der Komponente passen */
  --os-ease: cubic-bezier(.4, 0, .2, 1);
}

/* --- Die beiden Knoten --- */
.os-knoten {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.45rem;
  flex: 1 1 0;
  min-width: 0;
  /* Beide Kacheln halten dieselbe Hoehe, unabhaengig davon, welcher Name gerade im Ziel steht. */
  min-height: 4.9rem;
  border-radius: 10px;
  border: 1px solid #d7d7d7;
  background: #ffffff;
  padding: 1rem 1.15rem;
  transition: border-color 400ms ease, background-color 400ms ease, box-shadow 400ms ease;
}
.os-knoten-label {
  font-family: Inter, sans-serif;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #666666;
}
.os-knoten-wert {
  font-family: Inter, sans-serif;
  font-size: 0.95rem;
  line-height: 1.25;
  color: #000000;
}
/* Das Ziel steht auf getoentem Grund, damit die Bahn ein sichtbares Gegenüber hat. */
.os-knoten-ziel { background: #f8f9fa; }
.os-knoten-ziel.is-an { border-color: rgba(36, 83, 255, 0.45); background: rgba(36, 83, 255, 0.04); }
.os-ziel-zeile { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
/* Der Name bricht nie um: "Microsoft Dynamics 365" wuerde die Kachel sonst zweizeilig machen
   und die ganze Karte bei jedem Wechsel neu umbrechen lassen. */
.os-ziel-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.os-ziel-haken {
  flex: none;
  color: var(--os-akzent);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 250ms ease, transform 400ms cubic-bezier(.34, 1.45, .64, 1);
}
.os-knoten-ziel.is-an .os-ziel-haken { opacity: 1; transform: none; }

/* --- Die Bahn dazwischen --- */
.os-bahn {
  position: relative;
  flex: 0 1 5.5rem;
  min-width: 2.5rem;
  align-self: center;
  height: 1px;
}
.os-bahn-linie { position: absolute; inset: 0; background: #d7d7d7; }
/* Die Spitze markiert die Richtung, ohne einen Pfeil zu zeichnen. */
.os-bahn-spitze {
  position: absolute;
  right: 0;
  top: 50%;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 999rem;
  background: #d7d7d7;
  transition: background-color 300ms ease;
}
.os-strecke:has(.os-knoten-ziel.is-an) .os-bahn-spitze { background: var(--os-akzent); }
.os-bahn-puls {
  position: absolute;
  top: 50%;
  left: 0;
  width: 1.5rem;
  height: 2px;
  margin-top: -1px;
  border-radius: 999rem;
  background: linear-gradient(90deg, rgba(36, 83, 255, 0) 0%, var(--os-akzent) 100%);
  transform: translateX(-100%);
  animation: os-puls var(--os-puls) var(--os-ease) both;
}
@keyframes os-puls {
  0% { left: 0; opacity: 0; }
  15% { opacity: 1; }
  100% { left: 100%; opacity: 1; }
}

/* --- Legende als Chips --- */
/* Die Hervorhebung aendert ausschliesslich Farben. Schriftschnitt, Schriftgrad oder Rahmenstaerke
   zu wechseln wuerde die Chipbreite aendern - die Zeile braeche dann bei jedem Takt neu um. */
.os-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999rem;
  border: 1px solid #d7d7d7;
  background: #ffffff;
  padding: 0.34rem 0.7rem;
  font-family: Inter, sans-serif;
  font-size: 0.78rem;
  line-height: 1.25;
  color: #666666;
  white-space: nowrap;
  transition: color 300ms ease, background-color 300ms ease, border-color 300ms ease;
}
.os-chip.is-an { color: #ffffff; background: var(--os-akzent); border-color: var(--os-akzent); }
/* Der Auffangfall traegt Kontur, auch wenn er nicht an der Reihe ist. */
.os-chip-offen { color: #000000; border-color: rgba(0, 0, 0, 0.32); }
.os-chip-offen.is-an { color: #ffffff; border-color: var(--os-akzent); }
/* Der Knopf in die vollstaendige Liste. */
.os-chip-mehr {
  cursor: pointer;
  color: var(--os-akzent);
  border-color: rgba(36, 83, 255, 0.35);
  background: rgba(36, 83, 255, 0.05);
}
.os-chip-mehr:hover { background: rgba(36, 83, 255, 0.1); border-color: rgba(36, 83, 255, 0.55); }
.os-chip-mehr:focus-visible { outline: 2px solid var(--os-akzent); outline-offset: 3px; }
.os-chip-still { background: #f8f9fa; border-color: transparent; color: #000000; }

/* --- Dialog mit der vollstaendigen Liste --- */
/* Natives dialog: Escape, Fokusfalle und der Hintergrund kommen vom Browser. display darf nur
   im offenen Zustand gesetzt werden, sonst stuende das Fenster auch geschlossen im Fluss. */
.os-dialog {
  width: min(46rem, calc(100vw - 2rem));
  max-height: min(44rem, calc(100vh - 3rem));
  padding: 0;
  border: 1px solid #d7d7d7;
  border-radius: 16px;
  background: #ffffff;
  color: #000000;
  font-family: Inter, sans-serif;
  overflow: hidden;
}
.os-dialog[open] { display: flex; flex-direction: column; animation: os-dialog-auf 220ms cubic-bezier(.22, 1, .36, 1); }
.os-dialog::backdrop { background: rgba(11, 25, 32, 0.45); }
.os-dialog[open]::backdrop { animation: os-dialog-schleier 220ms ease; }
@keyframes os-dialog-auf { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes os-dialog-schleier { from { opacity: 0; } }

.os-dialog-inhalt { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.os-dialog-kopf {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.75rem 1.75rem 1.25rem;
}
.os-dialog-zu {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999rem;
  border: 1px solid #d7d7d7;
  background: #ffffff;
  color: #000000;
  cursor: pointer;
  transition: background-color 250ms ease, border-color 250ms ease;
}
.os-dialog-zu:hover { background: #f8f9fa; border-color: rgba(0, 0, 0, 0.3); }
.os-dialog-zu:focus-visible { outline: 2px solid var(--os-akzent); outline-offset: 3px; }

.os-suche {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 1.75rem;
  border: 1px solid #d7d7d7;
  border-radius: 10px;
  background: #f8f9fa;
  padding: 0 0.9rem;
  color: #666666;
  transition: border-color 250ms ease, background-color 250ms ease;
}
.os-suche:focus-within { border-color: var(--os-akzent); background: #ffffff; }
.os-suche input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 0.75rem 0;
  font-family: inherit;
  font-size: 0.9rem;
  color: #000000;
  outline: none;
}
.os-suche input::placeholder { color: #666666; }
.os-suche input::-webkit-search-cancel-button { cursor: pointer; }

.os-dialog-zahl { padding: 0.9rem 1.75rem 0; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: #666666; }
.os-dialog-liste { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1.75rem 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.os-dialog-gruppe { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: #666666; margin-bottom: 0.7rem; }
/* Die letzte Gruppe sind Formate, keine Systeme - der Hinweis sagt das, bevor jemand
   "E-Mail" fuer ein CRM haelt. */
.os-dialog-hinweis { margin: -0.3rem 0 0.7rem; font-family: Montserrat, sans-serif; font-size: 0.82rem; line-height: 1.55; color: #666666; }
.os-dialog-leer { font-family: Montserrat, sans-serif; font-size: 0.9rem; line-height: 1.6; color: #666666; }
.os-dialog-fuss {
  border-top: 1px solid #d7d7d7;
  padding: 1.15rem 1.75rem;
  font-family: Montserrat, sans-serif;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #666666;
  background: #f8f9fa;
}

.os-verbindung[data-pausiert="true"] .os-bahn-puls { animation-play-state: paused; }

/* Schmale Karte: die Strecke kippt in die Senkrechte, sonst bleibt fuer die Namen nichts uebrig. */
@media (max-width: 559px) {
  .os-strecke { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  /* min-width der waagerechten Bahn muss hier weg, sonst wird die Linie 2,5rem breit. */
  .os-bahn { flex: none; align-self: center; width: 1px; min-width: 0; height: 2.25rem; }
  .os-bahn-spitze { right: 50%; top: auto; bottom: 0; margin: 0 -2px 0 0; }
  .os-bahn-puls {
    left: 50%;
    top: 0;
    width: 2px;
    height: 1.5rem;
    margin: 0 0 0 -1px;
    background: linear-gradient(180deg, rgba(36, 83, 255, 0) 0%, var(--os-akzent) 100%);
    transform: translateY(-100%);
    animation-name: os-puls-senkrecht;
  }
}
@keyframes os-puls-senkrecht {
  0% { top: 0; left: 50%; opacity: 0; }
  15% { opacity: 1; }
  100% { top: 100%; left: 50%; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .os-knoten, .os-ziel-haken, .os-chip, .os-bahn-spitze { transition: none; }
  .os-bahn-puls { display: none; }
  .os-dialog[open], .os-dialog[open]::backdrop { animation: none; }
}
