/* SADA Support Chat Redesign */
/* Professional customer-support messenger with SADA visual identity */

/* The chat inherits the site's own accent tokens so it can never drift from
   the rest of sada.rw. --gold-hi is the same #D4AF37 the License Center uses
   as its default accent, so both surfaces speak one colour language.
   When the Owner publishes an accent from the License Center it arrives as
   --sada-accent* and wins here; without a published accent the chat keeps
   the site's own brand gold exactly as before. */
:root {
  --support-accent: var(--sada-accent, var(--gold-hi, #D4AF37));
  --support-accent-deep: var(--sada-accent-deep, var(--gold-deep, #8F751F));
  --support-accent-ink: var(--sada-accent-ink, var(--paper-ink, #0A0A0A));
  /* The launcher geometry, in one place, so the page can reserve the band
     the disc occupies instead of guessing at it. */
  --support-launcher-size: 56px;
  --support-launcher-inset: 16px;
  --support-launcher-band: calc(var(--support-launcher-size) + var(--support-launcher-inset) + 12px);
}

/* ============================================
   LAUNCHER BUTTON
   ============================================ */
/* The launcher is a fixed overlay, so it can only ever sit where the page
   leaves room. The labelled pill was 230px wide and, on a 1366x768 laptop, it
   landed on top of the hero "Utforska SADA" button and on the owner's advert
   card. The launcher is now a 56x56 disc in the bottom-right corner, the one
   place no measured hero call to action reaches, and the brand label survives
   as a hover/focus tooltip. */
.support-chat-launcher {
  position: fixed;
  left: auto;
  right: max(var(--support-launcher-inset), env(safe-area-inset-right));
  bottom: max(var(--support-launcher-inset), env(safe-area-inset-bottom));
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: var(--support-launcher-size);
  height: var(--support-launcher-size);
  min-height: var(--support-launcher-size);
  padding: 0;
  border: 2px solid var(--support-accent);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink) 0%, #1a1a1a 100%);
  color: var(--support-accent);
  font: 700 1rem var(--font);
  cursor: pointer;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 0 1px color-mix(in srgb, var(--support-accent) 15%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.02em;
}

/* The advert card owns the bottom-right corner, so it steps up above the
   launcher disc on every screen size. Phones already did this; the desktop
   needed the same clearance once the launcher became a disc. */
.support-chat-ready .ad-slot {
  bottom: 80px;
  max-height: calc(100dvh - 100px);
}

/* The panel occupies the same corner, so the launcher steps aside while the
   conversation is open. */
body.support-chat-open .support-chat-launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

.support-chat-launcher:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.6),
    0 0 0 2px color-mix(in srgb, var(--support-accent) 30%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border-color: var(--support-accent);
}

.support-chat-launcher:active {
  transform: translateY(-1px);
}

.support-chat-launcher-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 4px color-mix(in srgb, var(--support-accent) 30%, transparent));
}

/* The brand label stays available to pointer users as a tooltip above the
   disc. It never enters the accessible name: the button carries an aria-label. */
.support-chat-launcher-text {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  transform: translateY(6px);
  padding: 7px 14px;
  border: 1px solid color-mix(in srgb, var(--support-accent) 35%, transparent);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ink) 0%, #1a1a1a 100%);
  color: var(--support-accent);
  font: 700 .82rem var(--font);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.support-chat-launcher:hover .support-chat-launcher-text,
.support-chat-launcher:focus-visible .support-chat-launcher-text {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   CHAT PANEL
   ============================================ */
.support-chat-panel {
  position: fixed;
  z-index: 150;
  left: max(20px, env(safe-area-inset-left));
  top: calc(var(--support-top, 0px) + max(20px, var(--support-vh, 100dvh) - 680px));
  width: min(460px, calc(100vw - 40px));
  height: min(680px, calc(var(--support-vh, 100dvh) - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1.5px solid color-mix(in srgb, var(--support-accent) 25%, transparent);
  border-radius: 24px;
  background: linear-gradient(180deg, #1a1d1f 0%, #0f1113 100%);
  color: var(--text);
  box-shadow: 
    0 24px 80px rgba(0, 0, 0, 0.7),
    0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-size: 0.95rem;
  line-height: 1.6;
  animation: panelSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

/* ============================================
   HEADER
   ============================================ */
.support-chat-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1.5px solid color-mix(in srgb, var(--support-accent) 15%, transparent);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.2) 100%);
  position: relative;
}

.support-chat-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--support-accent) 30%, transparent), transparent);
}

.support-chat-header-content {
  display: flex;
  align-items: center;
  gap: 14px;
  row-gap: 10px;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}

.support-chat-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;
}

.support-chat-brand > div {
  flex: 1 1 auto;
  min-width: 0;
}

/* The support card carries the same SADA mark as the site header: the
   authentic artwork on a white circle with the accent border. */
.support-chat-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--sada-accent, var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.support-chat-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
  border-radius: 0;
}

.support-chat-logo:hover {
  transform: scale(1.05) rotate(2deg);
}

.support-chat-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.support-chat-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  /* The subtitle is a supporting line, so it yields before anything else:
     it stays on its own two lines at most and never lets a long translation
     push the header taller than the panel can afford. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* ============================================
   CONNECTION STATUS
   ============================================ */
.support-chat-connection {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--muted);
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  transition: all 0.3s ease;
}

.support-chat-connection-text {
  min-width: 0;
  white-space: normal;
  /* The status is a full sentence, and in the longer translations it used to
     wrap to four lines and swallow the panel's message list. Two lines keep
     the header honest; the whole sentence stays in the DOM for assistive
     technology and in the element's title attribute. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.support-chat-connection-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--muted);
  transition: all 0.3s ease;
  position: relative;
  flex-shrink: 0;
}

.support-chat-connection-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  animation: none;
}

.support-chat-connection[data-state="connected"] {
  background: rgba(69, 212, 131, 0.08);
  border-color: rgba(69, 212, 131, 0.2);
}

.support-chat-connection[data-state="connected"] .support-chat-connection-dot {
  background: #45d483;
  box-shadow: 0 0 10px rgba(69, 212, 131, 0.6);
}

.support-chat-connection[data-state="connected"] .support-chat-connection-dot::after {
  animation: connectionPulse 2s ease-in-out infinite;
}

@keyframes connectionPulse {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.5); }
}

.support-chat-connection[data-state="connected"] .support-chat-connection-text {
  color: #45d483;
}

.support-chat-connection[data-state="error"] {
  background: rgba(255, 119, 119, 0.08);
  border-color: rgba(255, 119, 119, 0.2);
}

.support-chat-connection[data-state="error"] .support-chat-connection-dot {
  background: #ff7777;
  box-shadow: 0 0 10px rgba(255, 119, 119, 0.6);
}

.support-chat-connection[data-state="error"] .support-chat-connection-text {
  color: #ff7777;
}

.support-chat-connection[data-state="connecting"] .support-chat-connection-dot {
  background: #e0b36a;
  animation: connectingPulse 1.5s ease-in-out infinite;
}

@keyframes connectingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ============================================
   CLOSE BUTTON
   ============================================ */
.support-chat-close {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  min-height: auto;
  min-width: auto;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 300;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.support-chat-close:hover {
  background: rgba(255, 119, 119, 0.15);
  border-color: rgba(255, 119, 119, 0.3);
  color: #ff7777;
  transform: rotate(90deg);
}

.support-chat-close:active {
  transform: rotate(90deg) scale(0.95);
}

/* ============================================
   MESSAGE HISTORY
   ============================================ */
.support-chat-history {
  flex: 1 1 auto;
  /* The message list is the only part of the panel that may give way. A floor
     here kept the scroll region at 100px on a short phone, which pushed the
     composer and the contact footer past the panel's clipped bottom edge. */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  overflow-wrap: anywhere;
  scroll-behavior: smooth;
  background: 
    radial-gradient(ellipse at top, color-mix(in srgb, var(--support-accent) 2%, transparent) 0%, transparent 50%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.05) 0%, transparent 100%);
}

.support-chat-history::-webkit-scrollbar {
  width: 8px;
}

.support-chat-history::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

.support-chat-history::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--support-accent) 20%, transparent);
  border-radius: 4px;
  transition: background 0.2s ease;
}

.support-chat-history::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--support-accent) 30%, transparent);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.support-chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 28px;
  color: var(--muted);
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.support-chat-empty-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  opacity: 0.5;
  filter: drop-shadow(0 4px 8px color-mix(in srgb, var(--support-accent) 20%, transparent));
}

.support-chat-empty h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.support-chat-empty p {
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.6;
  max-width: 280px;
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */
.support-chat-message {
  width: fit-content;
  max-width: 85%;
  margin: 0 0 14px;
  padding: 12px 16px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px 16px 16px 4px;
  background: rgba(255, 255, 255, 0.05);
  animation: messageSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.support-chat-message.visitor {
  margin-left: auto;
  border-color: var(--support-accent-deep);
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--support-accent) 10%, transparent) 0%, color-mix(in srgb, var(--support-accent-deep) 8%, transparent) 100%);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.support-chat-message p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 0.95rem;
}

.support-chat-message small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 8px;
  font-weight: 500;
  opacity: 0.8;
}

.support-chat-message.visitor small {
  color: var(--support-accent);
  opacity: 0.7;
}

/* ============================================
   FORM AREA
   ============================================ */
.support-chat-form {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px 18px;
  border-top: 1.5px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.25) 100%);
  position: relative;
}

.support-chat-form::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--support-accent) 20%, transparent), transparent);
}

.support-chat-input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.support-chat-name-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted, rgba(255, 255, 255, 0.7));
  margin-bottom: 3px;
  letter-spacing: 0.01em;
}

/* The message field keeps a real label for screen readers and assistive
   technology, but the approved design reads the placeholder instead, so the
   label is removed from the visual flow rather than duplicated on screen. */
.support-chat-form label[for="supportChatBody"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.support-chat-name-input,
.support-chat-message-input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 12px 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 15px var(--font);
  transition: all 0.2s ease;
  line-height: 1.5;
}

.support-chat-name-input {
  min-height: 40px;
  font-size: 0.9rem;
}

.support-chat-name-input:hover,
.support-chat-message-input:hover {
  border-color: color-mix(in srgb, var(--support-accent) 30%, transparent);
  background: rgba(255, 255, 255, 0.06);
}

.support-chat-name-input:focus,
.support-chat-message-input:focus {
  outline: none;
  border-color: var(--support-accent);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 
    0 0 0 3px color-mix(in srgb, var(--support-accent) 15%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.support-chat-message-input {
  resize: vertical;
  max-height: 140px;
  min-height: 64px;
}

.support-chat-message-input::placeholder,
.support-chat-name-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.support-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}

.support-chat-send-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--support-accent) 0%, var(--support-accent-deep) 100%);
  color: var(--support-accent-ink);
  font: 700 0.95rem var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 
    0 4px 12px color-mix(in srgb, var(--support-accent) 35%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}

.support-chat-send-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.support-chat-send-btn:hover:not(:disabled)::before {
  opacity: 1;
}

.support-chat-send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 18px color-mix(in srgb, var(--support-accent) 45%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.support-chat-send-btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.support-chat-send-icon {
  font-size: 1.2rem;
  transition: transform 0.2s ease;
}

.support-chat-send-btn:hover:not(:disabled) .support-chat-send-icon {
  transform: translateX(3px);
}

.support-chat-reconnect-btn,
.support-chat-new-btn {
  flex-shrink: 0;
  min-height: 46px;
  padding: 12px 16px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: 600 0.88rem var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.support-chat-reconnect-btn:hover,
.support-chat-new-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.support-chat-reconnect-btn:active,
.support-chat-new-btn:active {
  transform: translateY(0);
}

.support-chat-refresh-icon {
  font-size: 1.1rem;
  transition: transform 0.3s ease;
}

.support-chat-reconnect-btn:hover .support-chat-refresh-icon {
  transform: rotate(180deg);
}

/* ============================================
   NOTICE / STATUS MESSAGE
   ============================================ */
.support-chat-notice {
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--support-accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--support-accent) 20%, transparent);
  color: var(--support-accent);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  animation: noticeSlideIn 0.25s ease;
}

@keyframes noticeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.support-chat-notice:empty {
  display: none;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .support-chat-launcher {
    font-size: 0.95rem;
  }

  .support-chat-launcher-icon {
    font-size: 1.5rem;
  }

  /* The hero call-to-action row is the one piece of page content that lands
     in the launcher's corner: on a phone it spans the full page width, and on
     a short viewport (an iPhone with the browser bars showing) it sits right
     at the fold, so its second button ran under the disc. The row keeps a
     right-hand reserve the width of the launcher band, which makes the
     already-wrapping flex row drop its second button onto its own line
     instead of disappearing beneath the launcher. */
  .cta-row {
    padding-right: var(--support-launcher-band);
  }

  /* No hover on a touch screen, so the label stays screen-reader only and the
     button keeps its accessible name from its aria-label. */
  .support-chat-launcher-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .support-chat-panel {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    /* The panel is anchored by top + height so it can follow the visual
       viewport when the on-screen keyboard shrinks it. The home-indicator
       band is subtracted as well, so the contact row never sits under the
       iPhone gesture bar. */
    /* On a phone the composer, footer and header together are taller than a
       620px panel can spare, leaving the conversation a ~130px slot. Let the
       panel use the screen it has so the history stays a real reading area.
       The 12px is part of the anchor, not just the cap: a tall phone hit the
       760px cap exactly, so subtracting only the inset left the composer flush
       with the viewport edge and inside the home-indicator band. */
    top: calc(var(--support-top, 0px) + max(12px, var(--support-vh, 100dvh) - 772px - env(safe-area-inset-bottom)));
    bottom: auto;
    width: calc(100vw - 24px);
    height: min(760px, calc(var(--support-vh, 100dvh) - 24px - env(safe-area-inset-bottom)));
    border-radius: 20px;
  }

  .support-chat-header {
    padding: 12px 16px;
  }

  .support-chat-logo {
    width: 40px;
    height: 40px;
  }

  .support-chat-header h2 {
    font-size: 1.1rem;
  }

  .support-chat-subtitle {
    font-size: 0.75rem;
  }

  .support-chat-history {
    padding: 18px;
  }

  .support-chat-message {
    max-width: 90%;
  }

  .support-chat-form {
    padding: 12px 16px 12px;
    gap: 10px;
  }

  .support-chat-name-input {
    min-height: 38px;
  }

  .support-chat-message-input {
    height: 58px;
    min-height: 58px;
  }

  /* The empty state has to fit inside the message list on a phone, where the
     list is now the part that gives way when the panel is short. */
  .support-chat-empty {
    padding: 26px 18px;
  }

  /* The send button keeps the full width as the primary action, but the
     recovery buttons share one row underneath it instead of each taking a
     full row of its own. */
  .support-chat-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .support-chat-send-btn {
    width: 100%;
    flex: 1 1 100%;
  }

  .support-chat-reconnect-btn,
  .support-chat-new-btn {
    width: auto;
    flex: 1 1 auto;
  }

  /* The contact footer is the last thing in the panel, so it is trimmed to
     give the message list room on the smallest phones. */
  .support-chat-footer {
    padding: 10px 16px 12px;
  }

  .support-chat-footer-content {
    gap: 6px;
  }

  .support-chat-footer-label {
    font-size: 0.68rem;
  }

  .support-chat-footer-links {
    gap: 8px;
  }

  .support-chat-footer-link {
    padding: 3px 9px;
    font-size: 0.74rem;
  }

  .support-chat-footer-link span {
    font-size: 0.82rem;
  }
}

/* A phone in landscape leaves very little height. The base sheet tightens the
   padding for that case, so the phone rules above have to tighten it too or
   they would undo it. */
@media (max-width: 768px) and (max-height: 480px) {
  .support-chat-header {
    padding: 10px 14px;
  }

  .support-chat-form {
    padding: 10px 14px;
  }

  .support-chat-footer {
    padding: 8px 14px 10px;
  }

  .support-chat-message-input {
    height: 46px;
    min-height: 46px;
  }
}

/* ============================================
   PRESENCE, READ STATE AND UNREAD BADGE
   ============================================ */
/* The presence line is the customer's answer to "is anyone there?". It sits
   under the support subtitle, uses the same green the connection chip already
   uses for a live link, and clamps to two lines so a long translated name
   cannot push the message list down. */
.support-chat-presence {
  position: relative;
  margin: 5px 0 0;
  padding-left: 13px;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.support-chat-presence::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.42em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.support-chat-presence[data-state="online"] {
  color: #45d483;
}

.support-chat-presence[data-state="online"]::before {
  box-shadow: 0 0 8px rgba(69, 212, 131, 0.65);
}

/* "Seen" is a receipt, not a timestamp: it belongs to the visitor's own
   bubble, in the accent, under the time the message was sent. */
.support-chat-message.visitor small.support-chat-seen {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  color: var(--support-accent);
  opacity: 0.9;
  font-weight: 600;
}

.support-chat-message.visitor small.support-chat-seen::before {
  content: "\2713";
  font-size: 0.82rem;
  line-height: 1;
}

/* The unread count lives on the launcher so a reply that arrives while the
   customer reads the rest of the site is visible before the panel is opened. */
.support-chat-launcher-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--support-accent);
  color: var(--support-accent-ink);
  font: 800 0.72rem/18px var(--font);
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.support-chat-launcher-badge[hidden] {
  display: none;
}

.support-chat-launcher.support-chat-has-unread {
  animation: launcherUnread 2.6s ease-in-out infinite;
}

@keyframes launcherUnread {
  0%, 100% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 0 0 1px color-mix(in srgb, var(--support-accent) 15%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
  50% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 0 0 5px color-mix(in srgb, var(--support-accent) 22%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
}

/* ============================================
   TOASTS (shared notification surface)
   ============================================ */
/* The toast host sits above the launcher and clear of the safe areas. It is
   pointer-transparent so it never blocks the page; each toast re-enables
   pointer events for its own dismiss/action, and stays capped at four. */
.sada-toast-host {
  position: fixed;
  z-index: 300;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(var(--support-launcher-inset, 16px), env(safe-area-inset-bottom)) + var(--support-launcher-size, 56px) + 16px);
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

/* The launcher steps aside while the panel is open, and the panel owns the
   bottom of the screen. A toast anchored above the launcher would therefore
   land on the composer and the contact footer, so while the conversation is
   open the host docks under the panel header instead. The toast still
   announces the outcome; it just can never cover a control.
   app.js measures the live header in viewport coordinates, so the band
   follows the on-screen keyboard, the language and the panel's own offset. */
body.support-chat-open .sada-toast-host {
  top: var(--support-toast-top, 200px);
  bottom: auto;
}

.sada-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(380px, 100%);
  margin-left: auto;
  padding: 12px 14px;
  border: 1.5px solid color-mix(in srgb, var(--support-accent, #D4AF37) 45%, transparent);
  border-radius: 14px;
  background: linear-gradient(135deg, #1a1d1f 0%, #0f1113 100%);
  color: var(--text);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
  line-height: 1.45;
  cursor: pointer;
  animation: sadaToastIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes sadaToastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sada-toast-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.sada-toast-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--support-accent, #D4AF37) 14%, transparent);
  color: var(--support-accent, #D4AF37);
  font-size: 0.88rem;
  line-height: 1;
}

.sada-toast[data-kind="success"] .sada-toast-icon {
  background: rgba(69, 212, 131, 0.12);
  color: #45d483;
}

.sada-toast[data-kind="warning"] .sada-toast-icon {
  background: rgba(224, 179, 106, 0.12);
  color: #e0b36a;
}

.sada-toast[data-kind="error"] .sada-toast-icon {
  background: rgba(255, 119, 119, 0.12);
  color: #ff7777;
}

.sada-toast-body {
  flex: 1 1 auto;
  min-width: 0;
}

.sada-toast-title {
  display: block;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
}

.sada-toast-text {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.sada-toast[data-kind="success"] .sada-toast-title {
  color: #45d483;
}

.sada-toast[data-kind="warning"] .sada-toast-title {
  color: #e0b36a;
}

.sada-toast[data-kind="error"] .sada-toast-title {
  color: #ff7777;
}

.sada-toast-action {
  flex: 0 0 auto;
  align-self: center;
  padding: 7px 12px;
  border: 1px solid var(--support-accent, #D4AF37);
  border-radius: 999px;
  background: color-mix(in srgb, var(--support-accent, #D4AF37) 12%, transparent);
  color: var(--support-accent, #D4AF37);
  font: 700 0.78rem var(--font);
  cursor: pointer;
  white-space: nowrap;
}

/* A phone has no room for a floating column beside the launcher: the host
   spans the width and the toast keeps its action on the same line only while
   there is room for one. */
@media (max-width: 768px) {
  .sada-toast-host {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + var(--support-launcher-size, 56px) + 12px);
    left: max(10px, env(safe-area-inset-left));
  }

  .sada-toast {
    width: 100%;
    flex-wrap: wrap;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .support-chat-launcher,
  .support-chat-launcher.support-chat-has-unread,
  .support-chat-panel,
  .support-chat-logo,
  .support-chat-close,
  .support-chat-message,
  .support-chat-send-btn,
  .support-chat-send-icon,
  .support-chat-reconnect-btn,
  .support-chat-new-btn,
  .support-chat-refresh-icon,
  .sada-toast {
    animation: none;
    transition: none;
  }

  .support-chat-connection-dot::after {
    animation: none;
  }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
  .support-chat-launcher {
    border-width: 2.5px;
  }

  .support-chat-panel {
    border-width: 2px;
  }

  .support-chat-header {
    border-bottom-width: 2px;
  }

  .support-chat-form {
    border-top-width: 2px;
  }

  .support-chat-message {
    border-width: 2px;
  }

  .support-chat-name-input,
  .support-chat-message-input {
    border-width: 2px;
  }
}
