.chatbot-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.chatbot-panel {
  width: min(390px, calc(100vw - 24px));
  max-height: min(720px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 28px 70px rgba(8, 23, 44, 0.18);
  backdrop-filter: blur(16px);
}

.chatbot-panel[hidden] {
  display: none !important;
}

.chatbot-launcher {
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  box-shadow: 0 18px 40px rgba(29, 78, 216, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.chatbot-launcher:hover,
.chatbot-launcher:focus {
  transform: translateY(-2px);
  box-shadow: 0 22px 44px rgba(29, 78, 216, 0.34);
}

.chatbot-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.25rem 1rem;
  background:
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.16), transparent 28%),
    linear-gradient(135deg, rgba(13, 32, 61, 0.96), rgba(18, 63, 120, 0.96));
  color: #ffffff;
}

.chatbot-header-copy {
  min-width: 0;
}

.chatbot-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chatbot-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #34d399;
  box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.16);
}

.chatbot-title {
  margin: 0;
  color: #ffffff;
  font-size: 1.35rem;
}

.chatbot-subtitle {
  margin: 0.35rem 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.93rem;
}

.chatbot-header-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.chatbot-header-actions button {
  min-width: 42px;
  height: 42px;
  padding: 0 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
}

.chatbot-header-actions button:hover,
.chatbot-header-actions button:focus {
  background: rgba(255, 255, 255, 0.14);
}

.chatbot-stage {
  display: flex;
  flex-direction: column;
  min-height: 500px;
}

.chatbot-onboarding,
.chatbot-conversation {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.chatbot-onboarding[hidden],
.chatbot-conversation[hidden] {
  display: none !important;
}

.chatbot-section {
  padding: 1.2rem 1.25rem;
}

.chatbot-section + .chatbot-section {
  border-top: 1px solid var(--line);
}

.chatbot-section h4 {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-size: 1rem;
}

.chatbot-section p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.chatbot-form {
  display: grid;
  gap: 0.9rem;
}

.chatbot-field {
  display: grid;
  gap: 0.35rem;
}

.chatbot-field label {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
}

.chatbot-field input,
.chatbot-composer input {
  width: 100%;
  min-height: 52px;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(16, 35, 61, 0.12);
  border-radius: 16px;
  background: #ffffff;
  color: var(--text);
}

.chatbot-field input::placeholder,
.chatbot-composer input::placeholder {
  color: #7b8ba3;
}

.chatbot-form-action,
.chatbot-composer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  font-weight: 700;
}

.chatbot-form-action:hover,
.chatbot-form-action:focus,
.chatbot-composer button:hover,
.chatbot-composer button:focus {
  color: #ffffff;
  filter: brightness(1.05);
}

.chatbot-form-error {
  min-height: 22px;
  color: #dc2626;
  font-size: 0.86rem;
  font-weight: 600;
}

.chatbot-summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(29, 78, 216, 0.05);
}

.chatbot-summary p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.chatbot-summary strong {
  display: block;
  color: var(--text);
  font-size: 0.94rem;
}

.chatbot-edit-details {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.chatbot-messages {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  flex: 1 1 auto;
  min-height: 260px;
  max-height: 360px;
  padding: 1rem 1.1rem;
  overflow-y: auto;
  background:
    radial-gradient(circle at top right, rgba(29, 78, 216, 0.06), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08));
}

.chatbot-message {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.chatbot-message.user {
  align-items: flex-end;
}

.chatbot-message.bot {
  align-items: flex-start;
}

.chatbot-bubble-message {
  max-width: 88%;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chatbot-message.bot .chatbot-bubble-message {
  background: rgba(29, 78, 216, 0.08);
  border: 1px solid rgba(29, 78, 216, 0.08);
  color: var(--text);
  border-bottom-left-radius: 8px;
}

.chatbot-message.user .chatbot-bubble-message {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  border-bottom-right-radius: 8px;
}

.chatbot-meta {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 600;
}

.chatbot-status {
  padding: 0 1.1rem 0.8rem;
  color: var(--text-soft);
  font-size: 0.84rem;
  min-height: 22px;
}

.chatbot-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 1rem 1.1rem 1.1rem;
  border-top: 1px solid var(--line);
}

.chatbot-composer button {
  min-width: 112px;
  padding: 0 1rem;
}

.chatbot-empty {
  margin: auto;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.92rem;
}

html[lang="ar"] .chatbot-badge {
  letter-spacing: 0;
  text-transform: none;
}

html[dir="rtl"] .chatbot-widget {
  right: auto;
  left: 24px;
  align-items: flex-start;
}

html[dir="rtl"] .chatbot-panel,
html[dir="rtl"] .chatbot-header,
html[dir="rtl"] .chatbot-section,
html[dir="rtl"] .chatbot-summary,
html[dir="rtl"] .chatbot-status,
html[dir="rtl"] .chatbot-empty {
  text-align: right;
}

html[dir="rtl"] .chatbot-header-actions,
html[dir="rtl"] .chatbot-summary {
  flex-direction: row-reverse;
}

html[dir="rtl"] .chatbot-field input,
html[dir="rtl"] .chatbot-composer input {
  text-align: right;
}

html[dir="rtl"] .chatbot-message.user {
  align-items: flex-start;
}

html[dir="rtl"] .chatbot-message.bot {
  align-items: flex-end;
}

html[dir="rtl"] .chatbot-message.bot .chatbot-bubble-message {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 8px;
}

html[dir="rtl"] .chatbot-message.user .chatbot-bubble-message {
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 8px;
}

html[data-theme="dark"] .chatbot-panel {
  background: rgba(8, 23, 44, 0.92);
  border-color: rgba(148, 163, 184, 0.14);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.38);
}

html[data-theme="dark"] .chatbot-field input,
html[data-theme="dark"] .chatbot-composer input {
  background: rgba(15, 23, 42, 0.84);
  border-color: rgba(148, 163, 184, 0.16);
  color: #f8fafc;
}

html[data-theme="dark"] .chatbot-field input::placeholder,
html[data-theme="dark"] .chatbot-composer input::placeholder {
  color: rgba(203, 213, 225, 0.75);
}

html[data-theme="dark"] .chatbot-summary {
  background: rgba(15, 23, 42, 0.66);
}

html[data-theme="dark"] .chatbot-edit-details {
  border-color: rgba(148, 163, 184, 0.16);
  color: #f8fafc;
}

html[data-theme="dark"] .chatbot-messages {
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 24%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.54), rgba(8, 23, 44, 0.18));
}

html[data-theme="dark"] .chatbot-message.bot .chatbot-bubble-message {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(96, 165, 250, 0.14);
  color: #f8fafc;
}

body.whatsapp-panel-open {
  overflow: hidden;
}

.whatsapp-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
}

.whatsapp-overlay[hidden] {
  display: none !important;
}

.whatsapp-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(8, 23, 44, 0.42);
}

.whatsapp-panel {
  position: relative;
  width: min(430px, calc(100vw - 24px));
  border: 1px solid rgba(18, 140, 126, 0.14);
  border-radius: 28px;
  overflow: hidden;
  background: #f7f5f1;
  box-shadow: 0 32px 76px rgba(8, 23, 44, 0.24);
}

.whatsapp-header {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1.1rem 1.15rem;
  background: linear-gradient(135deg, #128c7e, #25d366);
  color: #ffffff;
}

.whatsapp-avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1.45rem;
}

.whatsapp-header-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.whatsapp-header-copy h3 {
  margin: 0;
  color: #ffffff;
  font-size: 1.2rem;
}

.whatsapp-header-copy p {
  margin: 0.25rem 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.92rem;
}

.whatsapp-phone {
  display: inline-block;
  margin-top: 0.45rem;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.whatsapp-close {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.whatsapp-thread {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 180px;
  padding: 1rem 1rem 0.7rem;
  background:
    radial-gradient(circle at top right, rgba(37, 211, 102, 0.12), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.12));
}

.whatsapp-bubble {
  max-width: 88%;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  font-size: 0.94rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.whatsapp-bubble-support {
  align-self: flex-start;
  background: #ffffff;
  color: #10233d;
  border-bottom-left-radius: 8px;
}

.whatsapp-bubble-user {
  align-self: flex-end;
  background: #dcf8c6;
  color: #10233d;
  border-bottom-right-radius: 8px;
}

.whatsapp-form {
  display: grid;
  gap: 0.85rem;
  padding: 1rem 1rem 1.1rem;
  background: var(--surface);
  border-top: 1px solid rgba(16, 35, 61, 0.08);
}

.whatsapp-field {
  display: grid;
  gap: 0.35rem;
}

.whatsapp-field span {
  color: var(--text);
  font-size: 0.87rem;
  font-weight: 700;
}

.whatsapp-field input,
.whatsapp-field textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(16, 35, 61, 0.12);
  border-radius: 16px;
  background: #ffffff;
  color: var(--text);
  resize: vertical;
}

.whatsapp-field textarea {
  min-height: 120px;
}

.whatsapp-field input::placeholder,
.whatsapp-field textarea::placeholder {
  color: #7b8ba3;
}

.whatsapp-error {
  min-height: 22px;
  color: #dc2626;
  font-size: 0.85rem;
  font-weight: 600;
}

.whatsapp-note {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.whatsapp-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 54px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #128c7e, #25d366);
  color: #ffffff;
  font-weight: 800;
}

.whatsapp-action:hover,
.whatsapp-action:focus,
.whatsapp-close:hover,
.whatsapp-close:focus {
  filter: brightness(1.04);
}

html[dir="rtl"] .whatsapp-overlay {
  justify-content: flex-start;
}

html[dir="rtl"] .whatsapp-panel,
html[dir="rtl"] .whatsapp-header,
html[dir="rtl"] .whatsapp-form,
html[dir="rtl"] .whatsapp-field,
html[dir="rtl"] .whatsapp-note {
  text-align: right;
}

html[dir="rtl"] .whatsapp-header {
  flex-direction: row-reverse;
}

html[dir="rtl"] .whatsapp-bubble-support {
  align-self: flex-end;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 8px;
}

html[dir="rtl"] .whatsapp-bubble-user {
  align-self: flex-start;
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 8px;
}

html[data-theme="dark"] .whatsapp-panel {
  background: rgba(8, 23, 44, 0.95);
  border-color: rgba(37, 211, 102, 0.14);
  box-shadow: 0 36px 80px rgba(0, 0, 0, 0.42);
}

html[data-theme="dark"] .whatsapp-thread {
  background:
    radial-gradient(circle at top right, rgba(37, 211, 102, 0.16), transparent 24%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.78), rgba(8, 23, 44, 0.38));
}

html[data-theme="dark"] .whatsapp-form {
  border-top-color: rgba(148, 163, 184, 0.12);
  background: rgba(8, 23, 44, 0.96);
}

html[data-theme="dark"] .whatsapp-bubble-support {
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
}

html[data-theme="dark"] .whatsapp-bubble-user {
  background: linear-gradient(135deg, rgba(18, 140, 126, 0.96), rgba(37, 211, 102, 0.88));
  color: #ffffff;
}

html[data-theme="dark"] .whatsapp-field input,
html[data-theme="dark"] .whatsapp-field textarea {
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(148, 163, 184, 0.16);
  color: #f8fafc;
}

html[data-theme="dark"] .whatsapp-field input::placeholder,
html[data-theme="dark"] .whatsapp-field textarea::placeholder {
  color: rgba(203, 213, 225, 0.74);
}

@media (max-width: 767.98px) {
  .chatbot-widget {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }

  html[dir="rtl"] .chatbot-widget {
    left: 12px;
    right: 12px;
  }

  .chatbot-panel {
    width: 100%;
    max-height: min(78vh, 680px);
  }

  .chatbot-launcher {
    align-self: flex-end;
  }

  .chatbot-stage {
    min-height: 460px;
  }

  .chatbot-summary,
  .chatbot-composer {
    grid-template-columns: 1fr;
  }

  .chatbot-composer button {
    width: 100%;
  }

  .whatsapp-overlay {
    padding: 12px;
  }

  .whatsapp-panel {
    width: 100%;
    max-width: 100%;
  }

  .whatsapp-thread {
    min-height: 160px;
  }
}
