/* WooPlus Live Chat — professional storefront widget. RTL, brand-themed. */
#wooplus-chat-root {
  --wpc-brand: #6c5ce7;
  --wpc-ox: 20px;
  --wpc-oy: 20px;
  --wpc-ink: #1f2937;
  --wpc-muted: #6b7280;
  --wpc-line: #ececf2;
  direction: rtl;
  font-family: inherit;
}
#wooplus-chat-root * { box-sizing: border-box; }

.wpc-bubble {
  position: fixed;
  height: 58px; min-width: 58px;
  border: 0; border-radius: 30px;
  background: var(--wpc-brand); color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  z-index: 2147483000; padding: 0;
  transition: transform .15s ease, box-shadow .15s;
}
/* icon-only = round 58px bubble; with a label = a pill (icon + gap + text) */
.wpc-bubble.wpc-has-txt { padding-inline: 18px 20px; }
.wpc-bubble:hover { transform: scale(1.05); }
.wpc-bubble.wpc-pulse { animation: wpc-pulse 1.4s ease-in-out infinite; }
@keyframes wpc-pulse { 0%,100%{ box-shadow:0 8px 24px rgba(0,0,0,.22);} 50%{ box-shadow:0 8px 24px rgba(0,0,0,.22), 0 0 0 10px rgba(108,92,231,.18);} }
.wpc-bubble .wpc-bubble-ico { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.wpc-bubble .wpc-bubble-ico svg { width: 26px; height: 26px; display: block; }
.wpc-bubble .wpc-bubble-ico img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: block; }
.wpc-bubble .wpc-launch-txt { font-size: 13px; font-weight: 700; white-space: nowrap; line-height: 1; }
.wpc-bubble .wpc-badge {
  position: absolute; inset-block-start: -2px; inset-inline-end: -2px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: #ef4444; color: #fff; border-radius: 9px;
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; display: none;
}

.wpc-panel {
  position: fixed;
  width: 360px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 120px);
  background: #fff; border: 1px solid var(--wpc-line);
  border-radius: 16px; box-shadow: 0 18px 48px rgba(0,0,0,.24);
  display: none; flex-direction: column; overflow: hidden;
  z-index: 2147483000;
}
#wooplus-chat-root.wpc-open .wpc-panel { display: flex; }

/* ---- position variants (logical, RTL-aware) ---- */
.wpc-pos-bottom-start .wpc-bubble { inset-block-end: var(--wpc-oy); inset-inline-start: var(--wpc-ox); }
.wpc-pos-bottom-start .wpc-panel  { inset-block-end: calc(var(--wpc-oy) + 72px); inset-inline-start: var(--wpc-ox); }
.wpc-pos-bottom-end   .wpc-bubble { inset-block-end: var(--wpc-oy); inset-inline-end: var(--wpc-ox); }
.wpc-pos-bottom-end   .wpc-panel  { inset-block-end: calc(var(--wpc-oy) + 72px); inset-inline-end: var(--wpc-ox); }
.wpc-pos-top-start    .wpc-bubble { inset-block-start: var(--wpc-oy); inset-inline-start: var(--wpc-ox); }
.wpc-pos-top-start    .wpc-panel  { inset-block-start: calc(var(--wpc-oy) + 72px); inset-inline-start: var(--wpc-ox); }
.wpc-pos-top-end      .wpc-bubble { inset-block-start: var(--wpc-oy); inset-inline-end: var(--wpc-ox); }
.wpc-pos-top-end      .wpc-panel  { inset-block-start: calc(var(--wpc-oy) + 72px); inset-inline-end: var(--wpc-ox); }

/* center column (RTL-safe via translateX) */
.wpc-pos-top-center    .wpc-bubble { inset-block-start: var(--wpc-oy); inset-inline-start: 50%; transform: translateX(-50%); }
.wpc-pos-top-center    .wpc-panel  { inset-block-start: calc(var(--wpc-oy) + 72px); inset-inline-start: 50%; transform: translateX(-50%); }
.wpc-pos-bottom-center .wpc-bubble { inset-block-end: var(--wpc-oy); inset-inline-start: 50%; transform: translateX(-50%); }
.wpc-pos-bottom-center .wpc-panel  { inset-block-end: calc(var(--wpc-oy) + 72px); inset-inline-start: 50%; transform: translateX(-50%); }
.wpc-pos-top-center .wpc-bubble:hover { transform: translateX(-50%) scale(1.05); }
.wpc-pos-bottom-center .wpc-bubble:hover { transform: translateX(-50%) scale(1.05); }

/* middle row (vertically centered) */
.wpc-pos-middle-start  .wpc-bubble { inset-block-start: 50%; inset-inline-start: var(--wpc-ox); transform: translateY(-50%); }
.wpc-pos-middle-start  .wpc-panel  { inset-block-start: 50%; inset-inline-start: var(--wpc-ox); transform: translateY(-50%); }
.wpc-pos-middle-end    .wpc-bubble { inset-block-start: 50%; inset-inline-end: var(--wpc-ox); transform: translateY(-50%); }
.wpc-pos-middle-end    .wpc-panel  { inset-block-start: 50%; inset-inline-end: var(--wpc-ox); transform: translateY(-50%); }
.wpc-pos-middle-center .wpc-bubble { inset-block-start: 50%; inset-inline-start: 50%; transform: translate(-50%, -50%); }
.wpc-pos-middle-center .wpc-panel  { inset-block-start: 50%; inset-inline-start: 50%; transform: translate(-50%, -50%); }
.wpc-pos-middle-start .wpc-bubble:hover { transform: translateY(-50%) scale(1.05); }
.wpc-pos-middle-end .wpc-bubble:hover { transform: translateY(-50%) scale(1.05); }
.wpc-pos-middle-center .wpc-bubble:hover { transform: translate(-50%, -50%) scale(1.05); }

/* ---- entrance animations (panel + launcher) ---- */
.wpc-bubble { animation: wpc-pop .28s ease-out both; }
@keyframes wpc-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
#wooplus-chat-root.wpc-open .wpc-panel { animation: wpc-panel-in .22s cubic-bezier(.22,1,.36,1) both; }
@keyframes wpc-panel-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
/* corner anchors open upward from the bottom, downward from the top */
.wpc-pos-bottom-start .wpc-panel, .wpc-pos-bottom-end .wpc-panel { transform-origin: bottom center; }
.wpc-pos-top-start .wpc-panel, .wpc-pos-top-end .wpc-panel { transform-origin: top center; }
.wpc-pos-bottom-center .wpc-panel { transform-origin: bottom center; }
.wpc-pos-top-center .wpc-panel { transform-origin: top center; }
.wpc-pos-middle-start .wpc-panel, .wpc-pos-middle-end .wpc-panel, .wpc-pos-middle-center .wpc-panel { transform-origin: center; }
/* center/middle keep their centering transform during the entrance keyframe */
#wooplus-chat-root.wpc-pos-top-center.wpc-open .wpc-panel,
#wooplus-chat-root.wpc-pos-bottom-center.wpc-open .wpc-panel { animation: wpc-panel-in-cx .22s cubic-bezier(.22,1,.36,1) both; }
@keyframes wpc-panel-in-cx { from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(.96); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
#wooplus-chat-root.wpc-pos-middle-start.wpc-open .wpc-panel,
#wooplus-chat-root.wpc-pos-middle-end.wpc-open .wpc-panel { animation: wpc-panel-in-cy .22s cubic-bezier(.22,1,.36,1) both; }
@keyframes wpc-panel-in-cy { from { opacity: 0; transform: translateY(-50%) scale(.96); } to { opacity: 1; transform: translateY(-50%) scale(1); } }
#wooplus-chat-root.wpc-pos-middle-center.wpc-open .wpc-panel { animation: wpc-panel-in-cc .22s cubic-bezier(.22,1,.36,1) both; }
@keyframes wpc-panel-in-cc { from { opacity: 0; transform: translate(-50%, -50%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.wpc-head { background: var(--wpc-brand); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.wpc-head-logo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.wpc-head .wpc-title { font-weight: 700; font-size: 15px; flex: 1; }
.wpc-head .wpc-sub { font-size: 11px; opacity: .85; font-weight: 400; display: block; margin-block-start: 2px; }
.wpc-head .wpc-x { background: transparent; border: 0; color: #fff; cursor: pointer; padding: 4px; opacity: .9; }
.wpc-head .wpc-x svg { width: 20px; height: 20px; }

.wpc-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #fafafb; }

/* ---- intro: welcome + FAQ + pre-chat ---- */
.wpc-intro { display: flex; flex-direction: column; gap: 10px; }
.wpc-welcome { background: #fff; border: 1px solid var(--wpc-line); border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.8; color: var(--wpc-ink); }
.wpc-faq-title { font-size: 12px; font-weight: 800; color: var(--wpc-muted); margin-block-start: 6px; }
.wpc-faq-q { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: start; background: #fff; border: 1px solid var(--wpc-line); border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600; color: var(--wpc-ink); cursor: pointer; font-family: inherit; }
.wpc-faq-q svg { width: 16px; height: 16px; transition: transform .15s; flex: 0 0 auto; }
.wpc-faq-q.open svg { transform: rotate(180deg); }
.wpc-faq-a { display: none; background: #fff; border: 1px solid var(--wpc-line); border-top: 0; border-radius: 0 0 10px 10px; padding: 0 12px; font-size: 12.5px; line-height: 1.9; color: var(--wpc-muted); margin-block-start: -8px; }
.wpc-faq-a.open { display: block; padding: 10px 12px; }
.wpc-prechat { display: flex; flex-direction: column; gap: 8px; margin-block-start: 6px; }
.wpc-pre-intro { font-size: 12.5px; color: var(--wpc-muted); }
.wpc-input { width: 100%; border: 1px solid var(--wpc-line); border-radius: 10px; padding: 10px 12px; font-size: 13px; font-family: inherit; background: #fff; }
.wpc-input:focus { outline: none; border-color: var(--wpc-brand); }
.wpc-consent { font-size: 11px; color: var(--wpc-muted); line-height: 1.7; }
.wpc-start { background: var(--wpc-brand); color: #fff; border: 0; border-radius: 10px; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; margin-block-start: 4px; }
/* FAQ-first: prominent «ارتباط با اپراتور» CTA that reveals the pre-chat form (#7) */
.wpc-contact-op { background: var(--wpc-brand); color: #fff; border: 0; border-radius: 10px; padding: 12px; font-size: 14px; font-weight: 800; cursor: pointer; font-family: inherit; margin-block-start: 10px; width: 100%; box-shadow: 0 4px 14px rgba(108,92,231,.28); }
.wpc-contact-op:hover { filter: brightness(1.05); }

.wpc-away { background: #fef3c7; color: #92400e; border-radius: 10px; padding: 9px 12px; font-size: 12.5px; line-height: 1.7; align-self: stretch; }
/* office-hours line (#5) */
.wpc-office { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--wpc-muted); align-self: stretch; }
/* department stamp (#6) — small chip pinned at the top of the thread */
.wpc-dept { align-self: center; background: #eef2ff; color: #3730a3; border: 1px solid #e0e7ff; border-radius: 999px; padding: 4px 12px; font-size: 11.5px; font-weight: 700; line-height: 1.6; }
.wpc-blocked { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; border-radius: 10px; padding: 9px 12px; margin-block-end: 8px; font-size: 12.5px; line-height: 1.7; text-align: center; }

.wpc-msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; font-size: 13px; line-height: 1.7; word-wrap: break-word; overflow-wrap: anywhere; }
.wpc-msg.customer { align-self: flex-start; background: var(--wpc-brand); color: #fff; border-end-end-radius: 4px; }
.wpc-msg.staff    { align-self: flex-end; background: #fff; color: var(--wpc-ink); border: 1px solid var(--wpc-line); border-end-start-radius: 4px; }
.wpc-msg.system   { align-self: center; background: transparent; color: var(--wpc-muted); font-size: 12px; }
.wpc-msg .wpc-meta { display: block; font-size: 10px; opacity: .7; margin-block-start: 3px; }

.wpc-foot { border-block-start: 1px solid var(--wpc-line); padding: 10px; background: #fff; }
.wpc-foot .wpc-row { display: flex; gap: 6px; align-items: flex-end; }
.wpc-foot textarea { flex: 1; resize: none; border: 1px solid var(--wpc-line); border-radius: 10px; padding: 9px 12px; font-size: 13px; font-family: inherit; max-height: 96px; line-height: 1.6; }
.wpc-foot textarea:focus { outline: none; border-color: var(--wpc-brand); }
.wpc-foot .wpc-send { flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--wpc-brand); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.wpc-foot .wpc-send:disabled { opacity: .5; cursor: default; }
.wpc-foot .wpc-send svg { width: 18px; height: 18px; }

/* ---- attach / mic icon buttons ---- */
.wpc-icon-btn { flex: 0 0 auto; width: 38px; height: 40px; border: 0; background: transparent; color: var(--wpc-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 10px; transition: background .12s, color .12s; }
.wpc-icon-btn:hover { background: #f3f3f8; color: var(--wpc-brand); }
.wpc-icon-btn:disabled { opacity: .45; cursor: default; }
.wpc-icon-btn svg { width: 20px; height: 20px; }

/* ---- recording bar ---- */
.wpc-recbar { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.wpc-rec-dot { width: 11px; height: 11px; border-radius: 50%; background: #ef4444; flex: 0 0 auto; animation: wpc-blink 1s steps(2,start) infinite; }
@keyframes wpc-blink { 50% { opacity: .25; } }
.wpc-rec-time { flex: 1; font-size: 14px; font-weight: 700; color: var(--wpc-ink); }
.wpc-recbar .wpc-rec-cancel { color: #ef4444; }

/* ---- attachments in a bubble ---- */
.wpc-msg-txt { white-space: pre-wrap; }
.wpc-msg .wpc-att-img { display: block; margin-block-start: 6px; border-radius: 10px; overflow: hidden; max-width: 220px; }
.wpc-msg .wpc-att-img img { display: block; width: 100%; height: auto; max-height: 240px; object-fit: cover; }
.wpc-msg .wpc-att-voice { display: flex; align-items: center; gap: 8px; margin-block-start: 6px; }
.wpc-msg .wpc-att-voice audio { height: 36px; max-width: 210px; }
.wpc-msg .wpc-att-dur { font-size: 11px; opacity: .8; }
.wpc-msg .wpc-att-file { display: flex; align-items: center; gap: 8px; margin-block-start: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.06); color: inherit; text-decoration: none; max-width: 230px; }
.wpc-msg.staff .wpc-att-file { background: #f3f3f8; }
.wpc-msg .wpc-att-file svg { width: 22px; height: 22px; flex: 0 0 auto; opacity: .8; }
.wpc-msg .wpc-att-fmeta { display: flex; flex-direction: column; min-width: 0; }
.wpc-msg .wpc-att-fname { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpc-msg .wpc-att-fsize { font-size: 10.5px; opacity: .7; }
.wpc-msg.wpc-pending { opacity: .7; font-style: italic; }

@media (max-width: 480px) {
  /* bottom-sheet reset wins for all 9 positions: kill any center/middle transform too */
  #wooplus-chat-root .wpc-panel { inset: auto 0 0 0 !important; transform: none !important; width: 100%; max-width: 100%; height: 82vh; max-height: 82vh; border-radius: 16px 16px 0 0; }
}

/* ---- respect reduced-motion: no pulse / blink / entrance ---- */
@media (prefers-reduced-motion: reduce) {
  .wpc-bubble,
  .wpc-bubble.wpc-pulse,
  .wpc-rec-dot,
  #wooplus-chat-root.wpc-open .wpc-panel,
  #wooplus-chat-root.wpc-pos-top-center.wpc-open .wpc-panel,
  #wooplus-chat-root.wpc-pos-bottom-center.wpc-open .wpc-panel,
  #wooplus-chat-root.wpc-pos-middle-start.wpc-open .wpc-panel,
  #wooplus-chat-root.wpc-pos-middle-end.wpc-open .wpc-panel,
  #wooplus-chat-root.wpc-pos-middle-center.wpc-open .wpc-panel { animation: none !important; }
}
