/* ============================================
   Shoppers Junction — Premium Support Concierge
   Prefixed .ec-chat-* (JS functional hooks preserved)
   ============================================ */

:root {
  --ec-chat-orange: #ff6a00;
  --ec-chat-orange-mid: #ff8a1f;
  --ec-chat-orange-soft: #ffad46;
  --ec-chat-ink: #1c1a17;
  --ec-chat-muted: #8a847a;
  --ec-chat-soft: #5f5950;
  --ec-chat-cream: #faf7f3;
  --ec-chat-card: #ffffff;
  --ec-chat-bubble: #f7f5f2;
  --ec-chat-tint: #fffaf5;
  --ec-chat-line: #f1e8df;
  --ec-chat-line-warm: rgba(255, 140, 40, 0.12);
  --ec-chat-green: #22c55e;
  --ec-chat-font: 'Outfit', system-ui, sans-serif;
  --ec-chat-display: 'Syne', 'Outfit', sans-serif;
  --ec-chat-z: 10050;
  --ec-chat-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.ec-chat-widget {
  position: fixed;
  z-index: var(--ec-chat-z);
  font-family: var(--ec-chat-font);
  color: var(--ec-chat-ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.ec-chat-widget *,
.ec-chat-widget *::before,
.ec-chat-widget *::after {
  box-sizing: border-box;
}

/* ---------- Launcher ---------- */

.ec-chat-launcher-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--ec-chat-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.ec-chat-launcher-hint {
  padding: 7px 12px;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: var(--ec-chat-ink);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  box-shadow: 0 8px 24px rgba(40, 20, 0, 0.1);
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ec-chat-launcher-wrap.is-open .ec-chat-launcher-hint {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.ec-chat-launcher {
  position: relative;
  width: 60px;
  height: 60px;
  padding: 0;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #ff6a00, #ff9f32);
  box-shadow: 0 14px 35px rgba(255, 110, 0, 0.32);
  display: grid;
  place-items: center;
  transition: transform 0.25s var(--ec-chat-ease), box-shadow 0.25s ease;
}

.ec-chat-launcher-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.ec-chat-launcher.is-open .ec-chat-launcher-dot {
  display: none;
}

.ec-chat-launcher:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px rgba(255, 110, 0, 0.38);
}

.ec-chat-launcher:active {
  transform: translateY(-1px) scale(0.97);
}

.ec-chat-launcher:focus-visible {
  outline: 3px solid rgba(255, 107, 0, 0.4);
  outline-offset: 3px;
}

.ec-chat-launcher-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}

.ec-chat-launcher-icon svg {
  width: 26px;
  height: 26px;
}

.ec-chat-launcher-label,
.ec-chat-launcher-pulse {
  display: none;
}

/* ---------- Panel ---------- */

.ec-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  width: 400px;
  height: min(650px, calc(100vh - 100px));
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--ec-chat-line-warm);
  border-radius: 28px;
  box-shadow:
    0 24px 70px rgba(40, 20, 0, 0.16),
    0 6px 18px rgba(255, 120, 20, 0.08);
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.26s var(--ec-chat-ease),
    transform 0.26s var(--ec-chat-ease),
    visibility 0.26s;
}

.ec-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

/* ---------- Header ---------- */

.ec-chat-header {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 18px 16px 16px;
  color: #fff;
  background: linear-gradient(135deg, #ff6a00, #ff8a1f, #ffad46);
  border-radius: 28px 28px 22px 22px;
  min-height: 135px;
}

.ec-chat-header-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(18px);
}

.ec-chat-header-glow--tr {
  top: -28px;
  right: -18px;
  width: 110px;
  height: 110px;
  background: rgba(255, 255, 255, 0.28);
}

.ec-chat-header-glow--bl {
  bottom: -36px;
  left: -20px;
  width: 90px;
  height: 90px;
  background: rgba(255, 200, 80, 0.35);
}

.ec-chat-header-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ec-chat-header-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.ec-chat-header-icon svg {
  width: 22px;
  height: 22px;
}

.ec-chat-header-copy {
  flex: 1;
  min-width: 0;
}

.ec-chat-header-title {
  margin: 0;
  font-family: var(--ec-chat-display);
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.ec-chat-header-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
}

.ec-chat-header-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ec-chat-green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.ec-chat-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.ec-chat-icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.15s ease;
}

.ec-chat-icon-btn:hover,
.ec-chat-icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.28);
}

.ec-chat-icon-btn:active {
  transform: scale(0.96);
}

.ec-chat-icon-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.ec-chat-icon-btn svg {
  width: 16px;
  height: 16px;
}

.ec-chat-header-intro {
  position: relative;
  z-index: 1;
  margin-top: 16px;
}

.ec-chat-header-desc {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.ec-chat-header-sub {
  margin: 4px 0 0;
  font-size: 0.76rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.88);
}

/* ---------- Body / scroll ---------- */

.ec-chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: transparent;
  padding: 12px 12px 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 140, 50, 0.35) transparent;
}

.ec-chat-body::-webkit-scrollbar {
  width: 5px;
}

.ec-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.ec-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 140, 50, 0.35);
  border-radius: 99px;
}

/* ---------- Welcome ---------- */

.ec-chat-welcome {
  animation: ec-chat-fade-up 0.28s var(--ec-chat-ease);
}

.ec-chat-welcome-hi {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.ec-chat-welcome-title {
  margin: 0 0 4px;
  font-family: var(--ec-chat-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.ec-chat-welcome-text {
  margin: 0 0 16px;
  color: var(--ec-chat-soft);
  font-size: 0.84rem;
}

.ec-chat-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ec-chat-action {
  appearance: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--ec-chat-line);
  border-radius: 18px;
  background: #fff;
  color: var(--ec-chat-ink);
  box-shadow: 0 5px 18px rgba(30, 15, 0, 0.05);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition:
    transform 0.18s var(--ec-chat-ease),
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.ec-chat-action:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 106, 0, 0.35);
  box-shadow: 0 10px 24px rgba(255, 120, 20, 0.1);
}

.ec-chat-action:active {
  transform: translateY(0) scale(0.99);
  background: #fff8f1;
}

.ec-chat-action:focus-visible {
  outline: 2px solid var(--ec-chat-orange);
  outline-offset: 2px;
}

.ec-chat-action-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #fff3e8;
  color: var(--ec-chat-orange);
}

.ec-chat-action-icon svg {
  width: 16px;
  height: 16px;
}

.ec-chat-action-label {
  flex: 1;
  min-width: 0;
}

.ec-chat-action-arrow {
  flex-shrink: 0;
  color: #c4b8ab;
  opacity: 0.75;
}

.ec-chat-action-arrow svg {
  width: 14px;
  height: 14px;
}

.ec-chat-action.is-featured {
  grid-column: 1 / -1;
  min-height: 78px;
  background: linear-gradient(135deg, #fff7f0, #fff1e3);
  border-color: #f3e3d5;
  padding: 14px 14px 14px 12px;
}

.ec-chat-action.is-featured .ec-chat-action-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.ec-chat-action.is-featured .ec-chat-action-sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ec-chat-muted);
}

.ec-chat-action.is-featured .ec-chat-action-go {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(255, 106, 0, 0.1);
  color: var(--ec-chat-orange);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ec-chat-action.is-featured .ec-chat-action-go svg {
  width: 15px;
  height: 15px;
}

.ec-chat-more-toggle {
  appearance: none;
  margin-top: 12px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ec-chat-soft);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  padding: 8px;
  border-radius: 12px;
  transition: background 0.15s ease, color 0.15s ease;
}

.ec-chat-more-toggle:hover {
  background: #fff7ef;
  color: var(--ec-chat-orange);
}

.ec-chat-more-options {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.ec-chat-more-options.is-open {
  display: grid;
}

/* Inline quick replies in thread stay compact chips */
.ec-chat-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ec-chat-inline-actions .ec-chat-action {
  min-height: 0;
  width: auto;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  gap: 6px;
  box-shadow: none;
  font-size: 0.74rem;
}

.ec-chat-inline-actions .ec-chat-action-icon,
.ec-chat-inline-actions .ec-chat-action-arrow,
.ec-chat-inline-actions .ec-chat-action-go,
.ec-chat-inline-actions .ec-chat-action-sub {
  display: none;
}

.ec-chat-inline-actions .ec-chat-action.is-featured {
  background: #fff;
  grid-column: auto;
}

/* ---------- Messages ---------- */

.ec-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

.ec-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 100%;
  animation: ec-chat-fade-up 0.22s var(--ec-chat-ease);
}

.ec-chat-row.is-customer {
  flex-direction: row-reverse;
}

.ec-chat-avatar {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: #fff3e8;
  color: var(--ec-chat-orange);
}

.ec-chat-avatar.is-spacer {
  visibility: hidden;
  width: 22px;
}

.ec-chat-row.is-customer .ec-chat-avatar {
  background: linear-gradient(135deg, #ff6600, #ff8b1f);
  color: #fff;
}

.ec-chat-row.is-customer .ec-chat-avatar.is-spacer {
  visibility: hidden;
}

.ec-chat-avatar svg {
  width: 12px;
  height: 12px;
}

.ec-chat-bubble-wrap {
  max-width: 84%;
  min-width: 0;
}

.ec-chat-row.is-customer .ec-chat-bubble-wrap {
  max-width: 80%;
}

.ec-chat-bubble {
  padding: 10px 14px;
  border-radius: 18px 18px 18px 6px;
  font-size: 0.875rem;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ec-chat-row.is-assistant .ec-chat-bubble {
  background: #ffffff;
  color: #222222;
  border: 1px solid #eee3d8;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
}

.ec-chat-row.is-customer .ec-chat-bubble {
  background: linear-gradient(135deg, #ff6600, #ff8b1f);
  color: #ffffff;
  border: none;
  border-radius: 18px 18px 6px 18px;
  box-shadow: 0 3px 12px rgba(255, 102, 0, 0.18);
}

.ec-chat-meta {
  margin-top: 2px;
  font-size: 0.62rem;
  color: var(--ec-chat-muted);
  line-height: 1.2;
}

.ec-chat-row.is-customer .ec-chat-meta {
  text-align: right;
}

.ec-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #f0e7df;
  border-radius: 18px 18px 18px 6px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
}

.ec-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c4b4a4;
  animation: ec-chat-bounce 1s infinite ease-in-out;
}

.ec-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.ec-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ec-chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-3px); opacity: 1; background: var(--ec-chat-orange-mid); }
}

@keyframes ec-chat-fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Support form ---------- */

.ec-chat-form {
  margin-top: 10px;
  padding: 16px;
  background: #fffaf5;
  border: 1px solid #f3e3d5;
  border-radius: 20px;
  display: grid;
  gap: 12px;
}

.ec-chat-form-field {
  position: relative;
  display: grid;
}

.ec-chat-form-field label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ec-chat-muted);
  pointer-events: none;
  transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease;
}

.ec-chat-form-field input {
  width: 100%;
  height: 46px;
  border: 1px solid #efe6dc;
  border-radius: 13px;
  padding: 18px 14px 6px;
  font: inherit;
  font-size: 0.88rem;
  background: #fff;
  color: var(--ec-chat-ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ec-chat-form-field input:focus,
.ec-chat-form-field input:not(:placeholder-shown) {
  outline: none;
}

.ec-chat-form-field input:focus {
  border-color: var(--ec-chat-orange);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.12);
}

.ec-chat-form-field input:focus + label,
.ec-chat-form-field input:not(:placeholder-shown) + label,
.ec-chat-form-field.has-value label {
  top: 9px;
  transform: none;
  font-size: 0.65rem;
  font-weight: 650;
  color: var(--ec-chat-orange);
}

.ec-chat-form-note {
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--ec-chat-muted);
}

.ec-chat-form-note svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--ec-chat-orange-mid);
}

.ec-chat-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.ec-chat-form-submit {
  border: none;
  height: 48px;
  border-radius: 14px;
  padding: 0 16px;
  background: linear-gradient(135deg, #ff6a00, #ff9d35);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.ec-chat-form-submit:hover,
.ec-chat-form-submit:focus-visible {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.ec-chat-form-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.ec-chat-error {
  color: #b42318;
  font-size: 0.78rem;
}

.ec-chat-row.is-alert {
  justify-content: stretch;
}

.ec-chat-alert {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff4f2;
  border: 1px solid rgba(180, 35, 24, 0.16);
  color: #8a1f16;
  font-size: 0.84rem;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.ec-chat-form.is-sent {
  opacity: 0.92;
}

.ec-chat-form.is-sent .ec-chat-form-submit {
  background: #1f7a3f;
  cursor: default;
}

/* ---------- Composer ---------- */

.ec-chat-composer-shell {
  flex: 0 0 auto;
  padding: 10px 12px 12px;
  background: transparent;
}

.ec-chat-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 6px 6px 6px 14px;
  background: #fff;
  border: 1px solid #eee5dd;
  border-radius: 18px;
  box-shadow: 0 5px 20px rgba(20, 10, 0, 0.05);
}

.ec-chat-composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 88px;
  resize: none;
  border: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 0;
  font: inherit;
  font-size: 0.9rem;
  background: transparent;
  color: var(--ec-chat-ink);
  line-height: 1.4;
  overflow-y: auto;
  scrollbar-width: none;
}

.ec-chat-composer textarea::-webkit-scrollbar {
  display: none;
}

.ec-chat-composer textarea:focus,
.ec-chat-composer textarea:focus-visible {
  outline: none;
  box-shadow: none;
}

.ec-chat-send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6a00, #ff9f32);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.15s var(--ec-chat-ease), opacity 0.15s ease;
}

.ec-chat-send:hover {
  transform: scale(1.04);
}

.ec-chat-send:focus-visible {
  outline: 2px solid var(--ec-chat-orange);
  outline-offset: 2px;
}

.ec-chat-send:disabled {
  background: #ffe3c8;
  color: #fff;
  cursor: not-allowed;
  transform: none;
  opacity: 1;
}

.ec-chat-send svg {
  width: 17px;
  height: 17px;
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  .ec-chat-launcher-wrap {
    right: 12px;
    bottom: 14px;
  }

  .ec-chat-panel {
    right: 8px;
    left: 8px;
    bottom: 72px;
    width: calc(100vw - 16px);
    height: min(82vh, 680px);
    max-height: calc(100dvh - 88px);
    border-radius: 24px;
  }

  .ec-chat-header {
    min-height: 118px;
    padding: 14px 14px 12px;
    border-radius: 24px 24px 18px 18px;
  }

  .ec-chat-header-sub {
    display: none;
  }

  .ec-chat-body {
    padding: 12px 12px 6px;
  }

  .ec-chat-action {
    min-height: 68px;
    padding: 10px;
    font-size: 0.76rem;
  }
}

@media (max-width: 360px) {
  .ec-chat-actions,
  .ec-chat-more-options.is-open {
    grid-template-columns: 1fr;
  }

  .ec-chat-header-title {
    font-size: 0.95rem;
  }
}

@media (max-height: 720px) {
  .ec-chat-panel {
    height: min(580px, calc(100vh - 90px));
  }

  .ec-chat-header {
    min-height: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ec-chat-panel,
  .ec-chat-launcher,
  .ec-chat-send,
  .ec-chat-action,
  .ec-chat-row,
  .ec-chat-welcome,
  .ec-chat-typing span {
    transition: none !important;
    animation: none !important;
  }
}
