/* ── Gemora Chat widget - styl marki (bordo #4a122b / malina #9c1146 / grafit #232323) ── */
#gemora-chat, #gemora-chat * { box-sizing: border-box; }
#gemora-chat {
  --gc-brand: #4a122b;
  --gc-brand-2: #9c1146;
  --gc-ink: #232323;
  --gc-bg: #ffffff;
  --gc-soft: #faf6f8;
  --gc-border: #ece6e9;
  --gc-muted: #8a8088;
  position: fixed; right: 20px; bottom: 20px; z-index: 999999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Dymek */
#gemora-chat .gc-bubble {
  position: relative;
  width: 60px; height: 60px; border-radius: 50%; padding: 0; margin: 0;
  background: var(--gc-brand); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 8px 24px rgba(74,18,43,.35);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s, box-shadow .15s;
}
#gemora-chat .gc-bubble:hover { background: var(--gc-brand-2); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(156,17,70,.4); }
#gemora-chat .gc-bubble svg { width: 28px; height: 28px; }
#gemora-chat .gc-dot {
  position: absolute; top: -2px; right: -2px; width: 14px; height: 14px;
  background: var(--gc-brand-2); border: 2px solid #fff; border-radius: 50%; display: none;
}

/* Podgląd odpowiedzi przy dymku (gdy panel zamknięty) - klient widzi, że odpisaliśmy */
#gemora-chat .gc-peek {
  position: absolute; right: 0; bottom: 74px; display: none;
  width: 240px; max-width: calc(100vw - 40px);
  background: #fff; color: var(--gc-ink);
  border: .5px solid var(--gc-border); border-left: 3px solid var(--gc-brand-2);
  border-radius: 12px; padding: 9px 12px; font-size: 13px; line-height: 1.4;
  box-shadow: 0 10px 28px rgba(35,35,35,.22); cursor: pointer;
  animation: gcIn .18s ease;
}
#gemora-chat .gc-peek::before { content: 'Gemma'; display: block; font-weight: 700; font-size: 11px; color: var(--gc-brand-2); margin-bottom: 2px; }
#gemora-chat.gc-open .gc-peek { display: none !important; }

/* Panel */
#gemora-chat .gc-panel {
  position: absolute; right: 0; bottom: 74px;
  width: 374px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 110px);
  background: var(--gc-bg); border-radius: 16px;
  box-shadow: 0 16px 48px rgba(35,35,35,.28);
  display: none; flex-direction: column; overflow: hidden;
  animation: gcIn .18s ease;
}
@keyframes gcIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
#gemora-chat.gc-open .gc-panel { display: flex; }
#gemora-chat.gc-open .gc-bubble { display: none; }

/* Header */
#gemora-chat .gc-head {
  background: linear-gradient(135deg, var(--gc-brand-2) 0%, var(--gc-brand) 100%); color: #fff; padding: 15px 16px;
  display: flex; align-items: center; gap: 10px;
}
#gemora-chat .gc-head-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 7px; }
#gemora-chat .gc-head-title::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25);
}
#gemora-chat .gc-head-sub { font-size: 11.5px; opacity: .85; margin-top: 1px; }
#gemora-chat .gc-close {
  margin-left: auto; background: transparent; border: none; color: #fff;
  font-size: 22px; cursor: pointer; line-height: 1; opacity: .85; padding: 0 4px;
}
#gemora-chat .gc-close:hover { opacity: 1; }

/* Ciało panelu - wypełnia całą wysokość pod nagłówkiem (flex column).
   min-height:0 jest KLUCZOWE, żeby lista wiadomości mogła się scrollować zamiast rozpychać panel. */
#gemora-chat .gc-body { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

/* Wiadomości */
#gemora-chat .gc-msgs {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px;
  background: var(--gc-soft);
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
}
#gemora-chat .gc-msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
#gemora-chat .gc-me  { align-self: flex-end; background: var(--gc-brand); color: #fff; border-bottom-right-radius: 4px; }
#gemora-chat .gc-them { align-self: flex-start; background: #fff; color: var(--gc-ink); border: .5px solid var(--gc-border); border-bottom-left-radius: 4px; }
#gemora-chat .gc-link { color: var(--gc-brand-2); text-decoration: underline; word-break: break-all; }
/* Komunikat systemowy (np. dołączenie konsultanta) - wyśrodkowany, subtelny, nie dymek */
#gemora-chat .gc-sys { align-self: center; max-width: 90%; text-align: center; font-size: 11.5px; color: var(--gc-muted); background: rgba(35,35,35,.05); padding: 5px 12px; border-radius: 10px; margin: 2px 0; }
#gemora-chat .gc-me .gc-link { color: #fff; }

/* Wskaźnik "pisze" (3 kropki) */
#gemora-chat .gc-typing { align-self: flex-start; background: #fff; border: .5px solid var(--gc-border); border-radius: 14px; border-bottom-left-radius: 4px; padding: 11px 13px; display: flex; gap: 4px; }
#gemora-chat .gc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--gc-muted); opacity: .5; animation: gcDot 1.2s infinite; }
#gemora-chat .gc-typing span:nth-child(2) { animation-delay: .2s; }
#gemora-chat .gc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes gcDot { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Karty produktów (rekomendacje od Gemmy) */
#gemora-chat .gc-prods { align-self: flex-start; max-width: 92%; display: flex; flex-direction: column; gap: 7px; }
#gemora-chat .gc-prodcard { display: flex; gap: 10px; align-items: center; background: #fff; border: .5px solid var(--gc-border); border-radius: 12px; padding: 8px; text-decoration: none; color: var(--gc-ink); transition: border-color .15s, box-shadow .15s; }
#gemora-chat .gc-prodcard:hover { border-color: var(--gc-brand-2); box-shadow: 0 4px 12px rgba(74,18,43,.1); }
#gemora-chat .gc-prodcard img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--gc-soft); }
#gemora-chat .gc-prodcard .gc-pc-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
#gemora-chat .gc-prodcard .gc-pc-go { font-size: 11.5px; color: var(--gc-brand-2); margin-top: 2px; }

/* Zgoda (consent gate) */
#gemora-chat .gc-consent { padding: 18px 16px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
#gemora-chat .gc-consent h4 { font-size: 15px; margin: 0 0 6px; color: var(--gc-ink); }
#gemora-chat .gc-consent p { font-size: 12.5px; color: var(--gc-muted); line-height: 1.5; margin: 0 0 12px; }
#gemora-chat .gc-field { margin-bottom: 10px; }
#gemora-chat .gc-field label { display: block; font-size: 11px; color: var(--gc-muted); margin-bottom: 3px; }
#gemora-chat .gc-field label .gc-req { color: var(--gc-brand-2); }
#gemora-chat .gc-input {
  width: 100%; padding: 9px 11px; border: .5px solid var(--gc-border); border-radius: 9px;
  font-size: 16px; color: var(--gc-ink); outline: none; font-family: inherit;
}
#gemora-chat .gc-input:focus { border-color: var(--gc-brand); }
#gemora-chat .gc-input.gc-err { border-color: var(--gc-brand-2); background: #fdf2f6; }
#gemora-chat .gc-consent-row { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--gc-ink); margin: 6px 0 14px; }
#gemora-chat .gc-consent-row input { margin-top: 2px; accent-color: var(--gc-brand); }
#gemora-chat .gc-consent-row a { color: var(--gc-brand-2); text-decoration: underline; }
#gemora-chat .gc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Załącznik - zdjęcie w bąbelku */
#gemora-chat .gc-msg-img { padding: 4px; }
#gemora-chat .gc-att { display: block; }
#gemora-chat .gc-att-img { display: block; max-width: 200px; max-height: 220px; width: auto; height: auto; border-radius: 10px; }
#gemora-chat .gc-att-cap { margin-top: 6px; padding: 0 8px 4px; }

/* Podgląd wybranego zdjęcia (nad polem wpisywania) */
#gemora-chat .gc-preview { flex-shrink: 0; display: none; align-items: center; gap: 8px; padding: 8px 10px; border-top: .5px solid var(--gc-border); background: #fff; }
#gemora-chat .gc-prev-img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: .5px solid var(--gc-border); }
#gemora-chat .gc-prev-x { border: none; background: var(--gc-soft); color: var(--gc-ink); width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; }
#gemora-chat .gc-prev-x:hover { background: #f0e6ea; }

/* Przycisk dodania zdjęcia */
#gemora-chat .gc-attach { width: 40px; height: 40px; flex-shrink: 0; border: none; padding: 0; margin: 0; border-radius: 10px; background: var(--gc-soft); color: var(--gc-brand); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
#gemora-chat .gc-attach:hover { background: #f0e6ea; }
#gemora-chat .gc-attach svg { width: 24px; height: 24px; }

/* Composer */
#gemora-chat .gc-composer { flex-shrink: 0; display: flex; gap: 8px; padding: 10px; border-top: .5px solid var(--gc-border); background: #fff; align-items: flex-end; }
#gemora-chat .gc-ta {
  flex: 1; resize: none; max-height: 100px; min-height: 40px; padding: 9px 11px;
  border: .5px solid var(--gc-border); border-radius: 10px; font-size: 16px; line-height: 1.4;
  color: var(--gc-ink); outline: none; font-family: inherit;
}
#gemora-chat .gc-ta:focus { border-color: var(--gc-brand); }
#gemora-chat .gc-send {
  width: 40px; height: 40px; flex-shrink: 0; border: none; padding: 0; margin: 0; border-radius: 10px;
  background: var(--gc-brand); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
#gemora-chat .gc-send:hover { background: var(--gc-brand-2); }
#gemora-chat .gc-send:disabled { opacity: .5; cursor: default; }
#gemora-chat .gc-send svg { width: 22px; height: 22px; }

#gemora-chat .gc-btn {
  width: 100%; padding: 11px; border: none; border-radius: 10px; background: var(--gc-brand);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s;
}
#gemora-chat .gc-btn:hover { background: var(--gc-brand-2); }
#gemora-chat .gc-btn:disabled { opacity: .5; cursor: default; }
#gemora-chat .gc-foot { flex-shrink: 0; text-align: center; font-size: 10px; color: var(--gc-muted); padding: 6px; background: #fff; }

/* Ikony theme-proof: motyw sklepu (Kadence) potrafi nadpisać `color` na przyciskach,
   przez co ikony rysowane currentColor znikają. Wymuszamy kolor kresek na sztywno. */
#gemora-chat .gc-bubble svg { fill: #fff !important; stroke: none !important; width: 28px !important; height: 28px !important; }
#gemora-chat .gc-send svg   { fill: #fff !important; stroke: none !important; width: 22px !important; height: 22px !important; }
#gemora-chat .gc-attach svg { fill: none !important; stroke: var(--gc-brand) !important; stroke-width: 2.2 !important; width: 22px !important; height: 22px !important; }

/* Mobile: czat na CAŁY ekran (jak Chatway) - nagłówek z X zawsze na górze, lista scrolluje,
   composer nad klawiaturą (wysokość/pozycję dostraja JS przez Visual Viewport). */
@media (max-width: 768px) {
  #gemora-chat { right: 14px; bottom: 14px; }
  #gemora-chat.gc-open .gc-panel {
    position: fixed; top: 0; left: 0; right: auto; bottom: auto;
    width: 100vw; height: 100vh; height: 100dvh;
    max-width: none; max-height: none; border-radius: 0;
  }
  #gemora-chat.gc-open .gc-head { border-radius: 0; }
}

/* ── Ankieta oceny po zamknięciu rozmowy ── */
#gemora-chat .gc-survey {
  align-self: stretch; margin: 6px 0 4px; padding: 14px;
  background: var(--gc-soft, #f7f3f5); border: .5px solid var(--gc-border, #eadfe4);
  border-radius: 12px; display: flex; flex-direction: column; gap: 10px;
}
#gemora-chat .gc-survey-q { font-size: 13.5px; font-weight: 700; color: var(--gc-brand); text-align: center; }
#gemora-chat .gc-stars { display: flex; justify-content: center; gap: 6px; }
#gemora-chat .gc-star {
  background: none; border: none; padding: 2px; margin: 0; cursor: pointer;
  font-size: 30px; line-height: 1; color: #d8cdd3; transition: color .12s, transform .12s;
}
#gemora-chat .gc-star:hover { transform: scale(1.12); }
#gemora-chat .gc-star.on { color: #f5a623; }
#gemora-chat .gc-survey-txt {
  width: 100%; box-sizing: border-box; resize: none; font-family: inherit; font-size: 14px;
  padding: 9px 11px; border: .5px solid var(--gc-border, #eadfe4); border-radius: 9px; background: #fff; color: #232323;
}
#gemora-chat .gc-survey-txt:focus { outline: none; border-color: var(--gc-brand); }
#gemora-chat .gc-survey-send {
  width: 100%; padding: 10px; border: none; border-radius: 9px; background: var(--gc-brand); color: #fff;
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .15s;
}
#gemora-chat .gc-survey-send:hover:not(:disabled) { background: var(--gc-brand-2); }
#gemora-chat .gc-survey-send:disabled { opacity: .5; cursor: default; }
#gemora-chat .gc-survey-done { font-weight: 600; color: var(--gc-brand-2); }
