.support-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: var(--font-sans, "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif);
  color: var(--text, #222);
  line-height: 1.4;
}

.support-chat-root.is-visible {
  display: block;
}

.support-chat-root *,
.support-chat-root *::before,
.support-chat-root *::after {
  box-sizing: border-box;
}

.support-chat-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 50px;
  padding: 0 18px 0 15px;
  border: 1px solid var(--primary, #2e8b46);
  border-radius: 10px;
  background: var(--primary, #2e8b46);
  color: #fff;
  box-shadow: 0 2px 10px rgba(46, 139, 70, 0.28);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  transition:
    background 0.12s ease,
    color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

.support-chat-fab-icon {
  flex: 0 0 auto;
  display: block;
  opacity: 0.95;
}

.support-chat-fab:hover {
  background: var(--primary-hover, #1f6b32);
  border-color: var(--primary-hover, #1f6b32);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 139, 70, 0.34);
}

.support-chat-fab:focus-visible {
  outline: 2px solid var(--primary, #2e8b46);
  outline-offset: 3px;
}

.support-chat-fab[aria-expanded="true"] {
  background: #fff;
  color: var(--primary, #2e8b46);
  border-color: var(--primary, #2e8b46);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.support-chat-fab[aria-expanded="true"]:hover {
  background: var(--primary-soft, #e5efe6);
  color: var(--primary-hover, #1f6b32);
  border-color: var(--primary-hover, #1f6b32);
}

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

@media (min-width: 480px) {
  .support-chat-fab-label {
    display: inline;
  }
}

.support-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 100px));
  max-height: min(560px, calc(100vh - 100px));
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dde5df);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

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

.support-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #dde5df);
  background: var(--soft-bg, #f7faf8);
}

.support-chat-title {
  margin: 0;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
  color: var(--text, #1a1a1a);
}

.support-chat-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: -6px -4px -6px 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim, #5c6670);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.support-chat-close:hover {
  background: #fff;
  border-color: var(--border, #dde5df);
  color: var(--text, #1a1a1a);
}

.support-chat-close:focus-visible {
  outline: 2px solid var(--primary, #2e8b46);
  outline-offset: 1px;
}

.support-chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 12px;
  background: #fafcfb;
  -webkit-overflow-scrolling: touch;
}

.support-chat-empty {
  margin: 0;
  color: var(--text-dim, #5c6670);
  font-size: 14px;
  line-height: 1.5;
}

.support-chat-converted {
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 12px;
  background: #e8f2ea;
  border: 1px solid #b8d4be;
  color: #1f4d2c;
  font-size: 14px;
  line-height: 1.5;
}

.support-chat-converted a,
.support-chat-converted-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #2e8b46;
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
}

.support-chat-compose {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px 14px;
  border-top: 1px solid var(--border, #dde5df);
  background: var(--card-bg, #fff);
}

.support-chat-input {
  display: block;
  width: 100%;
  min-height: 64px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--border, #dde5df);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
  box-sizing: border-box;
}

.support-chat-input:focus {
  outline: none;
  border-color: var(--primary, #2e8b46);
  box-shadow: 0 0 0 3px rgba(46, 139, 70, 0.16);
}

.support-chat-input::placeholder {
  color: var(--text-mute, #8a8a8a);
}

.support-chat-send {
  align-self: flex-end;
  flex: 0 0 auto;
  border: none;
  border-radius: 10px;
  min-height: 40px;
  padding: 9px 18px;
  background: var(--primary, #2e8b46);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.support-chat-send:hover:not(:disabled) {
  background: var(--primary-hover, #1f6b32);
}

.support-chat-send:focus-visible {
  outline: 2px solid var(--primary, #2e8b46);
  outline-offset: 2px;
}

.support-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.support-chat-signin {
  padding: 16px;
  font-size: 14px;
  color: var(--text-dim, #5c6670);
  line-height: 1.5;
}

.support-chat-signin button {
  margin-top: 12px;
  border: none;
  border-radius: 10px;
  background: var(--primary, #2e8b46);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 18px;
  font-size: 14px;
}

.support-chat-signin button:hover {
  background: var(--primary-hover, #267a3d);
}

/* Reuse custom-order chat bubble styling */
.support-chat-body .chat-row {
  display: flex;
  margin-bottom: 10px;
}

.support-chat-body .chat-row--in {
  justify-content: flex-start;
}

.support-chat-body .chat-row--out {
  justify-content: flex-end;
}

.support-chat-body .chat-row--system {
  justify-content: center;
}

.support-chat-body .chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
}

.support-chat-body .chat-bubble--in {
  background: #fff;
  border: 1px solid #dde5df;
}

.support-chat-body .chat-bubble--out {
  background: #2e8b46;
  color: #fff;
}

.support-chat-body .chat-bubble--system {
  background: #eef4ef;
  border: 1px solid #c8dccf;
  color: #1f4d2c;
  text-align: center;
}

.support-chat-body .chat-bubble--proposal {
  text-align: left;
}

.support-chat-body .chat-bubble--proposal .support-chat-proposal-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.support-chat-body .chat-bubble--proposal .support-chat-proposal-accept,
.support-chat-body .chat-bubble--proposal .support-chat-proposal-decline {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.support-chat-body .chat-bubble--proposal .support-chat-proposal-accept {
  background: #2e8b46;
  color: #fff;
}

.support-chat-body .chat-bubble--proposal .support-chat-proposal-decline {
  background: #fff;
  color: #5c6670;
  border: 1px solid #dde5df;
}

.support-chat-body .chat-bubble-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
  opacity: 0.85;
}

.support-chat-body .chat-bubble-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.support-chat-body .chat-bubble-time {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.75;
}

.support-chat-body .chat-page-tag {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.8;
  font-style: italic;
}

.support-chat-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #c62828;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.support-chat-fab-wrap {
  position: relative;
}

.support-chat-mode-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border, #dde5df);
  background: var(--soft-bg, #f7faf8);
}

.support-chat-mode-btn {
  flex: 1;
  border: 1px solid var(--border, #dde5df);
  border-radius: 999px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text-dim, #5c6670);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.support-chat-mode-btn:hover {
  border-color: #b8d4be;
  color: #1f4d2c;
}

.support-chat-mode-btn:focus-visible {
  outline: 2px solid var(--primary, #2e8b46);
  outline-offset: 1px;
}

.support-chat-mode-btn.is-active {
  background: #e8f2ea;
  border-color: #b8d4be;
  color: #1f4d2c;
}

.support-chat-assistant-wrap,
.support-chat-human-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.support-chat-assistant-wrap[hidden],
.support-chat-human-wrap[hidden] {
  display: none !important;
}

.support-chat-escalate {
  margin: 0 12px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff8e6;
  border: 1px solid #f0dca8;
  font-size: 13px;
  color: #5c4a1f;
}

.support-chat-escalate p {
  margin: 0 0 8px;
}

.support-chat-escalate-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--primary, #2e8b46);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.support-chat-body .chat-bubble--assistant {
  background: #f3f6ff;
  border: 1px solid #d5ddf5;
}

.support-chat-body .chat-bubble--assistant .support-chat-assistant-link {
  color: #1a5c3a;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.support-chat-body .chat-bubble--assistant .support-chat-assistant-link:hover {
  color: #0d3d26;
}

.support-chat-assistant-chips {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 12px;
}

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

.support-chat-assistant-chip {
  border: 1px solid #c5d9cc;
  background: #fff;
  color: #1a5c3a;
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.25;
  white-space: nowrap;
}

.support-chat-assistant-chip:hover {
  background: #e6f2ea;
}

.support-chat-assistant-chip:focus-visible {
  outline: 2px solid var(--primary, #2e8b46);
  outline-offset: 1px;
}

.support-chat-assistant-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.support-chat-proposal {
  flex-shrink: 0;
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #dde5df);
  background: #eef6f0;
}

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

.support-chat-proposal-text {
  margin: 0 0 6px;
  font-size: 14px;
  color: #1f4d2c;
}

.support-chat-proposal-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: #4a5c4e;
  line-height: 1.45;
}

.support-chat-proposal-actions {
  display: flex;
  gap: 8px;
}

.support-chat-proposal-accept,
.support-chat-proposal-decline {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.support-chat-proposal-accept {
  background: #2e8b46;
  color: #fff;
}

.support-chat-proposal-decline {
  background: #fff;
  color: #5c6670;
  border: 1px solid #dde5df;
}

.support-chat-archive {
  margin-bottom: 12px;
  opacity: 0.92;
}

.support-chat-archive-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #4a5c4e;
}

.support-chat-archive-link {
  color: #2e8b46;
  font-weight: 600;
}

.support-chat-divider {
  margin: 14px 0 4px;
  border: none;
  border-top: 2px dashed #b8c4ba;
}

.support-chat-section-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4a5c4e;
}

.support-chat-body .chat-bubble--declined {
  background: #fdecea;
  border-color: #f5c6c0;
  color: #7a2e2e;
}

@media (max-width: 479px) {
  .support-chat-root {
    right: 12px;
    bottom: 12px;
  }

  .support-chat-panel {
    right: 0;
    width: min(100vw - 24px, 380px);
    height: min(72vh, calc(100vh - 88px));
    max-height: min(72vh, calc(100vh - 88px));
  }
}
