/* Diplomat Chat — red & white theme */
#dpc-root, #dpc-root * { box-sizing: border-box; }
#dpc-root {
  --dpc-p: #d71920; --dpc-pd: #a8101a; --dpc-pl: #fdecee;
  --dpc-x: 24px; --dpc-y: 24px;
  --dpc-font: Vazirmatn, IRANSans, IRANYekan, Tahoma, sans-serif;
  position: fixed; bottom: var(--dpc-y); z-index: 2147483000;
  direction: rtl; text-align: right;
  font-family: var(--dpc-font); font-size: 14px; line-height: 1.8; color: #222;
  -webkit-font-smoothing: antialiased;
}
#dpc-root.dpc-left { left: var(--dpc-x); }
#dpc-root.dpc-right { right: var(--dpc-x); }
#dpc-root button, #dpc-root input, #dpc-root a { font-family: inherit; }
#dpc-root [hidden] { display: none !important; }

/* ---------- Launcher ---------- */
#dpc-root .dpc-launcher {
  -webkit-appearance: none; appearance: none;
  position: relative; display: grid; place-items: center;
  width: 64px; height: 64px; min-width: 0; min-height: 0; margin: 0; padding: 0;
  border: 3px solid #fff; border-radius: 50%;
  background: linear-gradient(135deg, var(--dpc-p), var(--dpc-pd));
  color: #fff; cursor: pointer; line-height: 1; text-transform: none; letter-spacing: 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28), 0 2px 6px rgba(0, 0, 0, .18);
  transition: transform .25s cubic-bezier(.3, 1.4, .5, 1), box-shadow .25s;
}
#dpc-root.dpc-left .dpc-launcher { margin-right: auto; }
#dpc-root.dpc-right .dpc-launcher { margin-left: auto; }
#dpc-root .dpc-launcher:hover { transform: scale(1.08); box-shadow: 0 14px 34px rgba(0, 0, 0, .32); }
#dpc-root .dpc-launcher:focus-visible { outline: 3px solid var(--dpc-p); outline-offset: 3px; }
#dpc-root .dpc-launcher::before {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid var(--dpc-p); opacity: 0; animation: dpc-pulse 2.6s ease-out infinite; pointer-events: none;
}
#dpc-root.dpc-open .dpc-launcher::before { animation: none; }
@keyframes dpc-pulse { 0% { transform: scale(1); opacity: .6; } 70%, 100% { transform: scale(1.55); opacity: 0; } }

#dpc-root .dpc-ico { position: absolute; display: grid; place-items: center; transition: transform .3s, opacity .25s; }
#dpc-root .dpc-ico-x { opacity: 0; transform: rotate(-90deg) scale(.5); }
#dpc-root.dpc-open .dpc-ico-chat { opacity: 0; transform: rotate(90deg) scale(.5); }
#dpc-root.dpc-open .dpc-ico-x { opacity: 1; transform: none; }

#dpc-root .dpc-badge {
  position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px;
  display: grid; place-items: center; border-radius: 11px;
  background: #fff; color: var(--dpc-p); font-size: 12px; font-weight: 700; line-height: 1;
  border: 2px solid var(--dpc-p); box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

/* ---------- Tip bubble ---------- */
#dpc-root .dpc-tip {
  position: absolute; bottom: 14px; max-width: 250px; padding: 12px 34px 12px 16px;
  background: #fff; color: #222; border-radius: 16px; font-size: 13.5px; line-height: 1.8; cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18), 0 0 0 1px rgba(0, 0, 0, .04);
  animation: dpc-pop .35s cubic-bezier(.3, 1.4, .5, 1);
}
#dpc-root.dpc-left .dpc-tip { left: 78px; }
#dpc-root.dpc-right .dpc-tip { right: 78px; }
#dpc-root .dpc-tip::before {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 4px; border-radius: 0 16px 16px 0; background: var(--dpc-p);
}
#dpc-root .dpc-tip-x {
  -webkit-appearance: none; appearance: none; position: absolute; top: 6px; right: 10px; width: 22px; height: 22px;
  padding: 0; margin: 0; border: 0; background: none; color: #999; font-size: 18px; line-height: 1; cursor: pointer;
}
#dpc-root .dpc-tip-x:hover { color: var(--dpc-p); }
@keyframes dpc-pop { from { opacity: 0; transform: translateY(8px) scale(.95); } to { opacity: 1; transform: none; } }

/* ---------- Window ---------- */
#dpc-root .dpc-window {
  position: absolute; bottom: 80px; display: flex; flex-direction: column;
  width: 384px; max-width: calc(100vw - 24px); height: 620px; max-height: calc(100vh - var(--dpc-y) - 100px);
  background: #fff; border-radius: 22px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .28), 0 0 0 1px rgba(0, 0, 0, .06);
  opacity: 0; visibility: hidden; transform: translateY(20px) scale(.96); pointer-events: none;
  transition: opacity .25s, transform .3s cubic-bezier(.2, .9, .3, 1), visibility 0s .3s;
}
#dpc-root.dpc-left .dpc-window { left: 0; transform-origin: bottom left; }
#dpc-root.dpc-right .dpc-window { right: 0; transform-origin: bottom right; }
#dpc-root.dpc-open .dpc-window { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 0s; }

/* Header */
#dpc-root .dpc-head {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 18px 18px 20px; color: #fff; overflow: hidden;
  background: linear-gradient(135deg, var(--dpc-p) 0%, var(--dpc-pd) 100%);
}
#dpc-root .dpc-head::before, #dpc-root .dpc-head::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .09); pointer-events: none;
}
#dpc-root .dpc-head::before { width: 140px; height: 140px; top: -70px; left: -40px; }
#dpc-root .dpc-head::after { width: 90px; height: 90px; bottom: -50px; left: 90px; }
#dpc-root .dpc-avatar {
  position: relative; flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: #fff; color: var(--dpc-p); overflow: hidden; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35);
}
#dpc-root .dpc-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
#dpc-root .dpc-meta { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
#dpc-root .dpc-meta strong { font-size: 15.5px; font-weight: 700; line-height: 1.6; color: #fff; }
#dpc-root .dpc-meta span { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .92; }
#dpc-root .dpc-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 0 rgba(61, 220, 132, .7); animation: dpc-live 2s infinite; }
@keyframes dpc-live { 70% { box-shadow: 0 0 0 7px rgba(61, 220, 132, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); } }
#dpc-root .dpc-close {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0; margin: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; transition: background .2s;
}
#dpc-root .dpc-close:hover { background: rgba(255, 255, 255, .3); }

/* Body */
#dpc-root .dpc-body {
  flex: 1; overflow-y: auto; padding: 18px 14px 8px; background: #fbf7f7; overscroll-behavior: contain; scroll-behavior: smooth;
}
#dpc-root .dpc-body::-webkit-scrollbar { width: 6px; }
#dpc-root .dpc-body::-webkit-scrollbar-thumb { background: #e3d6d6; border-radius: 3px; }

#dpc-root .dpc-msg { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; animation: dpc-in .28s ease-out; }
#dpc-root .dpc-msg.dpc-user { flex-direction: row-reverse; }
@keyframes dpc-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#dpc-root .dpc-mini {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: #fff; color: var(--dpc-p); overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}
#dpc-root .dpc-mini img { width: 100%; height: 100%; object-fit: cover; }
#dpc-root .dpc-mini svg { width: 18px; height: 18px; }
#dpc-root .dpc-bubble { max-width: 78%; padding: 10px 14px 6px; word-wrap: break-word; overflow-wrap: anywhere; }
#dpc-root .dpc-bot .dpc-bubble {
  background: #fff; color: #222; border-radius: 18px 4px 18px 18px; box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
#dpc-root .dpc-user .dpc-bubble {
  background: linear-gradient(135deg, var(--dpc-p), var(--dpc-pd)); color: #fff; border-radius: 4px 18px 18px 18px;
}
#dpc-root .dpc-txt { display: block; white-space: pre-line; }
#dpc-root .dpc-time { display: block; margin-top: 2px; font-size: 10.5px; opacity: .55; text-align: left; }

#dpc-root .dpc-typing { display: inline-flex; gap: 4px; padding: 6px 0 8px; }
#dpc-root .dpc-typing i { width: 7px; height: 7px; border-radius: 50%; background: #c9b8b8; animation: dpc-bounce 1.1s infinite; }
#dpc-root .dpc-typing i:nth-child(2) { animation-delay: .15s; }
#dpc-root .dpc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dpc-bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Quick replies */
#dpc-root .dpc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 38px 14px 0; animation: dpc-in .3s ease-out; }
#dpc-root .dpc-chip {
  -webkit-appearance: none; appearance: none; margin: 0; padding: 7px 14px; border-radius: 20px; cursor: pointer;
  border: 1.5px solid var(--dpc-p); background: #fff; color: var(--dpc-p); font-size: 13px; font-weight: 600; line-height: 1.6;
  text-transform: none; letter-spacing: 0; transition: background .18s, color .18s, transform .18s;
}
#dpc-root .dpc-chip:hover, #dpc-root .dpc-chip:focus-visible { background: var(--dpc-p); color: #fff; transform: translateY(-1px); outline: none; }

/* Action bar */
#dpc-root .dpc-actions { display: flex; gap: 8px; padding: 8px 12px 0; background: #fff; border-top: 1px solid #f0e6e6; }
#dpc-root .dpc-act {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 10px; margin-top: 0;
  border-radius: 12px; background: var(--dpc-pl); color: var(--dpc-p); font-size: 12.5px; font-weight: 600;
  text-decoration: none; box-shadow: none; border: 0; transition: background .2s, color .2s;
}
#dpc-root .dpc-act:hover { background: var(--dpc-p); color: #fff; }

/* Form */
#dpc-root .dpc-form { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px 12px; background: #fff; }
#dpc-root .dpc-actions + .dpc-form { padding-top: 8px; }
#dpc-root .dpc-input {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 44px; margin: 0; padding: 0 16px;
  border: 1.5px solid #eadfdf; border-radius: 24px; background: #faf6f6; color: #222; font-size: 14px; box-shadow: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
#dpc-root .dpc-input::placeholder { color: #a99b9b; }
#dpc-root .dpc-input:focus { outline: none; background: #fff; border-color: var(--dpc-p); box-shadow: 0 0 0 4px rgba(215, 25, 32, .12); }
#dpc-root .dpc-send {
  -webkit-appearance: none; appearance: none; flex: none; display: grid; place-items: center; width: 44px; height: 44px;
  margin: 0; padding: 0; border: 0; border-radius: 50%; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--dpc-p), var(--dpc-pd)); transition: transform .2s, box-shadow .2s;
  box-shadow: 0 6px 16px rgba(215, 25, 32, .35);
}
#dpc-root .dpc-send svg { transform: scaleX(-1); }
#dpc-root .dpc-send:hover { transform: scale(1.07); }
#dpc-root .dpc-send:disabled { opacity: .5; cursor: default; transform: none; }

/* ---------- Mobile ---------- */
@media (max-width: 520px) {
  #dpc-root { --dpc-x: 16px; --dpc-y: 16px; }
  #dpc-root .dpc-launcher { width: 58px; height: 58px; }
  #dpc-root .dpc-tip { max-width: calc(100vw - 110px); }
  #dpc-root.dpc-open { inset: 0 !important; bottom: 0; left: 0; right: 0; }
  #dpc-root.dpc-open .dpc-window {
    position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0;
    height: 100dvh;
  }
  #dpc-root.dpc-open .dpc-launcher { display: none; }
  #dpc-root .dpc-head { padding-top: max(18px, env(safe-area-inset-top)); }
  #dpc-root .dpc-form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  #dpc-root .dpc-input { font-size: 16px; } /* prevent iOS zoom */
}

@media (prefers-reduced-motion: reduce) {
  #dpc-root *, #dpc-root *::before { animation: none !important; transition: none !important; }
}
