/* =========================================================
   Daga po angielsku — wbudowany czat / wirtualna asystentka
   W pełni offline (bez API i internetu). Prefiks: .dchat
   ========================================================= */

.dchat, .dchat * { box-sizing: border-box; }

.dchat {
  --dc-orange:      oklch(0.705 0.150 52);
  --dc-orange-deep: oklch(0.640 0.155 48);
  --dc-rose-deep:   oklch(0.720 0.105 16);
  --dc-espresso:    oklch(0.32 0.028 52);
  --dc-espresso-2:  oklch(0.46 0.030 50);
  --dc-muted:       oklch(0.58 0.024 55);
  --dc-white:       oklch(0.995 0.004 80);
  --dc-cream:       oklch(0.985 0.010 78);
  --dc-line:        oklch(0.90 0.020 70);
  --dc-bot-bg:      oklch(0.965 0.016 76);
  --dc-font-body:   "Manrope", system-ui, -apple-system, sans-serif;
  --dc-font-disp:   "Cormorant Garamond", Georgia, serif;
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 2147482000;
  font-family: var(--dc-font-body);
}

/* ---------- Launcher ---------- */
.dchat-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  height: 60px;
  padding: 0 22px 0 16px;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  color: var(--dc-white);
  background: linear-gradient(135deg, var(--dc-orange), var(--dc-orange-deep));
  box-shadow: 0 18px 42px -16px oklch(0.64 0.155 48 / 0.62);
  font-family: var(--dc-font-body);
  font-size: 1rem;
  font-weight: 700;
  transition: transform 0.35s cubic-bezier(0.22,0.61,0.36,1), box-shadow 0.35s;
}
.dchat-launcher:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 26px 56px -18px oklch(0.64 0.155 48 / 0.7); }
.dchat-launcher:focus-visible { outline: 3px solid var(--dc-rose-deep); outline-offset: 3px; }
.dchat-launcher .dchat-l-ico {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: grid; place-items: center;
  position: relative;
}
.dchat-launcher .dchat-l-ico svg { width: 26px; height: 26px; position: absolute; transition: opacity 0.25s, transform 0.3s; }
.dchat-launcher .ico-close { opacity: 0; transform: rotate(-45deg) scale(0.6); }
.dchat-l-label { white-space: nowrap; }

.dchat-badge {
  position: absolute;
  top: -5px; right: -3px;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 100px;
  background: var(--dc-rose-deep);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: grid; place-items: center;
  border: 2px solid var(--dc-cream);
  animation: dchatPop 0.4s cubic-bezier(0.22,0.61,0.36,1);
}
.dchat[data-unread="0"] .dchat-badge { display: none; }

/* Open state: launcher becomes round close button */
.dchat[data-open="true"] .dchat-l-label { display: none; }
.dchat[data-open="true"] .dchat-launcher { padding: 0; width: 60px; justify-content: center; }
.dchat[data-open="true"] .ico-chat { opacity: 0; transform: rotate(45deg) scale(0.6); }
.dchat[data-open="true"] .ico-close { opacity: 1; transform: rotate(0) scale(1); }

/* ---------- Panel ---------- */
.dchat-panel {
  position: absolute;
  left: 0;
  bottom: 74px;
  width: min(384px, calc(100vw - 40px));
  height: min(620px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  background: var(--dc-cream);
  border: 1px solid var(--dc-line);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 50px 110px -40px oklch(0.45 0.09 48 / 0.55), 0 0 0 1px oklch(1 0 0 / 0.5) inset;
  transform-origin: left bottom;
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.34s cubic-bezier(0.22,0.61,0.36,1);
}
.dchat[data-open="true"] .dchat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Header ---------- */
.dchat-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 16px 15px;
  background: linear-gradient(135deg, var(--dc-orange), var(--dc-orange-deep));
  color: var(--dc-white);
  position: relative;
}
.dchat-ava {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  background: oklch(1 0 0 / 0.18);
  border: 1.5px solid oklch(1 0 0 / 0.45);
  font-family: var(--dc-font-disp);
  font-weight: 700;
  font-size: 1.4rem;
}
.dchat-head-meta { display: flex; flex-direction: column; line-height: 1.25; }
.dchat-head-meta strong { font-size: 1.06rem; font-weight: 700; }
.dchat-head-meta span { font-size: 0.78rem; opacity: 0.92; display: inline-flex; align-items: center; gap: 6px; }
.dchat-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #7CFFB2; box-shadow: 0 0 0 0 rgba(124,255,178,0.7); animation: dchatPulse 2.4s infinite; }
.dchat-head .dchat-min {
  margin-left: auto;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: oklch(1 0 0 / 0.16);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.25s;
}
.dchat-head .dchat-min:hover { background: oklch(1 0 0 / 0.3); }
.dchat-head .dchat-min svg { width: 18px; height: 18px; }

/* ---------- Body ---------- */
.dchat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.dchat-body::-webkit-scrollbar { width: 8px; }
.dchat-body::-webkit-scrollbar-thumb { background: var(--dc-line); border-radius: 8px; }

.dchat-row { display: flex; gap: 9px; align-items: flex-end; max-width: 100%; animation: dchatIn 0.34s cubic-bezier(0.22,0.61,0.36,1); }
.dchat-row.bot { justify-content: flex-start; }
.dchat-row.user { justify-content: flex-end; }
.dchat-mini-ava {
  width: 28px; height: 28px; flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--dc-orange), var(--dc-rose-deep));
  color: #fff;
  font-family: var(--dc-font-disp);
  font-weight: 700; font-size: 0.92rem;
  margin-bottom: 2px;
}
.dchat-bubble {
  max-width: 80%;
  padding: 11px 15px;
  font-size: 0.95rem;
  line-height: 1.5;
  border-radius: 18px;
  word-wrap: break-word;
}
.dchat-row.bot .dchat-bubble {
  background: var(--dc-white);
  color: var(--dc-espresso);
  border: 1px solid var(--dc-line);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 10px -6px oklch(0.45 0.05 50 / 0.25);
}
.dchat-row.user .dchat-bubble {
  background: linear-gradient(135deg, var(--dc-orange), var(--dc-orange-deep));
  color: var(--dc-white);
  border-bottom-right-radius: 6px;
}
.dchat-bubble p { margin: 0 0 8px; }
.dchat-bubble p:last-child { margin-bottom: 0; }
.dchat-bubble strong { font-weight: 700; }
.dchat-bubble ul { margin: 6px 0 8px; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.dchat-bubble a {
  color: var(--dc-orange-deep);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1.5px solid oklch(0.64 0.155 48 / 0.4);
}
.dchat-bubble a:hover { border-bottom-color: var(--dc-orange-deep); }
.dchat-row.user .dchat-bubble a { color: #fff; border-bottom-color: rgba(255,255,255,0.6); }

/* Inline CTA button inside a bot bubble */
.dchat-bubble .dchat-cta {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 8px;
  padding: 9px 16px;
  border-radius: 100px;
  background: linear-gradient(135deg, var(--dc-orange), var(--dc-orange-deep));
  color: #fff !important;
  font-weight: 700; font-size: 0.9rem;
  border: none !important;
  box-shadow: 0 12px 26px -12px oklch(0.64 0.155 48 / 0.6);
}
.dchat-bubble .dchat-cta:hover { transform: translateY(-1px); }
.dchat-bubble .dchat-cta svg { width: 15px; height: 15px; }

/* Typing indicator */
.dchat-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.dchat-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--dc-muted); animation: dchatType 1.2s infinite; }
.dchat-typing i:nth-child(2) { animation-delay: 0.18s; }
.dchat-typing i:nth-child(3) { animation-delay: 0.36s; }

/* ---------- Quick-reply chips ---------- */
.dchat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 12px;
  flex: 0 0 auto;
}
.dchat-chip {
  border: 1.5px solid oklch(0.86 0.05 58 / 0.9);
  background: var(--dc-white);
  color: var(--dc-espresso-2);
  border-radius: 100px;
  padding: 8px 14px;
  font-family: var(--dc-font-body);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s;
  line-height: 1.2;
}
.dchat-chip:hover { border-color: var(--dc-orange); color: var(--dc-orange-deep); background: oklch(0.97 0.03 60 / 0.7); transform: translateY(-1px); }

/* ---------- Input ---------- */
.dchat-input {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-top: 1px solid var(--dc-line);
  background: var(--dc-white);
}
.dchat-input input {
  flex: 1 1 auto;
  border: 1.5px solid var(--dc-line);
  border-radius: 100px;
  padding: 12px 16px;
  font-family: var(--dc-font-body);
  font-size: 0.92rem;
  color: var(--dc-espresso);
  background: var(--dc-cream);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.dchat-input input::placeholder { color: var(--dc-muted); }
.dchat-input input:focus { border-color: var(--dc-orange); box-shadow: 0 0 0 4px oklch(0.705 0.15 52 / 0.14); }
.dchat-send {
  width: 46px; height: 46px; flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--dc-orange), var(--dc-orange-deep));
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.25s, box-shadow 0.25s, opacity 0.25s;
  box-shadow: 0 12px 26px -12px oklch(0.64 0.155 48 / 0.6);
}
.dchat-send:hover { transform: translateY(-2px) scale(1.04); }
.dchat-send:disabled { opacity: 0.45; cursor: default; transform: none; }
.dchat-send svg { width: 20px; height: 20px; }

/* ---------- Footer note ---------- */
.dchat-foot {
  padding: 9px 16px 12px;
  font-size: 0.72rem;
  color: var(--dc-muted);
  text-align: center;
  background: var(--dc-white);
  line-height: 1.4;
}
.dchat-foot a { color: var(--dc-orange-deep); font-weight: 700; text-decoration: none; }
.dchat-foot button.dchat-clear {
  border: none; background: none; color: var(--dc-muted);
  font-family: var(--dc-font-body); font-size: 0.72rem; cursor: pointer;
  text-decoration: underline; padding: 0; margin-left: 4px;
}
.dchat-foot button.dchat-clear:hover { color: var(--dc-orange-deep); }

/* ---------- Animations ---------- */
@keyframes dchatIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dchatPop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes dchatType { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes dchatPulse { 0% { box-shadow: 0 0 0 0 rgba(124,255,178,0.6); } 70% { box-shadow: 0 0 0 7px rgba(124,255,178,0); } 100% { box-shadow: 0 0 0 0 rgba(124,255,178,0); } }

@media (prefers-reduced-motion: reduce) {
  .dchat-launcher, .dchat-panel, .dchat-row, .dchat-send, .dchat-chip { transition: none; animation: none; }
  .dchat-status-dot, .dchat-badge { animation: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .dchat { left: 14px; bottom: 16px; }
  .dchat-launcher { height: 54px; }
  .dchat-panel {
    position: fixed;
    left: 10px; right: 10px; bottom: 80px;
    width: auto;
    height: min(74vh, 560px);
  }
  .dchat-l-label { display: none; }
  .dchat-launcher { width: 54px; padding: 0; justify-content: center; }
}
