/* digi.camp Businessplan-Coach – Design gemäß Spezifikation 4.3 / Brand-Guide */

/* Self-hosted Fonts (lokal mitgeliefert, kein Hotlinking) */
@font-face {
  font-family: 'Neuzeit_BookHeavy';
  src: url('fonts/NeuzeitSLTStd-BookHeavy.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Neuzeit400';
  src: url('fonts/Neuzeit-Grotesk.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --magenta: #EF28C1;
  --magenta-dark: #c9169f;
  --green: #3DCD49;
  --rosa: #fce8f8;
  --neutral: #f0f0f0;
  --black: #000000;
  --white: #FFFFFF;
  --font-head: 'Neuzeit_BookHeavy', Helvetica, Arial, sans-serif;
  --font-body: 'Neuzeit400', Helvetica, Arial, sans-serif;
  --maxw: 1160px;
  --header-h: 60px;
  --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 18px;                 /* Fließtext 18px (verbindlich) */
  line-height: 1.55;
  color: var(--black);
  /* Warmer Verlauf: Creme → Blush → Rosa (gemäß Design-Vorlagen) */
  background: linear-gradient(120deg, #fff6ea 0%, #fdeef7 38%, #fbdcf0 75%, #f8cdea 100%);
  display: flex;
  flex-direction: column;
}

/* --------------------- Dekorativer Hintergrund (Brand) -------------------- */

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
}
.deco { position: absolute; }

.deco-waves {
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: clamp(120px, 24vh, 300px);
}

.deco-mountain {
  left: -20px;
  bottom: 0;
  width: clamp(200px, 24vw, 340px);
  height: auto;
}

.deco-sketch {
  top: 84px;
  right: 24px;
  width: clamp(220px, 26vw, 380px);
  height: auto;
  opacity: 0.30;
}

.deco-dots { width: 130px; height: 130px; opacity: 0.14; }
.deco-dots-tl { top: 84px; left: 28px; }
.deco-dots-br { right: 40px; bottom: 26vh; }

.bg-tagline {
  position: absolute;
  left: 36px;
  top: 210px;
  font-family: var(--font-head);
  font-size: 22px;
  line-height: 1.35;
  color: var(--black);
}
.tagline-dash {
  display: block;
  width: 34px;
  height: 4px;
  border-radius: 999px;
  background: var(--magenta);
  margin-top: 10px;
}

/* Deko nur zeigen, wo sie nicht mit den Karten kollidiert.
   Sketch/Punkte dürfen hinter die (opaken) Karten laufen – Text nicht. */
@media (max-width: 1600px) {
  .bg-tagline, .deco-dots-tl { display: none; }
}
@media (max-width: 1100px) {
  .deco-sketch, .deco-dots-br { display: none; }
}

/* ------------------------------- Header ---------------------------------- */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--white);        /* Logo nur auf Weiß/Schwarz/Magenta */
  border-bottom: 1px solid #f0dcea;
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.logo {
  font-family: var(--font-head);
  font-size: 26px;
  color: var(--black);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.logo-dot { color: var(--magenta); }

.header-actions { display: flex; gap: 8px; }

.btn-ghost {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--magenta);
  background: var(--white);
  border: 1.5px solid var(--magenta);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--rosa); }
.btn-ghost.success { border-color: var(--green); color: var(--green); }

/* ---------------------------- Hinweis-Banner ------------------------------ */

.banner {
  position: relative;
  z-index: 10;
  background: var(--rosa);
  color: var(--black);
  font-size: 14px;
  text-align: center;
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: center;
}
.banner a { color: var(--magenta); }

/* ------------------------- Gate / Fehler / Laden -------------------------- */

.main { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 1; }

.gate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.gate-card {
  max-width: 520px;
  text-align: center;
  background: var(--white);
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  padding: 40px 32px;
}
.gate-emoji { font-size: 44px; margin-bottom: 12px; }
.gate-card h1 {
  font-family: var(--font-head);
  font-size: 28px;
  margin-bottom: 12px;
}
.gate-card p { margin-bottom: 10px; }
.gate-footer { font-size: 14px; margin-top: 20px; }
.gate-footer a, .gate-card a { color: var(--magenta); }

.spinner {
  width: 38px; height: 38px;
  margin: 0 auto 16px;
  border: 4px solid var(--rosa);
  border-top-color: var(--magenta);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------- Chat-Layout (Grid) --------------------------- */

.chat-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px calc(24px + clamp(40px, 8vh, 110px));
  min-height: 0;
  align-items: stretch;
}

.chat-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--white);
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid #f0eaee;
  background: var(--white);
}
.coach-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--rosa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex: none;
}
.coach-meta { display: flex; flex-direction: column; line-height: 1.3; }
.coach-meta strong { font-family: var(--font-head); font-size: 18px; }
.coach-status { font-size: 13px; color: #666; display: flex; align-items: center; gap: 6px; }
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 88%;
  border-radius: 16px;
  padding: 12px 16px;
  overflow-wrap: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--rosa);          /* Nutzer: Rosa-Fläche */
  color: var(--black);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--neutral);       /* Agent: neutraler Hintergrund */
  color: var(--black);
  border-bottom-left-radius: 4px;
}

/* Markdown im Agent-Text */
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3, .msg.assistant h4 {
  font-family: var(--font-head);
  line-height: 1.3;
  margin: 14px 0 6px;
}
.msg.assistant h1 { font-size: 24px; }
.msg.assistant h2 { font-size: 21px; }
.msg.assistant h3 { font-size: 19px; }
.msg.assistant h4 { font-size: 18px; }
.msg.assistant > *:first-child { margin-top: 0; }
.msg.assistant p { margin: 8px 0; }
.msg.assistant ul, .msg.assistant ol { margin: 8px 0 8px 24px; }
.msg.assistant li { margin: 3px 0; }
.msg.assistant strong { font-family: var(--font-head); font-weight: 700; }
.msg.assistant code {
  background: #e2e2e2;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 16px;
}
.msg.assistant pre {
  background: #e2e2e2;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant a { color: var(--magenta); }
.msg.assistant hr { border: none; border-top: 1px solid #d5d5d5; margin: 12px 0; }
.msg.assistant blockquote {
  border-left: 3px solid var(--magenta);
  padding-left: 12px;
  margin: 8px 0;
  color: #333;
}

/* Tipp-Indikator während des Streamings */
.cursor-blink::after {
  content: '▍';
  color: var(--magenta);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Kopieren-Button pro Agent-Nachricht */
.msg-tools { margin-top: 8px; }
.btn-copy {
  font-family: var(--font-body);
  font-size: 13px;
  color: #555;
  background: var(--white);
  border: 1px solid #d0d0d0;
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-copy:hover { color: var(--magenta); border-color: var(--magenta); }
.btn-copy.copied { color: var(--green); border-color: var(--green); } /* Grün nur für Erfolg */

/* Fehlerhinweis im Chat */
.msg.notice {
  align-self: center;
  background: #FFF8C5;
  color: #806000;
  font-size: 15px;
  text-align: center;
  max-width: 96%;
}

/* ------------------------------- Composer --------------------------------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 1px solid #f0eaee;
}
.composer textarea {
  flex: 1;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.4;
  border: 1.5px solid #e5c8dc;
  border-radius: 22px;
  padding: 11px 16px;
  resize: none;
  max-height: 160px;
  outline: none;
  background: var(--white);
  color: var(--black);
}
.composer textarea:focus { border-color: var(--magenta); }

.btn-send {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--magenta);       /* Sende-Button: Magenta */
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, opacity .15s;
}
.btn-send:hover { background: var(--magenta-dark); }
.btn-send:disabled { opacity: .4; cursor: default; }

/* --------------------- Fortschrittsleiste „Dein Businessplan" ------------- */

.plan-card {
  background: var(--white);
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  padding: 20px;
  align-self: start;
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
}

.plan-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: 19px;
}
.plan-icon { font-size: 20px; }

.plan-sub {
  font-size: 14px;
  color: #666;
  margin: 6px 0 10px;
}

.plan-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--neutral);
  overflow: hidden;
  margin-bottom: 16px;
}
.plan-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--magenta);
  transition: width .4s ease;
}

.part-label {
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #b58aa8;
  font-family: var(--font-head);
  margin: 10px 0 4px 2px;
}
#stations > .part-label:first-child { margin-top: 0; }

.stations { list-style: none; display: flex; flex-direction: column; }

.station { display: flex; gap: 12px; align-items: flex-start; padding: 7px 0; }
.station-num {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--neutral);
  color: #888;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
}
.station-body { display: flex; flex-direction: column; line-height: 1.3; padding-top: 3px; min-width: 0; }
.station-title { font-family: var(--font-head); font-size: 15px; color: #777; }
.station-state { font-size: 12.5px; color: #aaa; }
.station-mobilestep { display: none; }

.station.done .station-num { background: var(--green); color: var(--white); font-size: 14px; }
.station.done .station-title { color: #555; }
.station.done .station-state { color: var(--green); }

.station.active-block {
  display: block;
  background: var(--rosa);
  border-radius: 16px;
  margin: 2px -8px;
  padding: 9px 8px 4px;
}
.station.active-block > .station-row { display: flex; gap: 12px; align-items: flex-start; }
.station.active-block .station-num { background: var(--magenta); color: var(--white); animation: pulse 2s infinite; }
.station.active-block .station-title { color: var(--black); font-size: 16px; }
.station.active-block .station-state { color: var(--magenta); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 40, 193, .35); }
  50% { box-shadow: 0 0 0 7px rgba(239, 40, 193, 0); }
}

/* Aufgeklappte Unterschritte der Finanzplanung (Kapitel 9) */
.substeps {
  list-style: none;
  margin: 8px 0 4px 13px;
  border-left: 3px dotted #eeb9de;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.substep { display: flex; gap: 9px; align-items: center; }
.substep-dot {
  flex: none;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid #e0c4d6;
  color: #b58aa8;
  font-size: 10.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
}
.substep-title { font-size: 13.5px; color: #8a7383; }
.substep.done .substep-dot { background: var(--green); border-color: var(--green); color: var(--white); }
.substep.done .substep-title { color: #555; }
.substep.active .substep-dot { background: var(--magenta); border-color: var(--magenta); color: var(--white); }
.substep.active .substep-title { color: var(--black); font-family: var(--font-head); }
.substep.active .substep-title::after {
  content: ' · Jetzt dran';
  color: var(--magenta);
  font-family: var(--font-body);
  font-size: 12px;
}

.station.summit .station-num { background: var(--white); border: 2px solid var(--black); color: var(--black); font-size: 14px; }

.plan-note {
  margin-top: 12px;
  font-size: 12.5px;
  color: #888;
  border-top: 1px solid #f0eaee;
  padding-top: 10px;
  line-height: 1.45;
}
.plan-note b { font-family: var(--font-head); font-weight: normal; color: #555; }

.btn-pdf {
  margin-top: 12px;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--magenta);
  background: var(--white);
  border: 1.5px solid var(--magenta);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s;
}
.btn-pdf:hover { background: var(--rosa); }

/* -------------------------------- Mobil ----------------------------------- */

@media (max-width: 900px) {
  .bg-tagline { display: none; }

  .chat-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 10px calc(16px + clamp(30px, 6vh, 60px));
  }

  /* Fortschritt als kompakte, horizontal scrollbare Leiste über dem Chat */
  .plan-card {
    order: -1;
    position: static;
    align-self: stretch;
    flex: none;
    max-height: none;
    padding: 12px 14px;
    border-radius: 18px;
    min-width: 0;
  }
  .plan-sub { margin: 4px 0 8px; }
  .plan-progress { margin-bottom: 10px; }

  /* Chips-Leiste: Gruppenlabels/Unterschritte/Notiz ausblenden, Kapitel horizontal scrollen */
  .part-label, .substeps, .plan-note { display: none; }
  #stations {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .stations { display: contents; }
  .station {
    flex: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    min-width: 108px;
    text-align: center;
    border: 1.5px solid #eee;
    border-radius: 16px;
  }
  .station.active-block {
    display: flex;
    margin: 0;
    border-color: var(--magenta);
  }
  .station.active-block > .station-row {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .station-body { padding-top: 0; align-items: center; }
  .station-title { font-size: 13px; }
  .station-state { display: none; }
  .station-mobilestep {
    display: block;
    font-size: 12px;
    color: var(--magenta);
    font-family: var(--font-head);
  }
  .btn-pdf { margin-top: 8px; }

  .chat-card { flex: 1; min-height: 60vh; border-radius: 18px; }
}

@media (max-width: 520px) {
  .header-inner { padding: 0 10px; gap: 8px; }
  .logo { font-size: 20px; flex: none; }
  .header-actions { gap: 6px; }
  .btn-ghost { font-size: 12px; padding: 5px 9px; }
  .msg { max-width: 94%; }
  .banner { font-size: 13px; }
}

/* ------------------------ Druck: nur der Chatverlauf ----------------------- */

@media print {
  body { background: #fff; display: block; }
  .bg-decor, .header, .banner, .chat-header, .composer,
  .plan-card, .msg-tools, .gate { display: none !important; }
  .main { display: block; }
  .chat-layout { display: block; padding: 0; max-width: 100%; }
  .chat-card {
    display: block;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
    min-height: 0;
  }
  .messages {
    display: block;
    overflow: visible;
    padding: 0;
  }
  .msg {
    max-width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff !important;
    color: #000 !important;
    margin: 0 0 10px;
    page-break-inside: avoid;
  }
  .msg.user { background: #f6f6f6 !important; }
  .msg.notice { display: none; }
}
