/* Chat widget — fully self-contained, brand-colored only via CSS vars so per-tenant
   theming retints it automatically. Logical properties throughout so it mirrors in
   RTL. Nothing here leaks into the rest of the site (all selectors under .dc-chat*). */

.dc-chat-launcher {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-end: 24px;
  z-index: 900;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--color-primary) 45%, transparent);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
  animation: dc-chat-pop .35s ease backwards;
}
.dc-chat-launcher:hover { transform: translateY(-2px) scale(1.04); }
.dc-chat-launcher:active { transform: scale(.96); }
.dc-chat-launcher svg { width: 26px; height: 26px; }
.dc-chat-launcher.is-hidden { opacity: 0; pointer-events: none; transform: scale(.5); }

@keyframes dc-chat-pop { from { opacity: 0; transform: scale(.4); } }

/* ---- panel ---- */
.dc-chat-panel {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-end: 24px;
  z-index: 901;
  width: min(384px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--color-surface, #fff);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
  overflow: hidden;
  transform-origin: bottom var(--dc-origin-inline, right);
  transition: opacity .2s ease, transform .2s ease;
  opacity: 0;
  transform: translateY(12px) scale(.96);
  pointer-events: none;
}
.dc-chat-panel.is-open { opacity: 1; transform: none; pointer-events: auto; }

/* header */
.dc-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-primary);
  color: #fff;
}
.dc-chat-header__logo {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center;
  overflow: hidden;
  flex: none;
}
.dc-chat-header__logo img { width: 100%; height: 100%; object-fit: cover; }
.dc-chat-header__logo svg { width: 22px; height: 22px; }
.dc-chat-header__meta { min-width: 0; flex: 1; }
.dc-chat-header__name {
  font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dc-chat-header__status {
  font-size: 12px; opacity: .85;
  display: flex; align-items: center; gap: 6px;
}
.dc-chat-header__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
  animation: dc-chat-pulse 2s infinite;
}
@keyframes dc-chat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .5); }
  70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.dc-chat-close {
  border: none; background: transparent; color: #fff;
  cursor: pointer; padding: 6px; border-radius: 8px;
  display: grid; place-items: center; opacity: .85;
}
.dc-chat-close:hover { opacity: 1; background: rgba(255, 255, 255, .15); }
.dc-chat-close svg { width: 20px; height: 20px; }

/* messages */
.dc-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-bg, #f6f7f9);
}
.dc-chat-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: dc-msg-in .2s ease;
}
@keyframes dc-msg-in { from { opacity: 0; transform: translateY(6px); } }
.dc-chat-msg--bot {
  align-self: flex-start;
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1a1a);
  border-start-start-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.dc-chat-msg--user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-start-end-radius: 4px;
}
.dc-chat-msg__time {
  display: block;
  font-size: 10px;
  opacity: .6;
  margin-block-start: 4px;
}

/* typing indicator */
.dc-chat-typing {
  align-self: flex-start;
  display: flex; gap: 4px;
  padding: 12px 14px;
  background: var(--color-surface, #fff);
  border-radius: 16px;
  border-start-start-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.dc-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: color-mix(in srgb, var(--color-primary) 55%, #999);
  animation: dc-typing 1.2s infinite;
}
.dc-chat-typing span:nth-child(2) { animation-delay: .2s; }
.dc-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes dc-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* quick-reply chips */
.dc-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  background: var(--color-bg, #f6f7f9);
}
.dc-chat-chip {
  border: 1px solid color-mix(in srgb, var(--color-primary) 40%, transparent);
  background: var(--color-surface, #fff);
  color: var(--color-primary);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.dc-chat-chip:hover { background: var(--color-primary); color: #fff; }

/* composer */
.dc-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-block-start: 1px solid rgba(0, 0, 0, .08);
  background: var(--color-surface, #fff);
}
.dc-chat-input {
  flex: 1;
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 999px;
  padding: 10px 15px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--color-bg, #f6f7f9);
  color: var(--color-text, #1a1a1a);
}
.dc-chat-input:focus { border-color: var(--color-primary); }
.dc-chat-send {
  flex: none;
  width: 42px; height: 42px;
  border: none; border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
}
.dc-chat-send:disabled { opacity: .5; cursor: default; }
.dc-chat-send svg { width: 19px; height: 19px; }

/* mobile: full-width bottom sheet */
@media (max-width: 480px) {
  .dc-chat-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
}

/* directional icons flip in RTL (send arrow) */
[dir="rtl"] .dc-chat-send svg { transform: scaleX(-1); }
