/* Shared chat widget — theme via [data-chat-site] */
.chat-widget {
  --chat-accent: #c45c26;
  --chat-bg: #fff;
  --chat-text: #1a1a1a;
  --chat-muted: #5c5c5c;
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  font-family: 'DM Sans', system-ui, sans-serif;
}

[data-chat-site="trade-servicez"].chat-widget {
  --chat-accent: #0b6e8c;
}

.chat-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: var(--chat-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle:hover { transform: translateY(-2px); }

.chat-toggle svg { width: 22px; height: 22px; flex-shrink: 0; }

.chat-panel {
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: calc(100% + 0.75rem);
  right: 0;
  width: min(380px, calc(100vw - 2rem));
  height: min(520px, calc(100dvh - 8rem));
  background: var(--chat-bg);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.chat-panel.open { display: flex; }

.chat-header {
  padding: 0.9rem 1rem;
  background: var(--chat-accent);
  color: #fff;
}

.chat-header h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.15rem; }
.chat-header p { font-size: 0.78rem; margin: 0; opacity: 0.9; }

.chat-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #f8f9fb;
}

.chat-msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg strong { font-weight: 600; }

.chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--chat-text);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--chat-accent);
  color: #fff;
}

.chat-msg.typing {
  color: var(--chat-muted);
  font-style: italic;
  background: transparent;
  border: none;
  padding: 0.25rem 0;
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.5rem;
  background: #f8f9fb;
}

.chat-chip {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--chat-text);
}

.chat-chip:hover { border-color: var(--chat-accent); color: var(--chat-accent); }

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.chat-action {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--chat-accent);
  text-decoration: none;
}

.chat-action:hover { text-decoration: underline; }

button.chat-send-request:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.chat-send-request {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: var(--chat-accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

.chat-form {
  display: block;
  flex: 0 0 auto;
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.chat-compose {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chat-attach { margin-top: 0.4rem; }

.chat-photo-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  background: #fff;
  color: var(--chat-accent);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
}

.chat-form input.chat-photo-input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0.02;
  cursor: pointer;
  font-size: 16px;
  pointer-events: auto;
  padding: 0;
  border: 0;
  flex: none;
}

.chat-photo-note, .chat-photo-consent {
  margin: 0.35rem 0 0;
  color: var(--text-muted, #5c6b73);
  font-size: 0.75rem;
  line-height: 1.35;
}

.chat-photo-consent { display: none; align-items: flex-start; gap: 0.4rem; }
.chat-photo-consent.show { display: flex; }

.chat-photo-preview { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }

.chat-photo-thumb { position: relative; width: 72px; height: 72px; }
.chat-photo-thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.chat-photo-thumb button {
  position: absolute; top: -6px; right: -6px;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: #16323c; color: #fff; cursor: pointer;
  font-size: 1.25rem; line-height: 1;
}

.chat-form input.chat-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
}

.chat-form input.chat-input:focus {
  outline: 2px solid color-mix(in srgb, var(--chat-accent) 25%, transparent);
  border-color: var(--chat-accent);
}

.chat-send {
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 44px;
  padding: 0.6rem 0.9rem;
  border: none;
  border-radius: 999px;
  background: var(--chat-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

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

@media (max-width: 960px) {
  .chat-widget { bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); }
  [data-chat-site="trade-servicez"].chat-widget { bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
  .chat-toggle { font-size: 0; padding: 0.85rem; min-width: 44px; min-height: 44px; }
  .chat-toggle svg { width: 22px; height: 22px; }
  .chat-panel.open {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--chat-vv-top, 0px);
    bottom: auto;
    width: 100%;
    height: var(--chat-vvh, 100dvh);
    max-height: var(--chat-vvh, 100dvh);
    border-radius: 0;
  }
}
}