/* Prezentigrawer Chat Widget — v1.0.6 */

/* Prefiks prchat- zapobiega konfliktom z motywem WordPress */

/* ─── Karty produktów ─── */
.prchat-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  margin: 8px 0;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  max-width: 240px;
}
.prchat-card-body {
  padding: 10px 12px 12px;
}
.prchat-card-name {
  font-weight: 700;
  font-size: 13.5px;
  color: #1e293b;
  margin-bottom: 3px;
  line-height: 1.3;
}
.prchat-card-price {
  font-size: 14px;
  font-weight: 700;
  color: #16a34a;
  margin-bottom: 10px;
}
.prchat-card-btn {
  display: inline-block;
  background: #2563eb;
  color: #fff !important;
  text-decoration: none !important;
  border: none !important;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.prchat-card-btn:hover {
  background: #1d4ed8;
}

/* ─── Popup powitalny ─── */
#prchat-popup {
  position: fixed;
  bottom: 104px;
  left: 28px;
  background: white;
  border-radius: 16px;
  padding: 14px 36px 14px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);
  z-index: 9997;
  max-width: 240px;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  color: #1e293b;
  transform: translateY(0);
  opacity: 1;
  transition: opacity .3s, transform .3s;
  border: 1px solid #f1f5f9;
  display: none;
}
#prchat-popup.prchat-popup-visible {
  display: block;
}
#prchat-popup.prchat-popup-hidden {
  opacity: 0 !important;
  transform: translateY(8px) !important;
  pointer-events: none;
}
#prchat-popup::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 24px;
  width: 14px;
  height: 14px;
  background: white;
  border-right: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  transform: rotate(45deg);
}
#prchat-popup p {
  margin: 0;
  padding: 0;
}
#prchat-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s;
}
#prchat-popup-close:hover {
  background: #e2e8f0;
  color: #1e293b;
}

#prchat-toggle {
  position: fixed;
  bottom: 28px;
  left: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(37,99,235,.5);
  z-index: 9998;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#prchat-toggle:hover {
  transform: scale(1.12);
  box-shadow: 0 10px 32px rgba(37,99,235,.6);
}
#prchat-toggle svg {
  width: 28px;
  height: 28px;
}
#prchat-toggle .prchat-icon-close { display: none; }
#prchat-toggle.open .prchat-icon-chat  { display: none; }
#prchat-toggle.open .prchat-icon-close { display: block; }

#prchat-badge {
  position: fixed;
  bottom: 76px;
  left: 72px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(239,68,68,.4);
  font-family: system-ui, -apple-system, sans-serif;
}

#prchat-window {
  position: fixed;
  bottom: 104px;
  left: 28px;
  width: 370px;
  max-height: 580px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform: scale(0) translateY(16px);
  transform-origin: bottom left;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  opacity: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* Izolacja od stylów motywu */
  box-sizing: border-box;
  line-height: normal;
  text-align: left;
}
#prchat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
}
#prchat-window *,
#prchat-window *::before,
#prchat-window *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#prchat-header {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
#prchat-header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: rgba(255,255,255,.15);
}
.prchat-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.3);
}
.prchat-header-info h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: white;
  margin: 0;
}
.prchat-header-info p {
  font-size: 11.5px;
  opacity: .75;
  margin-top: 1px;
  color: white;
}
#prchat-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #94a3b8;
  margin-left: auto;
  box-shadow: 0 0 0 3px rgba(148,163,184,.3);
  flex-shrink: 0;
  transition: background .3s;
}
#prchat-status-dot.online {
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74,222,128,.3);
}

#prchat-mode-banner {
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 18px;
  text-align: center;
  display: none;
  flex-shrink: 0;
}

#prchat-quick-replies {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
}
.prchat-quick-btn {
  background: white;
  border: 1.5px solid #bfdbfe;
  color: #1e40af;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s;
  font-family: inherit;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}
.prchat-quick-btn:hover {
  background: #eff6ff;
  border-color: #3b82f6;
}

#prchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#prchat-messages::-webkit-scrollbar { width: 4px; }
#prchat-messages::-webkit-scrollbar-track { background: transparent; }
#prchat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

.prchat-msg { width: fit-content; max-width: 78%; display: flex; flex-direction: column; gap: 3px; }
.prchat-msg.user   { align-self: flex-end;   align-items: flex-end; }
.prchat-msg.bot    { align-self: flex-start; align-items: flex-start; }
.prchat-msg.system { align-self: center; max-width: 90%; }

.prchat-msg .prchat-author {
  font-size: 10px;
  color: #94a3b8;
  padding: 0 6px;
  font-weight: 500;
}
.prchat-msg .prchat-bubble {
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
  color: #1e293b;
  min-width: 60px;
}
.prchat-msg.user  .prchat-bubble {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  border-bottom-right-radius: 5px;
  display: inline-block;
  width: fit-content;
  max-width: 100%;
}
.prchat-msg.bot   .prchat-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 5px;
}
.prchat-msg.system .prchat-bubble {
  background: #f0fdf4;
  color: #166534;
  font-size: 12px;
  text-align: center;
  border-radius: 10px;
  padding: 7px 14px;
  border: 1px solid #bbf7d0;
}

#prchat-typing { display: none; align-self: flex-start; }
.prchat-typing-dots {
  display: flex; gap: 5px;
  padding: 11px 15px;
  background: #f1f5f9;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
}
.prchat-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #94a3b8;
  animation: prchat-bounce .9s infinite;
}
.prchat-typing-dots span:nth-child(2) { animation-delay: .15s; }
.prchat-typing-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes prchat-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

#prchat-input-area {
  padding: 12px 14px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}
#prchat-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  resize: none;
  max-height: 80px;
  overflow-y: auto;
  line-height: 1.4;
  color: #1e293b;
  background: #f8fafc;
}
#prchat-input:focus {
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
#prchat-input::placeholder { color: #94a3b8; }

#prchat-send {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  border: none; border-radius: 50%;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(37,99,235,.35);
  padding: 0;
}
#prchat-send:hover { transform: scale(1.08); box-shadow: 0 5px 16px rgba(37,99,235,.45); }
#prchat-send:disabled { background: #cbd5e1; box-shadow: none; cursor: default; transform: none; }
#prchat-send svg { width: 18px; height: 18px; }

/* Responsywność na mobile — powiększenie x2.5 */
@media (max-width: 600px) {

  /* Toggle (przycisk kuli) */
  #prchat-toggle {
    width: 58px;
    height: 58px;
    bottom: 16px;
    left: 16px;
    box-shadow: 0 8px 32px rgba(37,99,235,.55);
  }
  #prchat-toggle svg {
    width: 26px;
    height: 26px;
  }

  /* Odznaka z liczbą wiadomości */
  #prchat-badge {
    bottom: 64px;
    left: 64px;
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

  /* Okno chatu — pełna szerokość i większa wysokość */
  #prchat-window {
    width: calc(100vw - 20px);
    left: 10px;
    right: 10px;
    bottom: 86px;
    max-height: calc(100vh - 118px);
    border-radius: 24px;
  }

  /* Header */
  #prchat-header {
    padding: 22px 22px;
    gap: 16px;
  }
  .prchat-avatar {
    width: 64px;
    height: 64px;
    font-size: 32px;
  }
  .prchat-header-info h3 {
    font-size: 20px;
  }
  .prchat-header-info p {
    font-size: 15px;
  }
  #prchat-status-dot {
    width: 14px;
    height: 14px;
  }

  /* Przyciski szybkich odpowiedzi */
  #prchat-quick-replies {
    padding: 14px 18px;
    gap: 10px;
  }
  .prchat-quick-btn {
    font-size: 16px;
    padding: 10px 20px;
    border-radius: 24px;
  }

  /* Wiadomości */
  #prchat-messages {
    padding: 22px 18px 10px;
    gap: 14px;
  }
  .prchat-msg .prchat-bubble {
    font-size: 17px;
    padding: 14px 18px;
    border-radius: 22px;
  }
  .prchat-msg .prchat-author {
    font-size: 13px;
  }

  /* Input i przycisk wyślij */
  #prchat-input-row {
    padding: 14px 16px;
    gap: 10px;
  }
  #prchat-input {
    font-size: 17px;
    padding: 14px 18px;
    border-radius: 28px;
  }
  #prchat-send {
    width: 52px;
    height: 52px;
    border-radius: 50%;
  }
  #prchat-send svg {
    width: 24px;
    height: 24px;
  }

  /* Baner trybu */
  #prchat-mode-banner {
    font-size: 15px;
    padding: 10px 18px;
  }

  /* Karty produktów */
  .prchat-card {
    max-width: 100%;
  }
  .prchat-card-name { font-size: 17px; }
  .prchat-card-price { font-size: 18px; }
  .prchat-card-btn {
    font-size: 16px;
    padding: 11px 20px;
  }
  .prchat-card img {
    height: 220px;
  }

  /* Popup */
  #prchat-popup {
    left: 16px;
    right: 16px;
    max-width: none;
    bottom: 126px;
    font-size: 17px;
    padding: 18px 44px 18px 20px;
  }
  #prchat-popup-close {
    width: 30px;
    height: 30px;
    font-size: 20px;
  }
}
