.support-chat-widget {
  --support-widget-width: clamp(320px, 92vw, 400px);
  --support-widget-height: clamp(420px, 72vh, 620px);
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1200;
  font-family: system-ui, sans-serif;
}

.support-chat-widget.is-embedded {
  --support-widget-width: min(100%, 400px);
  --support-widget-height: 580px;
  position: static;
  right: auto;
  bottom: auto;
  z-index: auto;
  width: var(--support-widget-width);
  margin: 0 auto;
}

.support-chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--home-accent, #2563eb);
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.28);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.support-chat-launcher:hover,
.support-chat-launcher:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.34);
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.support-chat-launcher-icon {
  display: inline-flex;
}

.support-chat-panel-root {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  width: var(--support-widget-width);
  height: var(--support-widget-height);
  max-height: var(--support-widget-height);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--home-border, #e5e7eb);
  border-radius: 1rem;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.support-chat-widget.is-embedded .support-chat-panel-root {
  position: static;
  width: 100%;
  height: var(--support-widget-height);
  max-height: 620px;
  min-height: 520px;
  box-shadow: var(--home-shadow, 0 1px 2px rgba(15, 23, 42, 0.06));
}

.support-chat-widget:not(.is-open):not(.is-embedded) .support-chat-panel-root {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
}

.support-chat-widget.is-open .support-chat-panel-root,
.support-chat-widget.is-embedded .support-chat-panel-root {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.support-chat-widget-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--home-border, #e5e7eb);
  background: #f8fafc;
}

.support-chat-widget-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.support-chat-widget-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.support-chat-widget-action {
  border: 0;
  background: transparent;
  color: var(--home-accent, #2563eb);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
}

.support-chat-widget-action:hover,
.support-chat-widget-action:focus-visible {
  text-decoration: underline;
  outline: none;
}

.support-chat-widget-minimize {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--home-border, #e5e7eb);
  border-radius: 999px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.support-chat-widget-minimize:hover,
.support-chat-widget-minimize:focus-visible {
  background: #f1f5f9;
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.support-chat-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--home-border, #e5e7eb);
  font-size: 0.85rem;
}

.support-chat-toolbar[hidden] {
  display: none !important;
}

.support-chat-business-select {
  min-width: 0;
  flex: 1 1 160px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--home-border, #e5e7eb);
  border-radius: 0.5rem;
}

.support-chat-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.support-chat-empty {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.25rem;
  text-align: center;
  color: #64748b;
  font-size: 0.92rem;
  overflow: auto;
}

.support-chat-empty[hidden],
.support-chat-panel[hidden] {
  display: none !important;
}

.support-chat-empty p {
  margin: 0;
}

.support-chat-start-btn {
  width: auto;
}

.support-chat-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.support-chat-messages {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 0.85rem;
}

.support-chat-messages::before {
  content: "";
  flex: 1 1 auto;
  min-height: 0;
}

.support-chat-messages > .support-chat-message:last-child {
  margin-bottom: 0;
}

.support-chat-composer {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid var(--home-border, #e5e7eb);
}

.support-chat-message {
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  max-width: 92%;
}

.support-chat-message-user {
  margin-left: auto;
  background: #eff6ff;
}

.support-chat-message-assistant {
  margin-right: auto;
  background: #f8fafc;
  border: 1px solid var(--home-border, #e5e7eb);
}

.support-chat-message header {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #64748b;
}

.support-chat-message p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.support-chat-form {
  padding: 0.75rem 0.75rem 0;
  background: #fff;
}

.support-chat-form textarea {
  width: 100%;
  resize: none;
  min-height: 56px;
  max-height: 120px;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--home-border, #e5e7eb);
  border-radius: 0.65rem;
  font: inherit;
  box-sizing: border-box;
}

.support-chat-form textarea:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.support-chat-form-actions {
  margin-top: 0.55rem;
  display: flex;
  justify-content: flex-end;
}

.support-chat-status {
  min-height: 1rem;
  padding: 0 0.75rem 0.65rem;
  font-size: 0.82rem;
  color: #64748b;
}

.support-chat-status.is-error {
  color: #b00020;
}

.support-chat-embedded-page {
  padding: 1.25rem 0 2rem;
  max-width: 420px;
  margin: 0 auto;
}

.support-chat-embedded-header {
  margin: 0 0 1rem;
  text-align: center;
}

.support-chat-embedded-title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
}

.support-chat-embedded-intro {
  margin: 0 0 0.75rem;
  color: #64748b;
  font-size: 0.95rem;
  line-height: 1.45;
}

.support-chat-embedded-lead {
  margin: 0;
  color: #64748b;
  font-size: 0.9rem;
}

.support-chat-embedded-lead a {
  color: var(--home-accent, #2563eb);
}

.support-chat-widget.is-embedded .support-chat-empty {
  justify-content: flex-start;
  padding: 1rem 1.25rem 1.25rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 640px) {
  .support-chat-widget:not(.is-embedded) {
    right: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
  }

  .support-chat-launcher-label {
    display: none;
  }

  .support-chat-widget:not(.is-embedded) .support-chat-panel-root {
    right: 0;
    left: 0;
    width: auto;
    max-height: min(72vh, 620px);
  }

  .support-chat-widget.is-embedded {
    --support-widget-height: min(580px, calc(100vh - 8rem));
    width: min(100%, calc(100vw - 1.5rem));
  }
}
