/* Durgesh Group AI widgets.
 *
 * Scoped under .dg- so nothing here can collide with Elementor, the matico
 * theme, or the 140 stylesheets already on the page. Everything animates on
 * transform/opacity only -- the homepage is already carrying 15.8 MB and
 * 7,186 DOM nodes, so this must not cost frames.
 */

.dg-root {
  --dg-ink: #444444;           /* the shop's own body text colour */
  --dg-muted: #6b6f76;
  --dg-line: #e5e3de;
  --dg-surface: #ffffff;
  --dg-soft: #f7f5f1;
  /* Defaults measured from sabsespecial.com. adoptHostTheme() overrides these
   * at runtime with whatever the host page actually uses, so the widget matches
   * each of the four sites without anyone editing this file. */
  --dg-brand: #E57C41;         /* the orange the shop already uses on buy buttons and prices */
  --dg-brand-ink: #C25F28;
  --dg-ok: #1d6b45;
  --dg-radius: 4px;            /* matches the theme's buttons */
  --dg-shadow: 0 1px 2px rgba(20,20,25,.06), 0 12px 32px -14px rgba(20,20,25,.22);

  font-family: inherit;
  color: var(--dg-ink);
  font-size: 15px;
  line-height: 1.55;
  box-sizing: border-box;
}
.dg-root *, .dg-root *::before, .dg-root *::after { box-sizing: inherit; }

/* --- launcher ------------------------------------------------------------ */
.dg-launcher {
  position: fixed; right: 18px; z-index: 9998;
  /* Clears the host theme's own fixed bottom bar, measured at runtime by
   * gift-finder.js. Falls back to 0 if there is no bar or the measurement
   * cannot run. */
  bottom: calc(18px + var(--dg-launcher-inset, 0px));
  display: inline-flex; align-items: center; gap: 9px;
  padding: 0 18px; min-height: 48px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--dg-brand); color: #fff;
  font: inherit; font-weight: 600; font-size: 14px;
  box-shadow: var(--dg-shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.dg-launcher:hover { transform: translateY(-2px); }
.dg-launcher:focus-visible { outline: 3px solid var(--dg-brand-ink); outline-offset: 3px; }
/* Joinchat's WhatsApp button owns the bottom-right corner. Sit above it. */
@media (max-width: 480px) {
  .dg-launcher { right: 12px; bottom: calc(12px + var(--dg-launcher-inset, 0px)); padding: 0 16px; }
}

/* --- panel --------------------------------------------------------------- */
.dg-panel {
  position: fixed; right: 18px; z-index: 9999;
  /* The panel is a dialog and sits above the shop's own chat button, so it may
   * cover it. It only has to clear the full-width navigation bar. */
  bottom: calc(18px + var(--dg-bottom-inset, 0px));
  width: min(400px, calc(100vw - 24px));
  max-height: min(640px, calc(100vh - 36px - var(--dg-bottom-inset, 0px)));
  display: flex; flex-direction: column;
  background: var(--dg-surface); border: 1px solid var(--dg-line);
  border-radius: var(--dg-radius); box-shadow: var(--dg-shadow);
  overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(.98);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}
.dg-panel[data-open="true"] { opacity: 1; transform: none; pointer-events: auto; }
@media (max-width: 480px) {
  .dg-panel {
    right: 8px; left: 8px; width: auto;
    bottom: calc(8px + var(--dg-bottom-inset, 0px));
    max-height: calc(100vh - 16px - var(--dg-bottom-inset, 0px));
  }
}

.dg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--dg-line); background: var(--dg-soft);
}
.dg-title { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.dg-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--dg-muted); }
.dg-close {
  border: 0; background: transparent; cursor: pointer; border-radius: 6px;
  font-size: 22px; line-height: 1; color: var(--dg-muted);
  /* 44px minimum -- the audit found 56% of this site's tap targets below it. */
  min-width: 46px; min-height: 46px; display: inline-flex;
  align-items: center; justify-content: center;
}
.dg-close:hover { background: rgba(0,0,0,.06); color: var(--dg-ink); }
.dg-close:focus-visible { outline: 2px solid var(--dg-brand); outline-offset: 1px; }

.dg-body { flex: 1; overflow-y: auto; padding: 16px; overscroll-behavior: contain; }
.dg-foot { border-top: 1px solid var(--dg-line); padding: 12px; background: var(--dg-surface); }

/* --- chat ---------------------------------------------------------------- */
.dg-msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; margin-bottom: 10px; font-size: 14.5px; }
.dg-msg--bot { background: var(--dg-soft); border-bottom-left-radius: 4px; }
.dg-msg--user { background: var(--dg-brand); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }

.dg-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.dg-chip {
  border: 1px solid var(--dg-line); background: var(--dg-surface); color: var(--dg-ink);
  border-radius: 999px; padding: 0 15px; font: inherit; font-size: 13.5px; cursor: pointer;
  min-height: 46px; display: inline-flex; align-items: center;
  transition: border-color .15s ease, transform .15s ease;
}
.dg-chip:hover { border-color: var(--dg-brand); transform: translateY(-1px); }
.dg-chip:focus-visible { outline: 2px solid var(--dg-brand); outline-offset: 2px; }
.dg-chip[aria-pressed="true"] { background: var(--dg-brand); color: #fff; border-color: var(--dg-brand); }

/* --- products ------------------------------------------------------------ */
.dg-products { display: grid; gap: 9px; margin: 4px 0 12px; }
.dg-card {
  display: grid; grid-template-columns: 62px 1fr; gap: 11px; align-items: center;
  padding: 9px; border: 1px solid var(--dg-line); border-radius: 9px;
  text-decoration: none; color: inherit; background: var(--dg-surface);
  transition: border-color .15s ease, transform .15s ease;
}
.dg-card:hover { border-color: var(--dg-brand); transform: translateY(-1px); }
.dg-card:focus-visible { outline: 2px solid var(--dg-brand); outline-offset: 2px; }
.dg-card img { width: 62px; height: 62px; object-fit: cover; border-radius: 6px; display: block; background: var(--dg-soft); }
.dg-card-name { font-size: 13.4px; font-weight: 600; line-height: 1.3; margin: 0 0 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dg-card-why { font-size: 12px; color: var(--dg-muted); margin: 0 0 3px; }
.dg-card-price { font-size: 13.5px; font-weight: 700; color: var(--dg-brand-ink); margin: 0; }

/* --- form ---------------------------------------------------------------- */
.dg-field { margin-bottom: 14px; }
.dg-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.dg-hint { font-size: 12.5px; color: var(--dg-muted); margin: 0 0 8px; }
.dg-input {
  /* Must be >= 16px: iOS Safari zooms the whole page on focus below that. */
  width: 100%; padding: 11px 12px; font: inherit; font-size: 16px;
  border: 1px solid var(--dg-line); border-radius: 8px; background: var(--dg-surface); color: var(--dg-ink);
}
.dg-input:focus { outline: 2px solid var(--dg-brand); outline-offset: 0; border-color: var(--dg-brand); }

.dg-btn {
  width: 100%; padding: 12px 16px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--dg-brand); color: #fff; font: inherit; font-weight: 650; font-size: 15px;
  transition: opacity .15s ease;
}
.dg-btn:hover { opacity: .92; }
.dg-btn:disabled { opacity: .5; cursor: not-allowed; }
.dg-btn:focus-visible { outline: 3px solid var(--dg-brand-ink); outline-offset: 2px; }
.dg-btn--ghost { background: transparent; color: var(--dg-muted); border: 1px solid var(--dg-line); font-weight: 500; }

.dg-progress { display: flex; gap: 4px; margin-bottom: 16px; }
.dg-progress span { height: 3px; flex: 1; border-radius: 2px; background: var(--dg-line); }
.dg-progress span[data-done="true"] { background: var(--dg-brand); }

/* --- quote --------------------------------------------------------------- */
.dg-tier { border: 1px solid var(--dg-line); border-radius: 9px; padding: 13px; margin-bottom: 11px; }
.dg-tier-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 9px; }
.dg-tier-name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--dg-brand-ink); }
.dg-tier-price { font-size: 14px; font-weight: 700; }
.dg-note { font-size: 12.5px; color: var(--dg-muted); padding: 10px; background: var(--dg-soft); border-radius: 7px; }

/* --- states -------------------------------------------------------------- */
.dg-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.dg-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dg-muted); animation: dg-bounce 1.2s infinite; }
.dg-typing i:nth-child(2) { animation-delay: .15s; }
.dg-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dg-bounce { 0%,60%,100% { transform: translateY(0); opacity:.4 } 30% { transform: translateY(-4px); opacity:1 } }
.dg-error { font-size: 13.5px; color: #a3231a; background: #fbeceb; padding: 10px 12px; border-radius: 7px; }
.dg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Motion is decoration here. Turn all of it off when asked. */
@media (prefers-reduced-motion: reduce) {
  .dg-root *, .dg-panel { transition: none !important; animation: none !important; }
  .dg-panel { transform: none !important; }
}

/* --- combo builder ------------------------------------------------------- */
/* Layout only. Colours come from the tokens above, which adoptHostTheme()
 * overwrites with the shop's own at runtime, and the buy button and prices
 * reuse WooCommerce's own classes so they inherit the theme directly. */

.dg-combo { display: flex; flex-direction: column; gap: 16px; }
.dg-combo-panel {
  border: 1px solid var(--dg-line); border-radius: var(--dg-radius);
  padding: 16px; background: var(--dg-surface);
}
.dg-combo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.dg-combo-panel .dg-title { margin: 0 0 4px; }
.dg-combo-panel .dg-hint { margin: 0 0 12px; }

.dg-combo-card { grid-template-columns: 62px 1fr auto; align-items: center; }
.dg-combo-card .dg-card-why { text-transform: capitalize; }
.dg-combo-action { min-height: 40px; padding: 0 13px; white-space: nowrap; }

.dg-combo-line {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--dg-line);
}
.dg-combo-line:last-of-type { border-bottom: none; padding-top: 11px; }
.dg-combo-total { position: sticky; bottom: 8px; box-shadow: var(--dg-shadow); }

/* The buy button reuses the theme's own classes; this only guarantees it is
   full width and reachable by thumb if the theme has no opinion. */
/* The CTA carries the shop's own button classes so it inherits the theme on
   sabsespecial.com. Off-site those classes do not exist, so .dg-btn underneath
   guarantees it still looks like a button rather than unstyled grey. */
.dg-combo-cta {
  width: 100%; margin-top: 14px; min-height: 48px; cursor: pointer;
  border: 0; border-radius: var(--dg-radius);
}

.dg-combo textarea.dg-input { resize: vertical; min-height: 72px; font-family: inherit; }

@media (max-width: 480px) {
  .dg-combo-card { grid-template-columns: 52px 1fr; }
  .dg-combo-card .dg-combo-action { grid-column: 2; justify-self: start; margin-top: 4px; }
}

/* --- voice --------------------------------------------------------------- */
/* The button only exists where the browser supports speech recognition, so
   there is no dead control on Firefox. */

.dg-voice { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }

.dg-mic {
  min-width: 46px; min-height: 46px; border-radius: 50%;
  border: 1px solid var(--dg-line); background: var(--dg-surface);
  font-size: 19px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, transform .15s ease;
}
.dg-mic:hover { border-color: var(--dg-brand); }
.dg-mic:focus-visible { outline: 2px solid var(--dg-brand); outline-offset: 2px; }

/* Listening: a calm pulse, not an alarm. */
.dg-mic--on {
  border-color: var(--dg-brand); background: var(--dg-brand); color: #fff;
  animation: dg-listen 1.6s ease-in-out infinite;
}
@keyframes dg-listen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,0,0,.18); }
  50%      { box-shadow: 0 0 0 7px rgba(0,0,0,0); }
}

.dg-voice-langs { display: flex; gap: 6px; }
.dg-lang {
  border: 1px solid var(--dg-line); background: var(--dg-surface); color: var(--dg-muted);
  border-radius: 999px; padding: 0 12px; min-height: 34px; font: inherit; font-size: 12.5px;
  cursor: pointer;
}
.dg-lang[aria-pressed="true"] {
  background: var(--dg-brand); color: #fff; border-color: var(--dg-brand);
}
.dg-lang:focus-visible { outline: 2px solid var(--dg-brand); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .dg-mic--on { animation: none; }
}

/* --- gift finder handing over to the combo builder ------------------------ */
.dg-combo-offer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 11px 13px; margin: 2px 0 12px;
  border: 1px dashed var(--dg-line-strong, var(--dg-line)); border-radius: var(--dg-radius);
  background: var(--dg-soft);
}
.dg-combo-offer .dg-card-why { margin: 0; flex: 1 1 auto; }
.dg-combo-offer-btn { white-space: nowrap; }

/* --- recovering from a failure ------------------------------------------
 * An error with no way forward sends the shopper away. These two give them
 * somewhere to go: retry the thing that failed, or clear and start again.
 * Both stay inside the shop's own palette -- no new colours are introduced.
 */
.dg-head-actions { display: flex; align-items: center; gap: 2px; }
.dg-reset {
  border: 1px solid var(--dg-line); background: var(--dg-surface); cursor: pointer;
  border-radius: var(--dg-radius); color: var(--dg-muted);
  font: inherit; font-size: 12.5px; padding: 0 10px;
  min-height: 32px; display: inline-flex; align-items: center; white-space: nowrap;
}
.dg-reset:hover { border-color: var(--dg-brand); color: var(--dg-brand-ink); }
.dg-reset:focus-visible { outline: 2px solid var(--dg-brand); outline-offset: 2px; }

.dg-retry {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 10px; cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--dg-brand); border-radius: var(--dg-radius);
  background: var(--dg-brand); color: #fff;
  /* the same 46px floor the rest of the widget keeps */
  min-height: 46px; padding: 0 18px;
}
.dg-retry:hover { background: var(--dg-brand-ink); border-color: var(--dg-brand-ink); }
.dg-retry:focus-visible { outline: 2px solid var(--dg-brand); outline-offset: 2px; }
.dg-error .dg-retry { display: block; margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  .dg-retry, .dg-reset { transition: none; }
}

/* --- the guided menu -----------------------------------------------------
 *
 * Four groups of chips, each collapsed to one or two rows so the panel opens
 * short on a phone. The old opening screen was four hard-coded suggestions;
 * this one is built from live stock, so it is longer and needs the structure.
 */
.dg-menu { display: grid; gap: 14px; margin: 2px 0 10px; }
.dg-menu-group { display: grid; gap: 7px; }
.dg-menu-label {
  margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--dg-muted);
}
/* Every menu chip carries the shop's colour: brand border, brand dot, medium
 * weight. The owner asked for one consistent treatment rather than a highlight
 * on the two nearest occasions.
 *
 * Nothing is lost by that: the occasion list is already sorted by how near each
 * one is, so what is coming up soonest is simply first. The order carries the
 * urgency the highlight used to.
 *
 * Text stays in ink rather than brand orange -- orange-on-white text would fail
 * contrast at this size, and the border plus dot already carry the colour. */
.dg-menu .dg-chip { border-color: var(--dg-brand); font-weight: 500; }
.dg-menu .dg-chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--dg-brand); margin-right: 7px; flex: 0 0 auto;
}

/* "More" is a control, not an occasion. It stays quiet and takes no dot, so it
 * never reads as one more thing to buy. */
.dg-menu .dg-chip--more {
  border-style: dashed; border-color: var(--dg-line);
  color: var(--dg-muted); font-weight: 400;
}
.dg-menu .dg-chip--more::before { display: none; }

/* Reserve the height the menu is about to occupy, so the panel does not jump
 * when it arrives. */
.dg-menu-loading { display: flex; flex-wrap: wrap; gap: 7px; }
.dg-skel {
  height: 46px; border-radius: 999px; background: var(--dg-soft);
  flex: 0 0 auto; width: 96px; animation: dg-pulse 1.4s ease-in-out infinite;
}
.dg-skel:nth-child(2n) { width: 128px; }
.dg-skel:nth-child(3n) { width: 78px; }
@keyframes dg-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* Devanagari sits taller than Latin at the same size and clips in a pill. */
.dg-panel[lang="hi"] .dg-chip { line-height: 1.55; padding-top: 2px; }
.dg-panel[lang="hi"] .dg-title,
.dg-panel[lang="hi"] .dg-msg { line-height: 1.6; }

@media (prefers-reduced-motion: reduce) {
  .dg-skel { animation: none; }
  .dg-chip:hover, .dg-card:hover { transform: none; }
}
