/* ===================================================================
   AI Contact Hub - style strony /kontakt
   Sesja 106 v2 | Widget chat = 1:1 z widget v4 (bsw-*), tu tylko
   style dla HERO + ALTERNATYW + EMBED OVERRIDES dla #bsw-root
   =================================================================== */

/* Lokalne tokeny spojne z widget v4 (tylko dla hero/alt - sam widget
   ma wlasne zmienne w #bsw-root) */
.ach-root {
  --ach-bg: #FAF9F5;
  --ach-surface: #FFFFFF;
  --ach-text: #1F1E1D;
  --ach-text-muted: #6B6A66;
  --ach-text-subtle: #A8A6A0;
  --ach-accent: #D97757;
  --ach-accent-dark: #99462A;
  --ach-accent-soft: #FDF2ED;
  --ach-border: rgba(136, 114, 108, 0.15);
  --ach-font-serif: "Newsreader", "Georgia", serif;
  --ach-font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --ach-radius-md: 16px;
  --ach-radius-lg: 20px;
  --ach-shadow-lift: 0 12px 32px rgba(25, 24, 23, 0.08);

  width: 100%;
  max-width: none;
  margin: 0;
  padding: 140px clamp(16px, 4vw, 96px) 64px;
  color: var(--ach-text);
  background: var(--ach-bg);
  font-family: var(--ach-font-sans);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

html.dark .ach-root,
html[data-theme="dark"] .ach-root {
  --ach-bg: #1F1E1D;
  --ach-surface: #2A2927;
  --ach-text: #F5F4EE;
  --ach-text-muted: #A8A6A0;
  --ach-text-subtle: #6B6A66;
  --ach-accent: #E8896A;
  --ach-accent-dark: #D97757;
  --ach-accent-soft: rgba(232, 137, 106, 0.12);
  --ach-border: rgba(219, 193, 185, 0.12);
  --ach-shadow-lift: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.ach-root * { box-sizing: border-box; }

/* ------------------------------------------------------------------
   HERO
   ------------------------------------------------------------------ */
.ach-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: none;     /* zeby h1 zmiescil sie w jednej linii na desktop */
  margin: 0 auto;
}

.ach-hero-eyebrow {
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ach-accent-dark);
  display: inline-block;
  margin: 0 auto -4px;
}

html.dark .ach-hero-eyebrow,
html[data-theme="dark"] .ach-hero-eyebrow {
  color: var(--ach-accent);
}

.ach-hero h1 {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ach-text);
  margin: 0;
  white-space: nowrap; /* desktop: 1 linia */
}

@media (max-width: 680px) {
  .ach-hero h1 {
    white-space: normal;
    font-size: 26px;
    letter-spacing: -0.01em;
  }
}

.ach-hero-sub {
  font-family: 'Manrope', sans-serif;
  font-weight: 400;
  font-size: 16px;
  color: var(--ach-text-muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ------------------------------------------------------------------
   CHAT MOUNT - tu widget v4 (#bsw-root) zostanie przeniesiony przez
   widget-embed-bootstrap.js
   ------------------------------------------------------------------ */
.ach-chat-mount {
  width: 100%;
  display: flex;
  justify-content: center;
  min-height: 720px;  /* rezerwacja miejsca PRZED zaladowaniem widgetu */
}

/* ======================================================
   EMBED OVERRIDES dla #bsw-root (widget v4)
   Zmieniamy z "floating panel" na "embed card"
   Wszystko z !important bo widget ma inline !important
   ====================================================== */

/* FAB niepotrzebny w embed mode */
#bsw-fab {
  display: none !important;
}

/* Panel: embed zamiast fixed floating */
body.ach-bsw-embed #bsw-root,
#bsw-root.bsw-embed {
  /* position: relative - kluczowe! dock i topbar sa absolute i potrzebuja kontekstu */
  position: relative !important;
  z-index: auto !important;
  right: auto !important;
  left: auto !important;
  bottom: auto !important;
  top: auto !important;
  width: 100% !important;
  max-width: 900px !important;
  height: 720px !important;
  max-height: calc(100vh - 180px) !important;
  margin: 0 auto !important;
  transform: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transition: none !important;
  border-radius: 24px !important;
  border: 1px solid rgba(136, 114, 108, 0.18) !important;
  box-shadow: 0 1px 2px rgba(25, 24, 23, 0.04), 0 8px 32px rgba(25, 24, 23, 0.06) !important;
}

html.dark #bsw-root.bsw-embed,
html[data-theme="dark"] #bsw-root.bsw-embed {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24), 0 8px 32px rgba(0, 0, 0, 0.28) !important;
  border-color: rgba(219, 193, 185, 0.12) !important;
}

/* Poswiata fioletowa gdy AI mysli.
   Uwaga: #bsw-root ma overflow:hidden (z widget-client.js) - dlatego ::before + box-shadow
   byly przycinane. Rozwiazanie: wrapper ach-chat-mount dostaje filter:drop-shadow
   ktory renderuje sie POZA panelem (nie jest clipowany przez overflow panelu). */
.ach-chat-mount {
  transition: filter 0.4s ease;
}

body.ach-bsw-embed.ach-thinking .ach-chat-mount,
.ach-chat-mount.ach-thinking {
  animation: ach-embed-thinking-glow 2.2s ease-in-out infinite;
}

@keyframes ach-embed-thinking-glow {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(177, 123, 255, 0.20));
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(177, 123, 255, 0.45));
  }
}

/* Mobile: prawie pelny ekran ale z marginesami */
@media (max-width: 680px) {
  body.ach-bsw-embed #bsw-root,
  #bsw-root.bsw-embed {
    max-width: 100% !important;
    height: calc(100vh - 160px) !important;
    max-height: calc(100vh - 160px) !important;
    border-radius: 20px !important;
  }
}

/* ------------------------------------------------------------------
   FORMULARZ ESKALACJI - kompakt 2 kolumny zeby zmiescic w 720px panelu
   Nadpisujemy inline CSS widget-client.js (z !important)
   ------------------------------------------------------------------ */
#bsw-root.bsw-embed .bsw-escalation {
  margin: 16px 0 !important;
  padding: 24px 24px !important;
  scroll-margin-top: 80px; /* topbar 64px + 16px oddech */
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  column-gap: 18px;
  row-gap: 4px;
}

/* Pelna szerokosc dla h3, lead, submit, note, privacy */
#bsw-root.bsw-embed .bsw-escalation h3,
#bsw-root.bsw-embed .bsw-escalation p.bsw-lead,
#bsw-root.bsw-embed .bsw-escalation-submit,
#bsw-root.bsw-embed .bsw-escalation-note,
#bsw-root.bsw-embed .bsw-escalation-privacy {
  grid-column: 1 / -1;
}

#bsw-root.bsw-embed .bsw-escalation h3 {
  font-size: 19px !important;
  margin: 0 !important;
}

#bsw-root.bsw-embed .bsw-escalation p.bsw-lead {
  margin: 2px 0 14px !important;
  font-size: 13px !important;
}

#bsw-root.bsw-embed .bsw-escalation label {
  margin: 10px 0 5px !important;
  font-size: 11px !important;
}

#bsw-root.bsw-embed .bsw-escalation input,
#bsw-root.bsw-embed .bsw-escalation textarea {
  padding: 11px 12px !important;
  font-size: 14.5px !important;
}

#bsw-root.bsw-embed .bsw-escalation textarea {
  min-height: 130px !important;
  resize: none !important;
}

#bsw-root.bsw-embed .bsw-escalation-submit {
  margin-top: 16px !important;
  padding: 13px !important;
  font-size: 15px !important;
}

#bsw-root.bsw-embed .bsw-escalation-note {
  margin: 10px 0 0 !important;
  font-size: 12px !important;
}

#bsw-root.bsw-embed .bsw-escalation-privacy {
  margin-top: 4px !important;
}

/* Explicit grid-area per dziecko (struktura: h3, lead, label+input x5, label+textarea, submit, note, privacy) */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(1),  /* h3 */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(2),  /* lead */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(3),  /* label Imie */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(4),  /* input Imie */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(13), /* label Wiadomosc */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(14), /* textarea */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(15), /* submit */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(16), /* note */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(17)  /* privacy */ {
  grid-column: 1 / -1;
}

/* Parowanie: Email+Telefon, NIP+Firma */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(5),  /* label Email */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(6),  /* input Email */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(9),  /* label NIP */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(10) /* div NIP */ {
  grid-column: 1;
}
#bsw-root.bsw-embed .bsw-escalation > :nth-child(7),  /* label Telefon */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(8),  /* input Telefon */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(11), /* label Firma */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(12) /* input Firma */ {
  grid-column: 2;
}

/* Rzedy: label Email i label Telefon w tym samym rzedzie (5). Inputy w 6. Analogicznie NIP/Firma w 7/8. */
#bsw-root.bsw-embed .bsw-escalation > :nth-child(5),
#bsw-root.bsw-embed .bsw-escalation > :nth-child(7) { grid-row: 5; }

#bsw-root.bsw-embed .bsw-escalation > :nth-child(6),
#bsw-root.bsw-embed .bsw-escalation > :nth-child(8) { grid-row: 6; }

#bsw-root.bsw-embed .bsw-escalation > :nth-child(9),
#bsw-root.bsw-embed .bsw-escalation > :nth-child(11) { grid-row: 7; }

#bsw-root.bsw-embed .bsw-escalation > :nth-child(10),
#bsw-root.bsw-embed .bsw-escalation > :nth-child(12) { grid-row: 8; }

/* Mobile: wszystko 1 kolumna (male ekrany nie ma gdzie upchnac) */
@media (max-width: 560px) {
  #bsw-root.bsw-embed .bsw-escalation {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------
   WYLACZ ITALIC (Poppins italic wyglada dramatycznie z nowym fontem).
   Globalny widget-client.js wymusza font-style:italic dla welcome/topbar/
   thinking/banner/escalation-lead - tu nadpisujemy lokalnie.
   ------------------------------------------------------------------ */
#bsw-root.bsw-embed .bsw-welcome-greeting,
#bsw-root.bsw-embed .bsw-topbar-program,
#bsw-root.bsw-embed .bsw-thinking,
#bsw-root.bsw-embed .bsw-banner,
#bsw-root.bsw-embed .bsw-escalation .bsw-lead {
  font-style: normal !important;
}

/* ------------------------------------------------------------------
   PRZYCISK "Formularz kontaktowy" - wstrzykniety jako dziecko #bsw-welcome.
   Divider uzywa natywnej klasy .bsw-welcome-divider (identyczny 1:1).
   Border-radius 14px (spojny z reszta widgetu v5). Margin-bottom 32px
   zeby button byl wyzej nad dock-pill (input na dole panelu).
   ------------------------------------------------------------------ */
#bsw-root .ach-alt-action {
  width: auto !important;
  padding: 10px 18px !important;
  border: 1px solid var(--bsw-border) !important;
  border-radius: 14px !important;
  justify-content: center !important;
  gap: 10px !important;
  margin: 0 auto 32px !important;
  transition: background 0.15s, border-color 0.15s !important;
}

#bsw-root .ach-alt-action:hover {
  background: var(--bsw-accent-soft) !important;
  border-color: var(--bsw-accent) !important;
}

/* CTA wstrzykiwane pod wiadomoscia AI ("Otworz formularz kontaktowy") - ten sam styl co welcome button */
#bsw-root .ach-inline-cta {
  width: auto !important;
  padding: 10px 18px !important;
  border: 1px solid var(--bsw-border) !important;
  border-radius: 14px !important;
  justify-content: center !important;
  gap: 10px !important;
  margin: 12px 0 0 !important;
  transition: background 0.15s, border-color 0.15s !important;
}

#bsw-root .ach-inline-cta:hover {
  background: var(--bsw-accent-soft) !important;
  border-color: var(--bsw-accent) !important;
}

/* ------------------------------------------------------------------
   FAQ TEASER
   ------------------------------------------------------------------ */
.ach-faq-teaser {
  text-align: center;
  font-size: 14px;
  color: var(--ach-text-muted);
  margin: 0;
}

.ach-faq-teaser a {
  color: var(--ach-text);
  text-decoration: underline;
  text-decoration-color: rgba(136, 114, 108, 0.35);
  text-underline-offset: 3px;
  font-weight: 500;
  transition: text-decoration-color 0.15s;
}

.ach-faq-teaser a:hover {
  text-decoration-color: var(--ach-accent);
}

html.dark .ach-faq-teaser a,
html[data-theme="dark"] .ach-faq-teaser a {
  text-decoration-color: rgba(219, 193, 185, 0.35);
}

/* ------------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------------ */
@media (max-width: 680px) {
  .ach-root {
    /* nav fixed 64px + notch safe-area + oddech - hero h1 nie moze byc obciety przez fixed nav */
    padding: calc(96px + env(safe-area-inset-top, 0px)) 16px 48px;
    gap: 24px;
  }
  .ach-hero h1 { font-size: 30px; }
  .ach-hero-sub { font-size: 15px; }
  .ach-chat-mount { min-height: calc(100vh - 160px); }

  /* Widget embed - mobile: zmniejsz welcome aby pills i button zmiescily sie w viewport */
  #bsw-root.bsw-embed .bsw-welcome-greeting {
    font-size: 17px !important;
    line-height: 1.3 !important;
    max-width: 280px !important;
  }
  #bsw-root.bsw-embed .bsw-brand-mark {
    width: 40px !important;
    height: 40px !important;
  }
  /* Ukryj text "BinSoft AI" na mobile - logo wystarcza */
  #bsw-root.bsw-embed .bsw-brand-text {
    display: none !important;
  }
  #bsw-root.bsw-embed .bsw-brand-logo {
    gap: 0 !important;
  }
  #bsw-root.bsw-embed #bsw-welcome {
    gap: 8px !important;
    padding: 8px 16px 4px !important;
    min-height: auto !important;
    justify-content: flex-start !important;
  }
  #bsw-root.bsw-embed .ach-alt-action {
    margin: 0 auto !important;
    padding: 7px 14px !important;
    font-size: 13px !important;
  }
  #bsw-root.bsw-embed .bsw-welcome-suggestions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 320px !important;
  }
  #bsw-root.bsw-embed .bsw-welcome-suggestion {
    font-size: 12.5px !important;
    padding: 6px 8px !important;
    white-space: normal !important;
    text-align: center !important;
    min-height: 32px !important;
  }
  #bsw-root.bsw-embed .bsw-welcome-divider {
    margin: 2px auto !important;
  }
  #bsw-root.bsw-embed .bsw-welcome-suggestions-label {
    margin: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ach-alt-card { transition: none; }
}
