/* Donki Support Tickets — Cosmiyo-like: one dock, no overlap with ATC */

.dst-fab,
.dst-sticky-ticket,
.dst-cart-ticket {
  font-family: inherit;
  box-sizing: border-box;
}

/* Fallback FAB: icon + label (only when .global-contact-icons missing) */
.dst-fab {
  position: fixed;
  right: 16px;
  left: auto;
  bottom: max(24px, env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 99980;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  min-width: 48px;
  min-height: 48px;
  padding: 0 16px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: #1a2332;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  animation: dst-fab-in 0.45s ease both;
}

@keyframes dst-fab-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dst-fab[hidden] {
  display: none !important;
}

.dst-fab:hover {
  transform: translateY(-2px);
  background: #243044;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.34);
}

.dst-fab:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
}

.dst-fab.dst-fab--unread {
  background: #1f2937;
  border-color: rgba(239, 68, 68, 0.55);
  animation: dst-fab-in 0.45s ease both, dst-fab-pulse 1.6s ease 0.5s 2;
}

@keyframes dst-fab-pulse {
  0%,
  100% {
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.28);
  }
  50% {
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.28), 0 0 0 6px rgba(239, 68, 68, 0.18);
  }
}

.dst-fab svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

.dst-fab__label {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  overflow: visible;
  clip: auto;
  white-space: nowrap;
  border: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1;
}

.dst-fab__badge,
.dst-contact-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

.dst-fab__badge[hidden],
.dst-contact-badge[hidden] {
  display: none !important;
}

/* Lift fallback FAB above typical mobile ATC / floating cart */
@media (max-width: 768px) {
  body.single-product .dst-fab,
  body.dst-near-atc .dst-fab {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 12px);
  }

  body.has-floating-cart .dst-fab {
    bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  }
}

/* Product form: no Ticket beside ATC — keep only bottom-right chat bubble.
   Old cached JS may still create these nodes; hide them defensively. */
.dst-cart-ticket {
  display: none !important;
}

.dst-cart-actions {
  display: contents;
}

/* Legacy sticky bar removed — do not reserve page padding */
.dst-sticky-bar {
  display: none !important;
}

/* Modal — MUST respect [hidden] */
.dst-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(12, 12, 12, 0.45);
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.dst-overlay[hidden] {
  display: none !important;
}

.dst-overlay:not([hidden]) {
  display: flex;
}

@media (min-width: 640px) {
  .dst-overlay:not([hidden]) {
    align-items: center;
    padding: 24px;
  }
}

.dst-modal {
  width: min(440px, 100%);
  max-height: min(92vh, 720px);
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #1a1a1a;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

@media (min-width: 640px) {
  .dst-modal {
    border-radius: 16px;
  }
}

.dst-modal__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}

.dst-modal__head h2,
.dst-modal #dst-title {
  margin: 0;
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a !important;
  background: transparent !important;
}

.dst-modal__head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.dst-open-page {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155 !important;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  padding: 6px 10px;
  border-radius: 999px;
  text-decoration: none !important;
  white-space: nowrap;
  cursor: pointer;
}

.dst-open-page::after {
  content: "↗";
  font-size: 11px;
  opacity: 0.75;
}

.dst-open-page:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a !important;
}

.dst-icon-btn {
  border: 0;
  background: transparent;
  color: #444;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.dst-icon-btn:hover {
  background: #eee;
}

.dst-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  min-height: 220px;
}

.dst-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 4px;
  color: #444;
}

.dst-form input,
.dst-form select,
.dst-form textarea,
.dst-compose input {
  width: 100%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #ddd !important;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  box-sizing: border-box;
  background: #fff !important;
  color: #1a1a1a !important;
}

.dst-form textarea {
  min-height: 96px;
  resize: vertical;
}

.dst-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #1a1a1a;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.dst-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dst-btn--ghost {
  background: transparent;
  color: #1a1a1a;
  border: 1px solid #ccc;
  margin-top: 8px;
}

.dst-err {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff1f0;
  color: #a33;
  font-size: 13px;
}

.dst-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: #666;
}

.dst-context {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4f6f8;
  color: #334155;
  font-size: 13px;
  line-height: 1.4;
}

.dst-context strong {
  color: #0f172a;
  font-weight: 650;
}

.dst-order-wrap {
  margin: 0 0 4px;
}

.dst-order-wrap[hidden] {
  display: none !important;
}

.dst-order-wrap .dst-hint {
  margin-top: -6px;
}

.dst-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dst-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.dst-bubble--customer {
  align-self: flex-end;
  background: #1a1a1a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.dst-bubble--pending {
  opacity: 0.72;
}

.dst-bubble--failed {
  background: #7f1d1d !important;
  box-shadow: inset 0 0 0 1px rgba(254, 202, 202, 0.35);
  cursor: pointer;
}

.dst-bubble--failed .dst-bubble__meta {
  opacity: 0.95;
  text-decoration: underline;
}

.dst-bubble--merchant,
.dst-bubble--system {
  align-self: flex-start;
  background: #f3f3f3;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

.dst-bubble--system {
  background: #f0f4f8;
  font-size: 13px;
}

.dst-bubble__meta {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.65;
}

.dst-compose {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  background: #fff;
}

.dst-compose input {
  flex: 1;
  width: auto;
  height: 42px;
  margin-bottom: 0;
  padding: 0 12px;
}

.dst-compose[hidden] {
  display: none !important;
}

.dst-typing[hidden] {
  display: none !important;
}

.dst-compose button {
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: #1a1a1a;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.dst-compose button:disabled {
  opacity: 0.5;
}

.dst-typing {
  font-size: 12px;
  color: #888;
  padding: 0 16px 8px;
}

/*
 * Primary entry: top of Donki .global-contact-icons
 * Match existing contact-icon look; unread lives here — no second FAB.
 */
.global-contact-icons .dst-contact-ticket {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  margin: 0;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid color-mix(in srgb, var(--color-primary, #9b59b6) 38%, var(--color-border, #2a2a4a) 62%);
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--color-surface, #1a1a2e) 88%, #ffffff 12%) 0%,
    var(--color-bg-alt, #111122) 100%
  );
  color: var(--color-text-heading, #ffffff);
  cursor: pointer;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  line-height: 1;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.global-contact-icons .dst-contact-ticket:hover {
  transform: translateY(-3px) scale(1.06);
  border-color: color-mix(in srgb, var(--color-primary-light, #bb77d6) 60%, var(--color-border, #2a2a4a) 40%);
}

.global-contact-icons .dst-contact-ticket svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
}

.global-contact-icons .dst-contact-ticket.dst-contact-ticket--unread {
  border-color: #ef4444;
}

@media (max-width: 768px) {
  .global-contact-icons .dst-contact-ticket {
    width: 40px;
    height: 40px;
  }

  .global-contact-icons .dst-contact-ticket svg {
    width: 20px;
    height: 20px;
  }

  /* Keep contact dock above mobile ATC strip */
  body.single-product .global-contact-icons {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
