/* ── Brand Tokens ────────────────────────────────────────────────────────── */
:root {
  --gold:   #E0AE42;
  --mauve:  #C6B2C9;
  --navy:   #0F1B2D;
  --plum:   #3A1E3F;
  --ivory:  #F6F2ED;

  --bg:     var(--navy);
  --panel:  #1a2a3f;      /* navy leicht aufgehellt für Header/Nav */
  --card:   var(--plum);  /* Karten / COO-Bubbles */
  --me:     var(--gold);
  --coo:    var(--plum);
  --txt:    var(--ivory);
  --muted:  var(--mauve);

  --font-head: 'Playfair Display', Georgia, serif;
  --font-body: 'Cabinet Grotesk', system-ui, -apple-system, sans-serif;

  --nav-h:  3.6rem;
  --max-w:  680px;        /* Chat-Spaltenbreite */
  --radius: 14px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--txt);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen { height: 100dvh; display: flex; flex-direction: column; }

/* Auth */
#auth {
  align-items: center; justify-content: center;
  gap: 1.2rem; text-align: center; padding: 2rem;
  background: radial-gradient(ellipse at 50% 30%, #1e2d45 0%, var(--navy) 70%);
}
#auth h1 {
  font-family: var(--font-head);
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 700; margin: 0;
  color: var(--gold);
  letter-spacing: -.01em;
}
#auth p { color: var(--muted); margin: 0; font-size: 1rem; }
.err { color: #f87171; min-height: 1.2em; font-size: .9rem; }

/* Buttons */
button {
  cursor: pointer; border: none;
  border-radius: 10px; color: var(--navy);
  background: var(--gold);
  padding: .8rem 1.6rem; font-size: 1rem;
  font-family: var(--font-body); font-weight: 700;
  letter-spacing: .02em;
  transition: filter .15s;
}
button:hover { filter: brightness(1.08); }
#auth-btn { font-size: 1.05rem; padding: .9rem 2.2rem; }

/* ── App container ───────────────────────────────────────────────────────── */
#app { overflow: hidden; }
.pane { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.pane.active { display: flex; }

/* Pane headers */
.pane header {
  padding: max(1rem, env(safe-area-inset-top)) 1.1rem .7rem;
  font-family: var(--font-head); font-size: 1.1rem; font-weight: 700;
  background: var(--panel);
  border-bottom: 1px solid rgba(224,174,66,.15);
  letter-spacing: .01em; color: var(--gold);
}
.chat-header { display: flex; align-items: center; gap: .6rem; }
.chat-header-title { flex: 1; color: var(--ivory); font-size: 1rem; font-family: var(--font-body); font-weight: 500; }

.agent-picker { display: flex; align-items: center; gap: .35rem; }
.agent-picker-label { font-size: .72rem; color: var(--muted); font-family: var(--font-body); font-weight: 400; }
#agent-select {
  appearance: none; -webkit-appearance: none;
  background: rgba(224,174,66,.12); color: var(--gold);
  border: 1px solid rgba(224,174,66,.35); border-radius: 9px;
  padding: .35rem 1.6rem .35rem .65rem;
  font-family: var(--font-body); font-size: .82rem; font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23E0AE42' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center;
}
#agent-select option { background: var(--navy); color: var(--ivory); font-weight: 500; }

.crm-header { display: flex; align-items: center; gap: .6rem; }
#crm-title, #training-title { flex: 1; color: var(--ivory); font-family: var(--font-body); font-weight: 600; font-size: 1rem; }
.crm-back-btn, .crm-refresh-btn {
  background: transparent; font-size: 1.2rem;
  padding: .3rem .6rem; border-radius: 8px;
  color: var(--muted);
}
.crm-back-btn:hover, .crm-refresh-btn:hover { background: rgba(198,178,201,.12); filter: none; }

/* ── Bottom nav ──────────────────────────────────────────────────────────── */
#bottom-nav {
  display: flex; height: var(--nav-h);
  background: var(--panel);
  border-top: 1px solid rgba(224,174,66,.12);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .12rem;
  background: transparent; border-radius: 0; padding: .4rem;
  color: var(--muted); font-size: .68rem;
  font-family: var(--font-body);
  transition: color .15s;
}
.nav-btn.active { color: var(--gold); }
.nav-icon { font-size: 1.25rem; line-height: 1; }
.nav-label { font-size: .68rem; }

/* ── Chat pane ───────────────────────────────────────────────────────────── */
#log {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: .55rem;
  padding: 1.2rem 1rem;
  /* Centered narrow column */
  max-width: var(--max-w);
  width: 100%; align-self: center;
}

.msg {
  max-width: 82%; padding: .65rem .9rem;
  border-radius: var(--radius); line-height: 1.45;
  font-size: .95rem; white-space: pre-wrap;
}
.msg.me {
  align-self: flex-end;
  background: var(--gold); color: var(--navy);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.msg.coo {
  align-self: flex-start;
  background: var(--plum); color: var(--ivory);
  border-bottom-left-radius: 4px;
}
.msg.status {
  align-self: center;
  background: transparent; color: var(--muted);
  font-size: .82rem; padding: .15rem .4rem;
  max-width: 100%; text-align: center;
}
.msg a { color: var(--gold); }
.msg.approval {
  background: rgba(58,30,63,.85);
  border: 1px solid rgba(224,174,66,.4);
  max-width: 95%;
}
.msg.approval small { color: var(--muted); }
.approval-row { display: flex; gap: .5rem; margin-top: .6rem; }
.approval-row button { flex: 1; padding: .5rem; font-size: .9rem; }
.approval-row button.deny { background: #4b5563; color: var(--ivory); }

/* Composer */
.composer-bar {
  background: var(--panel);
  border-top: 1px solid rgba(224,174,66,.1);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
#composer {
  max-width: var(--max-w); margin: 0 auto; width: 100%;
  display: flex; gap: .4rem; align-items: center;
  padding: .55rem .75rem;
}
#text {
  flex: 1; border: 1px solid rgba(198,178,201,.2);
  border-radius: 20px; padding: .65rem 1rem;
  font-size: .95rem; font-family: var(--font-body);
  background: rgba(255,255,255,.05); color: var(--ivory);
  outline: none;
  transition: border-color .15s;
}
#text:focus { border-color: rgba(224,174,66,.5); }
#text::placeholder { color: var(--muted); opacity: .7; }
#recording-indicator {
  flex: 1; min-width: 0; height: 42px;
  display: flex; align-items: center; gap: .65rem;
  border: 1px solid rgba(224,174,66,.45);
  border-radius: 20px; padding: .35rem .8rem;
  background: rgba(224,174,66,.08);
  color: var(--gold); font-size: .82rem;
}
#recording-indicator[hidden] { display: none; }
#recording-wave { flex: 1; min-width: 0; height: 28px; }
.icon-btn {
  background: transparent; font-size: 1.25rem;
  padding: .45rem; min-width: 2.6rem;
  color: var(--muted); border-radius: 50%;
}
#mic.recording {
  background: #ef4444; border-radius: 50%; color: var(--ivory);
  animation: recording-pulse 1.4s ease-in-out infinite;
}
#mic:disabled { opacity: .45; cursor: default; }
#send.recording { color: var(--gold); }
@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.35); }
  50% { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

/* ── Training pane ───────────────────────────────────────────────────────── */
.training-week { margin-bottom: 1.2rem; }

.training-day {
  display: flex; align-items: flex-start; gap: .7rem;
  background: var(--plum); border-radius: 10px;
  padding: .55rem .7rem; margin-bottom: .35rem;
  transition: opacity .15s;
}
.training-day.st-1 { opacity: .55; }
.training-day.st-3 .training-info { opacity: .5; text-decoration: line-through; }

.training-status {
  background: rgba(255,255,255,.08); font-size: 1.1rem; line-height: 1;
  padding: .4rem .5rem; border-radius: 8px; flex-shrink: 0;
  color: var(--ivory);
}
.training-status[disabled] { opacity: .35; cursor: default; }

.training-info { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.training-info strong { font-size: .88rem; color: var(--ivory); }
.training-info span { font-size: .8rem; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.training-ist { color: #86efac !important; }

.training-hint {
  text-align: center; color: var(--muted); font-size: .75rem;
  padding: .6rem 1rem; line-height: 1.5;
}

/* ── CRM pane ────────────────────────────────────────────────────────────── */
.crm-body { flex: 1; overflow-y: auto; padding: 1rem; }

.crm-loading, .crm-empty {
  text-align: center; color: var(--muted);
  padding: 2rem 1rem; font-size: .9rem; line-height: 1.6;
}

.crm-group { margin-bottom: 1.2rem; }
.crm-group-title {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  padding: .3rem 0 .45rem;
  border-bottom: 1px solid rgba(198,178,201,.18);
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: .5rem;
}
.crm-count {
  background: rgba(198,178,201,.15); border-radius: 10px;
  padding: .05rem .45rem; font-size: .7rem;
}

.crm-card {
  background: var(--plum); border-radius: 10px;
  padding: .7rem .9rem; margin-bottom: .4rem;
  cursor: pointer; display: flex;
  align-items: center; justify-content: space-between;
  transition: filter .15s;
}
.crm-card:hover { filter: brightness(1.12); }
.crm-card strong { font-size: .92rem; color: var(--ivory); }
.crm-card .crm-next { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.crm-card-arrow { color: var(--muted); font-size: 1rem; }

/* CRM detail */
.crm-detail { line-height: 1.6; font-size: .93rem; }
.crm-detail h2 { font-family: var(--font-head); font-size: 1.1rem; color: var(--gold); margin: .9rem 0 .3rem; }
.crm-detail h3 { font-size: .95rem; margin: .7rem 0 .25rem; color: var(--mauve); }
.crm-detail h4 { font-size: .87rem; margin: .6rem 0 .2rem; color: var(--muted); }
.crm-detail li { margin: .15rem 0; padding-left: .2rem; }
.crm-detail blockquote {
  border-left: 3px solid rgba(224,174,66,.35); padding: .3rem .7rem;
  margin: .4rem 0; color: var(--muted); font-size: .87rem;
}
.crm-detail p { margin: .3rem 0; }
