/* DMI Chat Assistant - 0.2.0 design: Samsung-style window, Apple-style
   opening screen, DMI blue/gold. Everything is scoped to #dmi-chat-root so
   the theme's styles and ours never mix. */
#dmi-chat-root {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  --dmi-blue: #2d4490;
  --dmi-gold: #e8bc1b;
  --dmi-ink: #1a1a1a;
  --dmi-muted: #5f6368;
  --dmi-line: #dadce0;
  --dmi-soft: #f1f3f4;
  position: fixed;
  bottom: 20px;
  z-index: 2147483000;
  font-family: "Open Sans", Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--dmi-ink);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#dmi-chat-root.dmi-chat-right { right: 20px; align-items: flex-end; }
#dmi-chat-root.dmi-chat-left { left: 20px; align-items: flex-start; }
#dmi-chat-root *, #dmi-chat-root *::before, #dmi-chat-root *::after { box-sizing: border-box; }
#dmi-chat-root [hidden] { display: none !important; }
#dmi-chat-root button, #dmi-chat-root textarea { font-family: inherit; }
#dmi-chat-root .dmi-chat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- closed: greeting card + "Chat with us" button ---- */
/* Promo ad (0.3.8, design F1): tire banner on top, friendly message and
   quick buttons below. White card with the same gold edge as the button. */
#dmi-chat-root .dmi-chat-greeting {
  position: relative; width: 310px; cursor: pointer; overflow: hidden;
  background: #fff; border: 2px solid var(--dmi-gold); border-radius: 18px;
  box-shadow: 0 14px 32px rgba(20, 30, 60, .2);
  display: flex; flex-direction: column;
  animation: dmi-chat-promo-in .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes dmi-chat-promo-in {
  from { opacity: 0; transform: translateY(16px) scale(.92); }
  to { opacity: 1; transform: none; }
}
#dmi-chat-root .dmi-chat-promo-banner {
  position: relative; height: 118px; overflow: hidden; background: var(--dmi-blue);
  display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 0 20px;
}
#dmi-chat-root .dmi-chat-promo-tire { position: absolute; right: -38px; top: -16px; display: block; }
#dmi-chat-root .dmi-chat-promo-banner span { position: relative; font-weight: 800; }
#dmi-chat-root .dmi-chat-promo-kicker { font-size: 11px; letter-spacing: 1.4px; color: var(--dmi-gold); line-height: 1.3; }
#dmi-chat-root .dmi-chat-promo-l1 { font-size: 24px; line-height: 1.15; color: #fff; }
#dmi-chat-root .dmi-chat-promo-l2 { font-size: 24px; line-height: 1.15; color: var(--dmi-gold); }
#dmi-chat-root .dmi-chat-promo-body { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
#dmi-chat-root .dmi-chat-promo-who { display: flex; align-items: center; gap: 10px; }
#dmi-chat-root .dmi-chat-promo-who strong { display: block; font-size: 14px; line-height: 1.3; color: var(--dmi-ink); }
#dmi-chat-root .dmi-chat-promo-who small { display: block; font-size: 12px; line-height: 1.3; color: var(--dmi-muted); }
#dmi-chat-root .dmi-chat-promo-avatar {
  position: relative; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  background: var(--dmi-blue); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center;
}
#dmi-chat-root .dmi-chat-promo-avatar i {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  background: #1e8e3e; border: 2px solid #fff;
}
#dmi-chat-root .dmi-chat-promo-hello { margin: 0; font-size: 15px; line-height: 1.5; color: var(--dmi-ink); }
#dmi-chat-root .dmi-chat-promo-chips { display: flex; flex-wrap: wrap; gap: 8px; }
#dmi-chat-root .dmi-chat-chip {
  height: 38px; margin: 0; padding: 0 14px; border-radius: 19px; cursor: pointer;
  border: 2px solid var(--dmi-gold); background: #fff; color: var(--dmi-blue);
  font-size: 13px; font-weight: 700; line-height: 1;
}
#dmi-chat-root .dmi-chat-chip:hover { background: #fdf6dc; }
#dmi-chat-root .dmi-chat-chip.is-main { background: var(--dmi-gold); color: var(--dmi-ink); font-weight: 800; }
#dmi-chat-root .dmi-chat-chip.is-main:hover { filter: brightness(1.05); }
#dmi-chat-root .dmi-chat-greeting-x {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; margin: 0; padding: 0; background: rgba(255, 255, 255, .92); color: var(--dmi-ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#dmi-chat-root .dmi-chat-greeting-x:hover { background: #fff; }
#dmi-chat-root .dmi-chat-launcher {
  display: flex; align-items: center; gap: 8px; height: 56px; margin: 0;
  border-radius: 28px; border: 2px solid var(--dmi-gold); background: #fff;
  padding: 0 22px 0 18px; cursor: pointer; color: var(--dmi-blue);
  font-weight: 700; font-size: 15px; line-height: 1;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .16);
  transition: transform .15s ease, box-shadow .15s ease;
}
#dmi-chat-root .dmi-chat-launcher:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(0, 0, 0, .2); }
#dmi-chat-root .dmi-chat-launcher:focus-visible,
#dmi-chat-root button:focus-visible,
#dmi-chat-root a:focus-visible { outline: 3px solid var(--dmi-gold); outline-offset: 2px; }

/* ---- the window ---- */
#dmi-chat-root .dmi-chat-panel {
  width: 400px; height: 640px; max-height: calc(100vh - 40px);
  background: #fff; border-radius: 20px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .2);
  animation: dmi-chat-in .2s ease-out;
}
@keyframes dmi-chat-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#dmi-chat-root .dmi-chat-header {
  background: var(--dmi-blue); color: #fff; padding: 12px 8px 12px 16px;
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; position: relative;
}
#dmi-chat-root.is-chat .dmi-chat-header { padding-left: 6px; }
#dmi-chat-root .dmi-chat-logo { height: 34px; width: auto; display: block; flex-shrink: 0; }
#dmi-chat-root .dmi-chat-titles {
  flex: 1; min-width: 0; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .35); line-height: 1.25;
}
#dmi-chat-root .dmi-chat-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dmi-chat-root .dmi-chat-subtitle { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dmi-chat-root .dmi-chat-subtitle:empty { display: none; }
#dmi-chat-root .dmi-chat-testbar {
  background: var(--dmi-gold); color: #1a1a1a; font-size: 11px; font-weight: 700;
  text-align: center; padding: 3px 8px; flex-shrink: 0;
}
#dmi-chat-root .dmi-chat-icon-btn {
  width: 36px; height: 36px; border: 0; margin: 0; padding: 0; border-radius: 50%;
  background: transparent; color: #fff; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
#dmi-chat-root .dmi-chat-icon-btn:hover { background: rgba(255, 255, 255, .14); }
#dmi-chat-root .dmi-chat-menu-wrap { position: relative; }
#dmi-chat-root .dmi-chat-menu {
  position: absolute; right: 0; top: 40px; background: #fff; border-radius: 10px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); z-index: 2; min-width: 190px;
}
#dmi-chat-root .dmi-chat-menu button {
  display: block; width: 100%; text-align: left; border: 0; margin: 0; background: transparent;
  color: var(--dmi-ink); font-size: 14px; padding: 10px 12px; border-radius: 6px; cursor: pointer;
}
#dmi-chat-root .dmi-chat-menu button:hover { background: var(--dmi-soft); }

/* ---- opening screen ---- */
#dmi-chat-root .dmi-chat-start {
  flex: 1; overflow-y: auto; padding: 26px 22px 14px; display: flex; flex-direction: column; gap: 12px;
}
#dmi-chat-root.is-chat .dmi-chat-start { display: none; }
#dmi-chat-root .dmi-chat-start h2 {
  margin: 0 0 6px; font-size: 21px; font-weight: 700; line-height: 1.3; text-align: center; color: var(--dmi-ink);
  font-family: inherit; letter-spacing: 0; text-transform: none;
}
#dmi-chat-root .dmi-chat-option {
  display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center;
  background: #fff; border: 1px solid var(--dmi-line); border-radius: 14px; padding: 16px; margin: 0;
  color: var(--dmi-ink); text-decoration: none; cursor: pointer; font-size: 14px; line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#dmi-chat-root .dmi-chat-option:hover { border-color: var(--dmi-blue); box-shadow: 0 4px 14px rgba(45, 68, 144, .12); }
#dmi-chat-root .dmi-chat-option svg { color: var(--dmi-blue); }
#dmi-chat-root .dmi-chat-option strong { font-size: 15px; font-weight: 700; }
#dmi-chat-root .dmi-chat-option span { font-size: 13px; color: var(--dmi-muted); }
#dmi-chat-root .dmi-chat-option em { font-style: normal; font-size: 12px; font-weight: 600; color: #8a2215; }
#dmi-chat-root .dmi-chat-recorded { margin: auto 0 0; padding-top: 10px; font-size: 11px; color: var(--dmi-muted); text-align: center; }

/* ---- conversation ---- */
#dmi-chat-root .dmi-chat-conversation { flex: 1; min-height: 0; display: none; flex-direction: column; }
#dmi-chat-root.is-chat .dmi-chat-conversation { display: flex; }
#dmi-chat-root .dmi-chat-messages {
  flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: #c4c7cc transparent; overscroll-behavior: contain;
}
#dmi-chat-root .dmi-chat-day { align-self: center; font-size: 11px; color: var(--dmi-muted); }
#dmi-chat-root .dmi-chat-row { display: flex; gap: 8px; align-items: flex-start; }
#dmi-chat-root .dmi-chat-row.dmi-chat-visitor { justify-content: flex-end; }
#dmi-chat-root .dmi-chat-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--dmi-blue); color: var(--dmi-gold);
  font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#dmi-chat-root .dmi-chat-col { display: flex; flex-direction: column; gap: 8px; max-width: 84%; min-width: 0; }
#dmi-chat-root .dmi-chat-msg {
  padding: 10px 12px; border-radius: 16px 16px 16px 4px; background: var(--dmi-soft);
  word-wrap: break-word; overflow-wrap: anywhere; font-size: 14px;
}
#dmi-chat-root .dmi-chat-visitor .dmi-chat-msg { background: var(--dmi-blue); color: #fff; border-radius: 16px 16px 4px 16px; }
#dmi-chat-root .dmi-chat-msg a { color: var(--dmi-blue); text-decoration: underline; }
#dmi-chat-root .dmi-chat-visitor .dmi-chat-msg a { color: #fff; }
#dmi-chat-root .dmi-chat-dot {
  display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%;
  background: #9aa0a6; animation: dmi-chat-blink 1.2s infinite ease-in-out;
}
#dmi-chat-root .dmi-chat-dot:nth-child(2) { animation-delay: .2s; }
#dmi-chat-root .dmi-chat-dot:nth-child(3) { animation-delay: .4s; }
@keyframes dmi-chat-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ---- live chat: team member, "joined the chat" ---- */
#dmi-chat-root .dmi-chat-avatar-agent { background: var(--dmi-gold); color: #1f3170; font-size: 12px; }
#dmi-chat-root .dmi-chat-agent .dmi-chat-msg { background: #fff6d6; }
#dmi-chat-root .dmi-chat-name { font-size: 11px; font-weight: 600; color: var(--dmi-muted); margin-bottom: -4px; }
#dmi-chat-root .dmi-chat-system {
  align-self: center; display: flex; align-items: center; gap: 10px; width: 100%;
  font-size: 12px; font-weight: 600; color: var(--dmi-muted); text-align: center;
}
#dmi-chat-root .dmi-chat-system::before,
#dmi-chat-root .dmi-chat-system::after { content: ""; flex: 1; height: 1px; background: #e3e5e8; }
#dmi-chat-root.is-human .dmi-chat-subtitle::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #5ee08a; margin-right: 5px; vertical-align: 1px;
}
#dmi-chat-root .dmi-chat-launcher { position: relative; }
/* A gentle gold pulse while the promo card is showing. */
#dmi-chat-root .dmi-chat-launcher.is-new { animation: dmi-chat-glow 2.4s ease-in-out 3; }
@keyframes dmi-chat-glow {
  0%, 100% { box-shadow: 0 10px 26px rgba(0, 0, 0, .16), 0 0 0 0 rgba(232, 188, 27, .55); }
  50% { box-shadow: 0 10px 26px rgba(0, 0, 0, .16), 0 0 0 10px rgba(232, 188, 27, 0); }
}
#dmi-chat-root .dmi-chat-launcher.has-unread::after {
  content: ""; position: absolute; top: 6px; right: 10px; width: 12px; height: 12px; border-radius: 50%;
  background: #d93025; border: 2px solid #fff;
}

#dmi-chat-root .dmi-chat-waiting {
  align-self: center; display: flex; align-items: center; gap: 8px; margin: 2px 0 4px;
  font-size: 12px; font-weight: 600; color: var(--dmi-muted);
}
#dmi-chat-root .dmi-chat-waiting-dots { display: inline-flex; gap: 3px; }
#dmi-chat-root .dmi-chat-waiting-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--dmi-blue);
  animation: dmi-chat-blink 1.2s infinite ease-in-out;
}
#dmi-chat-root .dmi-chat-waiting-dots i:nth-child(2) { animation-delay: .2s; }
#dmi-chat-root .dmi-chat-waiting-dots i:nth-child(3) { animation-delay: .4s; }

/* ---- product cards ---- */
#dmi-chat-root .dmi-chat-card { background: #fff; border: 1px solid var(--dmi-line); border-radius: 14px; overflow: hidden; }
#dmi-chat-root .dmi-chat-card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
#dmi-chat-root .dmi-chat-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
#dmi-chat-root .dmi-chat-card-pn { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
#dmi-chat-root .dmi-chat-card-price { font-size: 15px; font-weight: 700; white-space: nowrap; }
#dmi-chat-root .dmi-chat-card-price small { font-size: 12px; font-weight: 400; color: var(--dmi-muted); }
#dmi-chat-root .dmi-chat-card-spec { font-size: 12px; color: var(--dmi-muted); }
#dmi-chat-root .dmi-chat-card-stock { font-size: 12px; font-weight: 600; color: var(--dmi-muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
#dmi-chat-root .dmi-chat-card-stock::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9aa0a6; }
#dmi-chat-root .dmi-chat-card-stock.is-in { color: #137333; }
#dmi-chat-root .dmi-chat-card-stock.is-in::before { background: #1e8e3e; }
#dmi-chat-root .dmi-chat-card-actions { display: flex; border-top: 1px solid #eceef1; }
#dmi-chat-root .dmi-chat-card-actions a,
#dmi-chat-root .dmi-chat-card-actions button {
  flex: 1; display: flex; align-items: center; justify-content: center; min-height: 42px;
  padding: 0 10px; margin: 0; font-size: 13px; font-weight: 700; line-height: 1.2;
  color: var(--dmi-blue); text-decoration: none; background: transparent; border: 0; border-radius: 0; cursor: pointer;
}
#dmi-chat-root .dmi-chat-card-actions > * + * { border-left: 1px solid #eceef1; }
#dmi-chat-root .dmi-chat-card-actions a:hover,
#dmi-chat-root .dmi-chat-card-actions button:hover { background: #f5f7fb; }

/* ---- typing box ---- */
#dmi-chat-root .dmi-chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 8px 14px 6px; margin: 0; }
#dmi-chat-root .dmi-chat-form textarea {
  /* 16px: iPhones zoom into any text box smaller than that (Andres, iPhone, 20 Oct).
     Height set here so the theme's own textarea size (it made the box ~120px tall) never applies. */
  flex: 1; min-width: 0; resize: none; margin: 0; font-size: 16px; line-height: 20px; color: var(--dmi-ink);
  border: 1.5px solid #80868b; border-radius: 22px; padding: 11px 16px; background: #fff;
  height: 44px; min-height: 44px; max-height: 120px; box-shadow: none; overflow-y: hidden;
  -webkit-appearance: none; appearance: none; display: block; width: auto;
}
#dmi-chat-root .dmi-chat-form textarea:focus { outline: none; border-color: var(--dmi-blue); }
#dmi-chat-root .dmi-chat-send {
  width: 44px; height: 44px; border-radius: 50%; border: 0; margin: 0; padding: 0; flex-shrink: 0;
  background: var(--dmi-blue); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#dmi-chat-root .dmi-chat-send:disabled { opacity: .5; cursor: default; }
#dmi-chat-root .dmi-chat-footer { padding: 2px 18px 12px; font-size: 11px; color: var(--dmi-muted); text-align: center; }

/* ---- phones: the window takes the whole screen ---- */
/* 0.3.9: while the chat is open on a phone the page behind it stays still. */
html.dmi-chat-lock, html.dmi-chat-lock body { overflow: hidden !important; overscroll-behavior: none; }
@media (max-width: 520px) {
  #dmi-chat-root.dmi-chat-right { right: 16px; }
  #dmi-chat-root.dmi-chat-left { left: 16px; }
  #dmi-chat-root .dmi-chat-panel {
    position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh; max-height: none; border-radius: 0;
  }
  #dmi-chat-root .dmi-chat-greeting { width: min(310px, calc(100vw - 32px)); }
  #dmi-chat-root .dmi-chat-logo { height: 24px; }
  #dmi-chat-root .dmi-chat-header { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  #dmi-chat-root * { animation: none !important; transition: none !important; }
}
