:host,
.hssd-root {
  all: initial;
  font-family: "Segoe UI", "Noto Sans Arabic", "Tahoma", sans-serif;
  color: #18212f;
}

.hssd-root {
  --hssd-surface: #ffffff;
  --hssd-panel-bg: rgba(255, 255, 255, 0.98);
  --hssd-page-bg: #f5f7fb;
  --hssd-text: #18212f;
  --hssd-muted: #64748b;
  --hssd-border: rgba(15, 23, 42, 0.1);
  --hssd-accent: #1f5eff;
  --hssd-user: #142033;
  --hssd-bot: #f8fafc;
  --hssd-link: #0f766e;
  --hssd-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
  --hssd-size: 56px;
  --hssd-gap: 10px;
  --hssd-action-rail: 122px;
  --hssd-right: 16px;
  --hssd-bottom: 18px;
  --hssd-mobile-bottom: 104px;
  position: fixed;
  right: var(--hssd-right);
  bottom: var(--hssd-bottom);
  z-index: 2147483000;
  color: var(--hssd-text);
  -webkit-font-smoothing: antialiased;
}

.hssd-root[data-theme="dark"] {
  --hssd-surface: #0f172a;
  --hssd-panel-bg: rgba(15, 23, 42, 0.98);
  --hssd-page-bg: #08101f;
  --hssd-text: #e5edf8;
  --hssd-muted: #9cafc3;
  --hssd-border: rgba(148, 163, 184, 0.18);
  --hssd-accent: #7dd3fc;
  --hssd-user: #20304c;
  --hssd-bot: #122033;
  --hssd-link: #86efac;
  --hssd-shadow: 0 20px 48px rgba(0, 0, 0, 0.42);
}

.hssd-root * {
  box-sizing: border-box;
  font-family: inherit;
}

.hssd-dock {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--hssd-gap);
  padding: 8px;
  width: calc(var(--hssd-size) + 16px);
  max-width: calc(var(--hssd-size) + 16px);
  overflow: hidden;
  border: 1px solid var(--hssd-border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--hssd-surface) 90%, transparent);
  box-shadow: var(--hssd-shadow);
  backdrop-filter: blur(12px);
  transition: width 170ms ease, max-width 170ms ease;
}
.hssd-root.is-expanded .hssd-dock {
  width: calc((var(--hssd-size) * 3) + (var(--hssd-gap) * 2) + 40px);
  max-width: calc((var(--hssd-size) * 3) + (var(--hssd-gap) * 2) + 40px);
}
.hssd-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--hssd-gap);
  width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  flex: 0 0 auto;
  pointer-events: none;
  transform: translateX(6px);
  transition: width 170ms ease, max-width 170ms ease, opacity 150ms ease, transform 150ms ease;
}

.hssd-root.is-expanded .hssd-actions {
  width: var(--hssd-action-rail);
  max-width: var(--hssd-action-rail);
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.hssd-button,
.hssd-action {
  width: var(--hssd-size);
  height: var(--hssd-size);
  min-width: var(--hssd-size);
  min-height: var(--hssd-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: none;
  flex: 0 0 var(--hssd-size);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.hssd-button:focus-visible,
.hssd-action:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--hssd-accent) 70%, #ffffff 30%);
  outline-offset: 2px;
}

.hssd-button:hover,
.hssd-action:hover {
  transform: translateY(-1px);
}

.hssd-button {
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fb 100%);
  color: #1f2937;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.hssd-root[data-theme="dark"] .hssd-button {
  background: linear-gradient(180deg, #1d2a3f 0%, #142033 100%);
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}

.hssd-action--chat {
  background: linear-gradient(180deg, #ffffff 0%, #f3f6fa 100%);
  color: #1f2937;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.hssd-root[data-theme="dark"] .hssd-action--chat {
  background: linear-gradient(180deg, #1d2a3f 0%, #142033 100%);
  color: #f8fafc;
}

.hssd-action--whatsapp {
  background: linear-gradient(180deg, #2ed867 0%, #22c55e 100%);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.hssd-icon {
  width: 26px;
  height: 26px;
  display: block;
  flex: 0 0 26px;
}

.hssd-panel {
  position: absolute;
  right: 0;
  bottom: calc(var(--hssd-size) + 18px);
  width: min(400px, calc(100vw - 16px));
  height: min(640px, calc(100dvh - 148px));
  min-height: 420px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--hssd-panel-bg);
  border: 1px solid var(--hssd-border);
  border-radius: 22px;
  box-shadow: var(--hssd-shadow);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.985);
  transform-origin: bottom right;
  transition: opacity 170ms ease, transform 170ms ease;
}

.hssd-root.is-chat-open .hssd-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.hssd-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--hssd-border);
  background: color-mix(in srgb, var(--hssd-surface) 92%, transparent);
}

.hssd-heading {
  min-width: 0;
}

.hssd-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hssd-subtitle {
  margin: 6px 0 0;
  color: var(--hssd-muted);
  font-size: 13px;
  line-height: 1.45;
}

.hssd-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hssd-close-btn {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 16px;
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hssd-mini {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hssd-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--hssd-surface) 90%, transparent);
  color: var(--hssd-text);
  font-size: 12px;
  cursor: pointer;
}

.hssd-mini--icon {
  width: 36px;
  padding: 0;
}

.hssd-messages {
  min-height: 0;
  padding: 14px;
  overflow: auto;
  background: var(--hssd-page-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hssd-row {
  display: flex;
  width: 100%;
}

.hssd-row--user {
  justify-content: flex-end;
}

.hssd-row--assistant {
  justify-content: flex-start;
}

.hssd-bubble {
  max-width: min(85%, 100%);
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--hssd-border);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  unicode-bidi: plaintext;
  text-align: start;
}

.hssd-row--user .hssd-bubble {
  background: var(--hssd-user);
  color: #f8fafc;
  border-bottom-right-radius: 8px;
}

.hssd-row--assistant .hssd-bubble {
  width: min(100%, 340px);
  background: var(--hssd-bot);
  color: var(--hssd-text);
  border-bottom-left-radius: 8px;
}

.hssd-content {
  margin: 0;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  unicode-bidi: plaintext;
  text-align: start;
}

.hssd-content + .hssd-content {
  margin-top: 0.65em;
}

.hssd-content--list {
  padding-inline-start: 1.35em;
}

.hssd-link {
  color: var(--hssd-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hssd-typing {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  min-width: min(100%, 220px);
}

.hssd-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hssd-muted) 12%, transparent);
}

.hssd-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hssd-muted) 62%, transparent);
  animation: hssd-bounce 1.2s infinite ease-in-out;
}

.hssd-dot:nth-child(2) {
  animation-delay: 120ms;
}

.hssd-dot:nth-child(3) {
  animation-delay: 240ms;
}

.hssd-typing-meta {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.hssd-typing-text {
  color: var(--hssd-muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hssd-typing-bar {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hssd-muted) 18%, transparent);
  overflow: hidden;
}

.hssd-typing-bar::before {
  content: "";
  display: block;
  width: 34%;
  height: 100%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--hssd-accent) 45%, transparent) 0%, color-mix(in srgb, var(--hssd-accent) 88%, transparent) 55%, color-mix(in srgb, var(--hssd-accent) 45%, transparent) 100%);
  transform: translateX(-120%);
  animation: hssd-slide 1.2s infinite ease-in-out;
}

.hssd-input-wrap {
  border-top: 1px solid var(--hssd-border);
  padding: 12px;
  background: color-mix(in srgb, var(--hssd-surface) 94%, transparent);
}

.hssd-input-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.hssd-input {
  width: 100%;
  min-height: 48px;
  max-height: 132px;
  resize: none;
  padding: 12px 13px;
  border: 1px solid var(--hssd-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--hssd-surface) 96%, transparent);
  color: var(--hssd-text);
  font-size: 14px;
  line-height: 1.45;
}

.hssd-input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--hssd-accent) 68%, transparent);
  outline-offset: 1px;
}

.hssd-send {
  min-width: 92px;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #284ce5 0%, #1836b5 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.hssd-root[data-theme="dark"] .hssd-send {
  background: linear-gradient(180deg, #4e94ff 0%, #2e69ff 100%);
}

.hssd-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hssd-note {
  margin: 8px 2px 0;
  color: var(--hssd-muted);
  font-size: 11.5px;
  line-height: 1.35;
}

@keyframes hssd-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-2px); opacity: 1; }
}

@keyframes hssd-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

@media (max-width: 767px) {
  .hssd-root {
    right: 12px;
    bottom: var(--hssd-mobile-bottom);
  }

  .hssd-panel {
    width: min(420px, calc(100vw - 16px));
    height: min(76dvh, 640px);
    min-height: 360px;
    border-radius: 20px;
  }

  .hssd-header {
    grid-template-columns: 1fr;
    position: relative;
    padding-right: 74px;
  }

  .hssd-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 52px;
    height: 52px;
    min-width: 52px;
    font-size: 38px;
    z-index: 4;
  }

  .hssd-input-grid {
    grid-template-columns: 1fr;
  }

  .hssd-send {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .hssd-root {
    right: 8px;
  }

  .hssd-dock {
    width: calc(var(--hssd-size) + 14px);
    max-width: calc(var(--hssd-size) + 14px);
    padding: 7px;
  }

.hssd-root.is-expanded .hssd-dock {
  width: calc((var(--hssd-size) * 3) + (var(--hssd-gap) * 2) + 40px);
  max-width: calc((var(--hssd-size) * 3) + (var(--hssd-gap) * 2) + 40px);
}

  .hssd-panel {
    width: calc(100vw - 12px);
    height: min(72dvh, 620px);
    bottom: calc(var(--hssd-size) + 14px);
  }

  .hssd-title {
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hssd-dock,
  .hssd-actions,
  .hssd-button,
  .hssd-action,
  .hssd-panel,
  .hssd-dot,
  .hssd-typing-bar::before {
    animation: none !important;
    transition: none !important;
  }
}

/* WhatsApp icon fit fix */
.hssd-action--whatsapp .hssd-icon {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
}

.hssd-root {
  --hssd-size: 60px;
  --hssd-gap: 12px;
  --hssd-action-rail: 132px;
}



@media (max-width: 767px) {
  .hssd-root.is-chat-open .hssd-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    right: 0;
    bottom: 0;
    transform-origin: center;
  }

  .hssd-root.is-chat-open .hssd-dock {
    border-bottom-right-radius: 0;
  }

  .hssd-root.is-chat-open {
    right: 0;
    bottom: 0;
  }
}
