/* PC-DNA Chat Widget — every class is prefixed pcdnachat- and scoped under
   #pcdnachat-root so it can never collide with the host page's own CSS
   (learned the hard way: this site's own header uses the class/id
   "pcdna-header", which a plain ".pcdna-" prefix would have collided with). */
#pcdnachat-root, #pcdnachat-root * {
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#pcdnachat-root {
  --pcdna-bg: #0f0f13;
  --pcdna-surface: #17171f;
  --pcdna-surface2: #1e1e29;
  --pcdna-border: rgba(255,255,255,0.08);
  --pcdna-text: #f0f0f4;
  --pcdna-text-dim: #9898a8;
  --pcdna-text-muted: #6b6b80;
  --pcdna-orange: #f97316;
  --pcdna-orange-dark: #ea580c;
  --pcdna-green: #22c55e;
  --pcdna-grey: #6b6b80;

  position: fixed;
  z-index: 2147483000;
  bottom: 22px;
  right: 22px;
}

/* ─── Launcher bubble ─── */
#pcdnachat-root .pcdnachat-launcher {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pcdna-orange), var(--pcdna-orange-dark));
  box-shadow: 0 6px 20px rgba(249,115,22,0.4);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}
#pcdnachat-root .pcdnachat-launcher:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(249,115,22,0.5); }
#pcdnachat-root .pcdnachat-launcher svg {
  width: 26px !important; height: 26px !important;
  min-width: 26px; min-height: 26px; flex-shrink: 0; display: block !important;
  transition: opacity 0.15s, transform 0.15s;
}
#pcdnachat-root .pcdnachat-launcher .pcdnachat-icon-close { position: absolute; opacity: 0; transform: rotate(-45deg) scale(0.6); }
#pcdnachat-root.is-open .pcdnachat-launcher .pcdnachat-icon-chat { opacity: 0; transform: rotate(45deg) scale(0.6); }
#pcdnachat-root.is-open .pcdnachat-launcher .pcdnachat-icon-close { opacity: 1; transform: rotate(0) scale(1); }

#pcdnachat-root .pcdnachat-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
#pcdnachat-root.is-open .pcdnachat-badge, #pcdnachat-root .pcdnachat-badge.is-hidden { display: none; }

/* ─── Panel ─── */
#pcdnachat-root .pcdnachat-panel {
  position: absolute;
  bottom: 76px; right: 0;
  width: 366px; height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--pcdna-bg);
  border-radius: 18px;
  border: 1px solid var(--pcdna-border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#pcdnachat-root.is-open .pcdnachat-panel {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (max-width: 420px) {
  #pcdnachat-root { bottom: 14px; right: 14px; left: 14px; }
  #pcdnachat-root .pcdnachat-panel { width: 100%; right: 0; height: calc(100vh - 110px); }
}

/* ─── Header ─── */
#pcdnachat-root .pcdnachat-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--pcdna-orange), var(--pcdna-orange-dark));
  color: #fff;
  flex-shrink: 0;
}
#pcdnachat-root .pcdnachat-header-top { display: flex; align-items: center; justify-content: space-between; }
#pcdnachat-root .pcdnachat-header-title { font-size: 15px; font-weight: 700; }
#pcdnachat-root .pcdnachat-header-status { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.92; margin-top: 3px; }
#pcdnachat-root .pcdnachat-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pcdna-green); box-shadow: 0 0 6px var(--pcdna-green); }
#pcdnachat-root .pcdnachat-status-dot.offline { background: #d9d9d9; box-shadow: none; }
#pcdnachat-root .pcdnachat-end-chat {
  background: rgba(255,255,255,0.16); border: none; color: #fff;
  font-size: 11px; padding: 4px 9px; border-radius: 6px; cursor: pointer;
}
#pcdnachat-root .pcdnachat-end-chat:hover { background: rgba(255,255,255,0.26); }

/* ─── Pre-chat form ─── */
#pcdnachat-root .pcdnachat-prechat {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 24px 22px; gap: 12px; overflow-y: auto;
}
#pcdnachat-root .pcdnachat-prechat p { color: var(--pcdna-text-dim); font-size: 13px; margin-bottom: 4px; }
#pcdnachat-root .pcdnachat-field label { display: block; font-size: 11px; color: var(--pcdna-text-muted); margin-bottom: 5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
#pcdnachat-root .pcdnachat-field input {
  width: 100%; padding: 10px 12px;
  background: var(--pcdna-surface2); border: 1px solid var(--pcdna-border);
  border-radius: 9px; color: var(--pcdna-text); font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
#pcdnachat-root .pcdnachat-field input:focus { border-color: var(--pcdna-orange); }
#pcdnachat-root .pcdnachat-prechat-submit {
  margin-top: 6px; padding: 11px; border: none; border-radius: 9px;
  background: linear-gradient(135deg, var(--pcdna-orange), var(--pcdna-orange-dark));
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
#pcdnachat-root .pcdnachat-prechat-submit:hover { opacity: 0.92; }
#pcdnachat-root .pcdnachat-offline-note {
  font-size: 12px; color: var(--pcdna-text-dim);
  background: var(--pcdna-surface2); border: 1px solid var(--pcdna-border);
  border-radius: 9px; padding: 10px 12px; margin-bottom: 4px;
}

/* ─── Messages ─── */
#pcdnachat-root .pcdnachat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 9px;
  background: var(--pcdna-bg);
}
#pcdnachat-root .pcdnachat-messages::-webkit-scrollbar { width: 5px; }
#pcdnachat-root .pcdnachat-messages::-webkit-scrollbar-thumb { background: var(--pcdna-surface2); border-radius: 3px; }

#pcdnachat-root .pcdnachat-msg { display: flex; flex-direction: column; max-width: 78%; }
#pcdnachat-root .pcdnachat-msg.user { align-self: flex-end; align-items: flex-end; }
#pcdnachat-root .pcdnachat-msg.support { align-self: flex-start; align-items: flex-start; }
#pcdnachat-root .pcdnachat-msg.system { align-self: center; align-items: center; max-width: 92%; }

#pcdnachat-root .pcdnachat-bubble {
  padding: 9px 13px; font-size: 13px; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
}
#pcdnachat-root .pcdnachat-msg.user .pcdnachat-bubble {
  background: linear-gradient(135deg, var(--pcdna-orange), var(--pcdna-orange-dark));
  color: #fff; border-radius: 13px 13px 3px 13px;
}
#pcdnachat-root .pcdnachat-msg.support .pcdnachat-bubble {
  background: var(--pcdna-surface2); border: 1px solid var(--pcdna-border);
  color: var(--pcdna-text); border-radius: 13px 13px 13px 3px;
}
#pcdnachat-root .pcdnachat-msg.system .pcdnachat-bubble {
  background: var(--pcdna-surface2); color: var(--pcdna-text-muted);
  border-radius: 20px; font-size: 11px; text-align: center; padding: 6px 12px;
}
#pcdnachat-root .pcdnachat-bubble-image { max-width: 200px; max-height: 200px; border-radius: 12px; display: block; cursor: pointer; }
#pcdnachat-root .pcdnachat-msg-time { font-size: 10px; color: var(--pcdna-text-muted); margin-top: 3px; padding: 0 3px; }

#pcdnachat-root .pcdnachat-waiting {
  align-self: center; max-width: 92%; display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; background: var(--pcdna-surface2); color: var(--pcdna-text-muted);
  border-radius: 20px; font-size: 11px; text-align: center; margin-top: 2px;
}
#pcdnachat-root .pcdnachat-waiting-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--pcdna-orange);
  flex-shrink: 0; animation: pcdnachat-pulse 1.4s infinite ease-in-out;
}
@keyframes pcdnachat-pulse { 0%,100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.15); } }

/* ─── Composer ─── */
#pcdnachat-root .pcdnachat-composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px; border-top: 1px solid var(--pcdna-border);
  background: var(--pcdna-surface); flex-shrink: 0;
}
#pcdnachat-root .pcdnachat-composer textarea {
  flex: 1; resize: none; max-height: 90px; min-height: 38px;
  padding: 9px 12px; background: var(--pcdna-surface2);
  border: 1px solid var(--pcdna-border); border-radius: 10px;
  color: var(--pcdna-text); font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
#pcdnachat-root .pcdnachat-composer textarea:focus { border-color: var(--pcdna-orange); }
#pcdnachat-root .pcdnachat-icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: none;
  background: var(--pcdna-surface2); color: var(--pcdna-text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background 0.15s, color 0.15s;
}
#pcdnachat-root .pcdnachat-icon-btn:hover { background: var(--pcdna-surface2); color: var(--pcdna-text); }
#pcdnachat-root .pcdnachat-send-btn {
  background: linear-gradient(135deg, var(--pcdna-orange), var(--pcdna-orange-dark));
  color: #fff;
}
#pcdnachat-root .pcdnachat-send-btn:hover { opacity: 0.9; }
#pcdnachat-root .pcdnachat-send-btn:disabled { opacity: 0.4; cursor: default; }
#pcdnachat-root .pcdnachat-icon-btn svg {
  width: 18px !important; height: 18px !important;
  min-width: 18px; min-height: 18px; flex-shrink: 0; display: block !important;
}

#pcdnachat-root .pcdnachat-footer-note {
  text-align: center; font-size: 10px; color: var(--pcdna-text-muted);
  padding: 6px 0 10px; background: var(--pcdna-surface);
}
