/* ============================================================
   Formiqa Lead-Console — shared engine styles
   Dark cockpit: Navy / Champagne / Cream, Geist + Geist Mono.
   One file for all sections (icp-* shells + generic console.html).
   Mobile-first master–detail: list and detail swap on small screens.
   ============================================================ */

:root {
  --bg:        #0a0f1c;
  --surface:   #0f1626;
  --surface2:  #141d31;
  --line:      rgba(245,241,232,0.08);
  --line2:     rgba(245,241,232,0.14);
  --cream:     #f5f1e8;
  --mute:      rgba(245,241,232,0.62);
  --subtle:    rgba(245,241,232,0.38);
  --champagne: #c9a86a;
  --champagne2:#b89554;
  --ok:        #34d399;
  --warn:      #f59e0b;
  --danger:    #fb7185;
  --info:      #7dd3fc;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-header-h: 64px; /* measured live in console.js, drives sticky offsets */
}

* { box-sizing: border-box; }
html, body {
  background: var(--bg);
  color: var(--cream);
  font-family: Geist, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}
body { min-height: 100dvh; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(245,241,232,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(245,241,232,0.22); }

/* ── Tiers / badges ── */
.tier-1 { border-left-color: var(--champagne); }
.tier-2 { border-left-color: var(--info); }
.tier-3 { border-left-color: rgba(245,241,232,0.32); }

.tier-badge-1 { background: rgba(201,168,106,0.14); color: var(--champagne); border: 1px solid rgba(201,168,106,0.32); }
.tier-badge-2 { background: rgba(125,211,252,0.10); color: var(--info); border: 1px solid rgba(125,211,252,0.24); }
.tier-badge-3 { background: rgba(245,241,232,0.05); color: rgba(245,241,232,0.55); border: 1px solid rgba(245,241,232,0.14); }

.status-Neu { background: rgba(52,211,153,0.14); color: var(--ok); border: 1px solid rgba(52,211,153,0.32); }
.status-verify-needed { background: rgba(245,158,11,0.10); color: var(--warn); border: 1px solid rgba(245,158,11,0.32); }

.channel-mail { color: var(--info); }
.channel-instagram-dm, .channel-instagram { color: var(--danger); }
.channel-telefon-anruf-zuerst, .channel-telefon { color: var(--warn); }
.channel-vor-ort { color: var(--ok); }

.rating-pill {
  font-family: "Geist Mono", monospace; font-size: 9.5px; padding: 1px 6px; border-radius: 9999px;
  background: rgba(245,241,232,0.05); color: rgba(245,241,232,0.55);
  border: 1px solid rgba(245,241,232,0.12); white-space: nowrap;
}
.rating-pill.perle { background: rgba(201,168,106,0.14); color: var(--champagne); border-color: rgba(201,168,106,0.32); }

/* ── Lead list item ── */
.lead-item { position: relative; transition: background-color .18s ease, border-color .18s ease, transform .2s ease, opacity .2s ease; cursor: pointer; touch-action: pan-y; }
.lead-dismiss { position: absolute; top: 6px; right: 6px; z-index: 3; width: 22px; height: 22px; display: none; align-items: center; justify-content: center; padding: 0; font-size: 11px; line-height: 1; color: #fb7185; background: rgba(251,113,133,0.12); border: 1px solid rgba(251,113,133,0.32); border-radius: 6px; cursor: pointer; }
.lead-dismiss:hover { background: rgba(251,113,133,0.22); }
.lead-item:hover .lead-dismiss { display: flex; }
.toast-action { margin-left: 14px; padding: 0; background: none; border: none; color: #c9a86a; font-weight: 600; text-decoration: underline; cursor: pointer; font-size: inherit; font-family: inherit; }
.lead-item:hover { background: rgba(245,241,232,0.03); }
.lead-item.active { background: rgba(201,168,106,0.08); }
.lead-item:active { background: rgba(201,168,106,0.12); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px; font-size: 12.5px; font-weight: 500; border-radius: 7px;
  transition: all .14s ease; cursor: pointer; user-select: none; border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--champagne); color: var(--bg); }
.btn-primary:hover { background: #d4b275; }
.btn-ghost { background: transparent; color: var(--cream); border-color: rgba(245,241,232,0.14); }
.btn-ghost:hover { border-color: rgba(245,241,232,0.32); background: rgba(245,241,232,0.03); }
.btn-mono { font-family: "Geist Mono", monospace; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input[type=text], input[type=search], input[type=email], input[type=url], input[type=date], input[type=time], input[type=datetime-local], input[type=number], input[type=tel], select, textarea {
  background: rgba(245,241,232,0.03); color: var(--cream);
  border: 1px solid rgba(245,241,232,0.10); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; font-family: Geist, system-ui, sans-serif;
  transition: border-color .14s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--champagne); }
/* Inputs that sit on a light/modal surface flip to dark text */
.input-light { background: #ffffff !important; color: #111111 !important; }

.chip {
  padding: 5px 11px; font-size: 12px; border-radius: 9999px;
  border: 1px solid rgba(245,241,232,0.12); color: rgba(245,241,232,0.65);
  cursor: pointer; transition: all .14s ease; user-select: none; white-space: nowrap;
}
.chip:hover { border-color: rgba(245,241,232,0.24); color: var(--cream); }
.chip.active { background: var(--champagne); color: var(--bg); border-color: var(--champagne); }

.copy-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; font-size: 10.5px;
  background: rgba(245,241,232,0.05); border: 1px solid rgba(245,241,232,0.12); color: rgba(245,241,232,0.65);
  border-radius: 5px; cursor: pointer; transition: all .14s ease;
  font-family: "Geist Mono", monospace; letter-spacing: 0.04em; text-transform: uppercase;
}
.copy-btn:hover { border-color: var(--champagne); color: var(--champagne); }
.copy-btn.copied { background: rgba(52,211,153,0.14); color: var(--ok); border-color: rgba(52,211,153,0.32); }

.weakness-li { padding-left: 18px; position: relative; line-height: 1.55; margin-bottom: 6px; color: rgba(245,241,232,0.78); font-size: 13px; }
.weakness-li::before { content: '·'; position: absolute; left: 6px; top: -2px; color: var(--champagne); font-size: 18px; font-weight: bold; }

.section-title { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(245,241,232,0.45); font-weight: 600; margin-bottom: 10px; }

pre.codeblock {
  background: rgba(10,15,28,0.6); border: 1px solid rgba(245,241,232,0.10); border-radius: 7px;
  padding: 12px 14px; font-family: "Geist Mono", monospace; font-size: 12px; line-height: 1.55;
  color: var(--cream); white-space: pre-wrap; word-break: break-word;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(22px + var(--safe-bottom)); right: 22px;
  background: var(--surface2); color: var(--cream); padding: 10px 16px; font-size: 13px;
  border: 1px solid rgba(245,241,232,0.12); border-radius: 8px;
  opacity: 0; transform: translateY(8px); transition: all .25s ease; pointer-events: none; z-index: 90;
  max-width: calc(100vw - 44px);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,15,28,0.78); backdrop-filter: blur(6px); z-index: 60; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid rgba(245,241,232,0.14); border-radius: 14px;
  width: 100%; max-width: 760px; max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.8);
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid rgba(245,241,232,0.08); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.modal-footer { padding: 14px 22px; border-top: 1px solid rgba(245,241,232,0.08); display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* ============================================================
   LAYOUT — desktop master + detail
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(10,15,28,0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(245,241,232,0.05), 0 12px 32px -16px rgba(0,0,0,0.65);
  padding-top: env(safe-area-inset-top, 0px);
}
.app-header-inner { max-width: 1500px; margin: 0 auto; padding: 0 24px; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.app-stats { display: flex; align-items: center; gap: 20px; font-size: 12px; }
.app-stat { display: flex; align-items: center; gap: 8px; }
.app-stat .lbl { color: var(--subtle); text-transform: uppercase; letter-spacing: 0.08em; }
.app-stat .val { font-family: "Geist Mono", monospace; font-weight: 600; }

.app-main {
  max-width: 1500px; margin: 0 auto; padding: 24px;
  display: grid; grid-template-columns: 340px 1fr; gap: 24px;
  /* Fixed height so the two panes scroll INTERNALLY (list stays put,
     detail scrolls under its own sticky info bar) instead of the window. */
  height: calc(100dvh - var(--app-header-h, 64px));
}
.app-aside { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.app-detail { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.lead-list { flex: 1; overflow-y: auto; margin-right: -8px; padding-right: 8px; display: flex; flex-direction: column; gap: 1px; }

/* ── Sticky lead info surface ──
   The lead's identity + primary actions stay pinned to the top of the detail
   pane, so calling / mailing / status are always reachable without scrolling up. */
.detail-hero {
  position: sticky; top: 0; z-index: 18;
  background: var(--surface);
  padding: 20px 22px;
  box-shadow: 0 16px 28px -22px rgba(0,0,0,0.85);
}
.detail-back { display: none; } /* surfaces only on mobile */

/* Mobile filter toggle (hidden on desktop) */
.filter-toggle { display: none; }

/* ============================================================
   RESPONSIVE — tablet & mobile master–detail
   ============================================================ */
@media (max-width: 1024px) {
  .app-main { grid-template-columns: 300px 1fr; gap: 18px; padding: 16px; }
}

@media (max-width: 760px) {
  .app-header-inner { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 14px; min-height: 0; }
  .app-brandrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .app-stats {
    gap: 0; justify-content: space-between;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; scrollbar-width: none;
  }
  .app-stats::-webkit-scrollbar { display: none; }
  .app-stat { flex-direction: column; gap: 1px; align-items: center; flex: 1; min-width: 56px; }
  .app-stat .lbl { font-size: 9px; }
  .app-stat .val { font-size: 14px; }

  /* Single column; list and detail swap via body state.
     height:auto releases the desktop fixed-height so the page scrolls normally. */
  .app-main { display: block; padding: 0; height: auto; min-height: calc(100dvh - var(--app-header-h, 110px)); }
  .app-aside { padding: 12px 14px 0; gap: 10px; }
  .app-detail {
    display: none; padding: 0 14px calc(24px + var(--safe-bottom));
    overflow-y: visible;
  }
  .lead-list { margin-right: 0; padding-right: 0; overflow-y: visible; gap: 2px; }

  /* When a lead is open: hide list + drop the stats strip so the header stays slim */
  body.view-detail .app-aside { display: none; }
  body.view-detail .app-detail { display: block; }
  body.view-detail .app-stats { display: none; }

  /* Sticky lead info surface pins right under the (now slim) app header */
  .detail-hero {
    top: var(--app-header-h, 56px);
    padding: 13px 14px;
    margin: 0 -14px 12px;
    border-radius: 0 0 14px 14px;
    border-left: none; border-right: none; border-top: none;
  }
  .detail-back { display: inline-flex; padding: 5px 10px; font-size: 12px; }

  /* Bigger touch targets */
  .lead-item { padding: 12px 12px; border-radius: 10px; }
  .chip { padding: 8px 13px; font-size: 12.5px; }
  .btn { padding: 10px 14px; font-size: 13.5px; }
  .copy-btn { padding: 6px 10px; font-size: 11px; }

  /* Collapsible filters to keep the list prominent */
  .filter-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 9px 13px; border-radius: 9px;
    border: 1px solid rgba(245,241,232,0.12); background: rgba(245,241,232,0.03);
    color: var(--mute); font-size: 12.5px; cursor: pointer;
  }
  .filter-group { display: none; flex-direction: column; gap: 8px; }
  body.filters-open .filter-group { display: flex; }

  /* Detail action buttons stay compact so the sticky info surface keeps its
     height in check while still showing every action. */
  .detail-actions { display: flex; flex-wrap: wrap; gap: 7px; }
  .detail-actions .btn { flex: 1 1 auto; padding: 9px 11px; font-size: 12.5px; white-space: nowrap; }
  .detail-actions a.btn-primary { flex-basis: 100%; } /* Anrufen = full-width primary CTA */

  /* Detail cards: collapse 2-col grids to single column */
  .detail-grid-2 { grid-template-columns: 1fr !important; }
  .detail-grid-3 { grid-template-columns: 1fr !important; }

  /* Modals go near full-screen */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 94dvh; border-radius: 16px 16px 0 0; border-bottom: none; }
  .modal-footer { position: sticky; bottom: 0; background: var(--surface); padding-bottom: calc(14px + var(--safe-bottom)); }
  .modal-footer .btn { flex: 1; }

  /* Build status panel: full width bottom sheet */
  #build-panel { left: 10px !important; right: 10px !important; bottom: calc(10px + var(--safe-bottom)) !important; max-width: none !important; }
}

@media (max-width: 400px) {
  .app-stat .lbl { display: none; }
  .app-stat { min-width: 40px; }
}

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