/* ==========================================================================
   Mert Gümüş AI Concierge — jewelry advisor widget (js/ai-assistant.js).
   Header: "Mert Gümüş | AI CONCIERGE". Below it, the "Modern Jewelry AI"
   layout: an opening with a faceted-gem drawing and the question, a
   quick-start rail, and a dark mocha command bar; then the conversation.

   Palette (unchanged): ivory field, mocha type, champagne hairlines, warm
   beige surfaces. Light and glow are soft motion cues — no neon, gold
   fills or heavy shadows.

   Stacking (see css/style.css): mobile nav 600–601, discount tab 650,
   THIS widget 700, discount overlay/drawer 890–900, cookie banner 950,
   toast 1000.
   ========================================================================== */

.mg-ai{
  --ai-ink: #33211A;                 /* body text — warm dark mocha */
  --ai-mocha: var(--cta, #4A2D21);
  --ai-mocha-deep: #3B2A23;
  --ai-muted: #75604F;               /* secondary text — mocha, never grey */
  --ai-sub: #4A3326;                 /* firm secondary mocha */
  --ai-field: #FFFCF8;               /* panel field — soft ivory */
  --ai-card: #FFFDFB;                /* tile / card surface */
  --ai-beige: #F4EBE2;               /* warm beige */
  --ai-champagne: var(--champagne, #CDB89F);
  --ai-hairline: rgba(205, 184, 159, .5);
  --ai-line: rgba(205, 184, 159, .7);
  --ai-emerald: #4FAA80;
  --ai-radius: 16px;
  --ai-offset: 0px; /* raised above the cookie banner by JS while it is open */
  /* Header surface — deep mocha, a whisper of tonal depth */
  --ai-head-bg: linear-gradient(135deg, #4A2D21 0%, #3A2319 55%, #2F1C14 100%);
  --ai-on-dark: #FFF6EC;
  --ai-on-dark-soft: rgba(255, 240, 226, .74);
  /* Type system: Urbanist for the wordmark and headings, Jost for text */
  --ai-font-display: 'Urbanist', var(--font-sans, 'Manrope'), sans-serif;
  --ai-font-body: 'Jost', var(--font-sans, 'Manrope'), sans-serif;
  font-family: var(--ai-font-body);
  color: var(--ai-ink);
}
.mg-ai *, .mg-ai *::before, .mg-ai *::after{ box-sizing: border-box; }
.mg-ai [hidden]{ display: none !important; }

/* ==========================================================================
   Launcher
   ========================================================================== */
.mg-ai-launcher{
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--ai-offset) + env(safe-area-inset-bottom, 0px));
  z-index: 700;
  display: inline-flex; align-items: center; gap: 10px;
  height: 48px;
  padding: 0 18px 0 6px;
  border: 1px solid rgba(205, 184, 159, .55);
  border-radius: 999px;
  background: var(--ai-mocha);
  color: #FFF7F0;
  font: 600 14px/1 var(--ai-font-body);
  letter-spacing: .02em;
  box-shadow: 0 6px 18px rgba(53, 35, 29, .18);
  cursor: pointer;
  transition: background .22s ease, box-shadow .22s ease, transform .22s ease, bottom .25s ease;
}
.mg-ai-launcher:hover{ background: #3A231A; box-shadow: 0 8px 22px rgba(53, 35, 29, .24); transform: translateY(-1px); }
.mg-ai-launcher:focus-visible{ outline: 2px solid var(--ai-champagne); outline-offset: 3px; }
.mg-ai-launcher[aria-expanded="true"]{ opacity: 0; pointer-events: none; transform: translateY(6px); }
.mg-ai-mark{
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #FFF9F2;
  color: #3A231A;
}
.mg-ai-mark svg{ display: block; width: 20px; height: 20px; }
.mg-ai-launcher-label{ white-space: nowrap; transition: transform .22s ease; }
.mg-ai-launcher:hover .mg-ai-launcher-label{ transform: translateX(1px); }

/* ==========================================================================
   Panel
   ========================================================================== */
.mg-ai-panel{
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--ai-offset) + env(safe-area-inset-bottom, 0px));
  z-index: 700;
  display: flex; flex-direction: column;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 620px;
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  background: var(--ai-field);
  border: 1px solid rgba(74, 45, 33, .12);
  border-radius: var(--ai-radius);
  box-shadow: 0 2px 6px rgba(40, 24, 17, .06), 0 24px 56px rgba(40, 24, 17, .2);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.965);
  transform-origin: 100% 100%; /* grows out of the launcher's corner */
  transition: opacity .3s ease, transform .3s cubic-bezier(.16, 1, .3, 1), bottom .25s ease;
}
.mg-ai-panel.is-open{ opacity: 1; transform: none; }

/* ---------- Header: deep mocha, one-line wordmark + AI Concierge tag ---------- */
.mg-ai-head{
  position: relative;
  overflow: hidden; /* clips the one-time light sweep and the ambient light */
  display: flex; align-items: center; gap: 4px;
  min-height: 69px;
  padding: 0 6px 0 26px; /* the close glyph lands ~19px from the edge */
  background: var(--ai-head-bg);
  color: var(--ai-on-dark);
  box-shadow: inset 0 -1px 0 rgba(205, 184, 159, .3); /* fine champagne base line */
}
.mg-ai-head-text{ position: relative; z-index: 1; flex: 1; min-width: 0; }
/* Wordmark · hairline · tag, on one optical centre line. */
.mg-ai-brand{ display: flex; align-items: center; gap: 12px; min-width: 0; }
.mg-ai-title{
  flex: none;
  margin: 0;
  font-family: var(--ai-font-display);
  font-size: 21px; font-weight: 800; line-height: 1; letter-spacing: -.012em;
  color: #FFF8F0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  white-space: nowrap;
}
.mg-ai-title:focus{ outline: none; }
.mg-ai-rule{
  flex: none;
  width: 1px; height: 13px;
  background: rgba(216, 194, 164, .42);
  transform: scaleX(.6); /* a finer-than-1px hairline on dense screens */
}
.mg-ai-tag{
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  min-width: 0;
  margin: 0;
  font: 600 10px/1 var(--ai-font-body);
  letter-spacing: .28em;
  color: #D8C2A4;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
}
/* A very small champagne glint beside the tag, breathing slowly. */
.mg-ai-tag::after{
  content: '';
  flex: none;
  width: 3px; height: 3px;
  margin-left: -2px; /* sits against the tag's trailing letter-spacing */
  background: #F3E3CC;
  transform: rotate(45deg);
  animation: mg-ai-glint 3.6s ease-in-out infinite;
}
@keyframes mg-ai-glint{
  0%, 100%{ opacity: .3; box-shadow: 0 0 0 0 rgba(243, 227, 204, 0); }
  50%     { opacity: .95; box-shadow: 0 0 5px 1px rgba(243, 227, 204, .45); }
}
/* Close / home: bare fine ivory line icons; a soft champagne disc on hover. */
.mg-ai-iconbtn{
  position: relative; z-index: 3;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 246, 236, .78);
  cursor: pointer;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.mg-ai-iconbtn:hover{ background: rgba(216, 194, 164, .12); box-shadow: inset 0 0 0 1px rgba(216, 194, 164, .3); color: #FFF8F0; }
.mg-ai-iconbtn:focus-visible{ outline: 2px solid var(--ai-champagne); outline-offset: 2px; }
.mg-ai-iconbtn svg{ width: 16px; height: 16px; display: block; }
.mg-ai-iconbtn svg *{ stroke-width: 1.1; }
.mg-ai-home svg{ width: 16px; height: 16px; }


/* ==========================================================================
   Body — "Modern Jewelry AI"
   Opening: a faceted-gem line drawing top right, the question low left.
   Quick starts ride on a rail right above a dark mocha command bar (the
   header's material, repeated at the bottom). In chat mode the opening
   and the rail are gone; only the conversation and the bar remain.
   ========================================================================== */

/* ---------- Scroll area ---------- */
.mg-ai-log{
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(205, 184, 159, .6) transparent;
}

/* ---------- First-use consent (replaces the body until accepted) ---------- */
.mg-ai-panel[data-consent="pending"] .mg-ai-log,
.mg-ai-panel[data-consent="pending"] .mg-ai-rail-wrap,
.mg-ai-panel[data-consent="pending"] .mg-ai-foot,
.mg-ai-panel[data-consent="pending"] .mg-ai-home{ display: none !important; }
.mg-ai-consent{
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex; flex-direction: column;
  padding: 22px 22px calc(16px + env(safe-area-inset-bottom, 0px));
  scrollbar-width: thin;
  scrollbar-color: rgba(205, 184, 159, .6) transparent;
}
/* AI mark: a small mocha tile with an ivory-champagne sparkle, fine edge. */
.mg-ai-consent-mark{
  flex: none;
  align-self: flex-start;
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  margin: 4px 0 16px;
  border-radius: 11px;
  background: var(--ai-head-bg);
  color: #F3E3CC;
  box-shadow: inset 0 0 0 1px rgba(216, 194, 164, .38), 0 4px 12px rgba(40, 24, 17, .12);
}
.mg-ai-consent-mark svg{ width: 16px; height: 16px; display: block; }
.mg-ai-consent-title{
  margin: 0;
  font: 800 24px/1.1 var(--ai-font-display);
  letter-spacing: -.03em;
  color: #33201A;
}
.mg-ai-consent-lead{
  margin: 10px 0 0;
  font: 500 14px/1.55 var(--ai-font-body);
  color: var(--ai-muted);
}
.mg-ai-consent-note{
  margin: 10px 0 0;
  font: 500 12.5px/1.5 var(--ai-font-body);
  color: #8A7464;
}
.mg-ai-consent-age{
  margin: 6px 0 0;
  font: 500 11.5px/1.4 var(--ai-font-body);
  color: #9A8575;
}
/* Consent row: warm ivory surface, fine champagne edge, a custom box over a
   real checkbox (the input stays focusable and clickable). */
.mg-ai-consent-row{
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: start;
  margin-top: auto;
  padding: 14px 14px 14px 13px;
  border-radius: 13px;
  background: #FBF6F0;
  box-shadow: inset 0 0 0 1px rgba(205, 184, 159, .6);
  transition: background .25s ease, box-shadow .25s ease;
}
.mg-ai-consent-row:has(.mg-ai-consent-input:checked){ background: #F6EDE3; box-shadow: inset 0 0 0 1px rgba(139, 111, 86, .5); }
.mg-ai-consent-check{ position: relative; width: 22px; height: 22px; margin-top: 1px; }
.mg-ai-consent-input{
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.mg-ai-consent-box{
  position: absolute; inset: 0;
  border-radius: 6px;
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1.5px rgba(139, 111, 86, .55);
  transition: background .2s ease, box-shadow .2s ease;
}
.mg-ai-consent-box::after{
  content: '';
  position: absolute; left: 8px; top: 4px;
  width: 5px; height: 10px;
  border-right: 2px solid #F3E3CC; border-bottom: 2px solid #F3E3CC;
  transform: rotate(45deg) scale(.4);
  opacity: 0;
  transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .2, 1);
}
.mg-ai-consent-input:checked + .mg-ai-consent-box{ background: var(--ai-head-bg); box-shadow: inset 0 0 0 1px rgba(216, 194, 164, .5), 0 0 0 3px rgba(205, 184, 159, .22); }
.mg-ai-consent-input:checked + .mg-ai-consent-box::after{ opacity: 1; transform: rotate(45deg) scale(1); }
.mg-ai-consent-input:hover + .mg-ai-consent-box{ box-shadow: inset 0 0 0 1.5px rgba(74, 45, 33, .7); }
.mg-ai-consent-input:checked:hover + .mg-ai-consent-box{ box-shadow: inset 0 0 0 1px rgba(216, 194, 164, .5), 0 0 0 3px rgba(205, 184, 159, .22); }
.mg-ai-consent-input:focus-visible + .mg-ai-consent-box{ outline: 2px solid var(--ai-mocha); outline-offset: 3px; }
.mg-ai-consent-text{
  font: 500 13px/1.5 var(--ai-font-body);
  color: var(--ai-ink);
  cursor: pointer;
}
.mg-ai-consent-text a{
  color: var(--ai-mocha);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(176, 146, 116, .8);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.mg-ai-consent-text a:hover{ text-decoration-color: var(--ai-mocha); }
.mg-ai-consent-text a:focus-visible{ outline: 2px solid var(--ai-mocha); outline-offset: 2px; border-radius: 3px; }

.mg-ai-consent-go{
  flex: none;
  height: 50px;
  margin-top: 12px;
  border: 0; border-radius: 12px;
  background: var(--ai-head-bg);
  color: #FFF6EC;
  font: 700 14px/1 var(--ai-font-display);
  letter-spacing: .14em;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(216, 194, 164, .42), inset 0 1px 0 rgba(255, 240, 220, .2), 0 8px 20px rgba(40, 24, 17, .16);
  transition: filter .2s ease, box-shadow .25s ease, background .25s ease, color .25s ease;
}
.mg-ai-consent-go:not(:disabled):hover{ filter: brightness(.92); }
.mg-ai-consent-go:focus-visible{ outline: 2px solid var(--ai-mocha); outline-offset: 3px; }
.mg-ai-consent-go:disabled{
  background: #EDE3D8;
  color: #A58C77;
  box-shadow: inset 0 0 0 1px rgba(176, 146, 116, .3);
  cursor: not-allowed;
}
.mg-ai-consent-cancel{
  flex: none;
  align-self: center;
  margin-top: 6px;
  padding: 9px 14px;
  border: 0; border-radius: 8px;
  background: none;
  color: #6A4E3E;
  font: 600 13px/1 var(--ai-font-body);
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.mg-ai-consent-cancel:hover{ color: #33201A; background: rgba(244, 235, 226, .8); }
.mg-ai-consent-cancel:focus-visible{ outline: 2px solid var(--ai-mocha); outline-offset: 2px; }

/* Consent motion: a light stagger in; a short fade-up out on "Devam Et". */
.mg-ai-panel.is-open .mg-ai-consent > *{ animation: mg-ai-rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.mg-ai-panel.is-open .mg-ai-consent > :nth-child(1){ animation-delay: .04s; }
.mg-ai-panel.is-open .mg-ai-consent > :nth-child(2){ animation-delay: .1s; }
.mg-ai-panel.is-open .mg-ai-consent > :nth-child(3){ animation-delay: .16s; }
.mg-ai-panel.is-open .mg-ai-consent > :nth-child(4){ animation-delay: .21s; }
.mg-ai-panel.is-open .mg-ai-consent > :nth-child(5){ animation-delay: .27s; }
.mg-ai-panel.is-open .mg-ai-consent > :nth-child(6){ animation-delay: .33s; }
.mg-ai-panel.is-open .mg-ai-consent > :nth-child(7){ animation-delay: .38s; }
.mg-ai-panel.is-open .mg-ai-consent > :nth-child(8){ animation-delay: .42s; }
.mg-ai-consent.is-leaving{ opacity: 0; transform: translateY(-10px); transition: opacity .26s ease, transform .26s ease; }

/* ---------- Opening ---------- */
.mg-ai-welcome{
  position: relative;
  min-height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 22px 22px 16px;
}
/* Decorative, never in the way: a faceted stone with three slow sparkles. */
.mg-ai-gem{
  position: absolute; right: -6px; top: 4px;
  width: 172px; height: 172px;
  color: rgba(154, 124, 98, .38);
  pointer-events: none;
}
.mg-ai-twinkle{ color: #C8A77F; transform-box: fill-box; transform-origin: center; animation: mg-ai-twinkle 3.4s ease-in-out infinite; }
.mg-ai-twinkle--b{ animation-delay: 1.2s; }
.mg-ai-twinkle--c{ animation-delay: 2.2s; }
@keyframes mg-ai-twinkle{
  0%, 100%{ opacity: .3; transform: scale(.78); }
  50%     { opacity: 1;  transform: scale(1); }
}

.mg-ai-hero{ position: relative; }
.mg-ai-hero-top{ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mg-ai-chipmark,
.mg-ai-resume{
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 10px 0 8px;
  border: 0; border-radius: 8px;
  font: 600 11px/1 var(--ai-font-body);
  white-space: nowrap;
}
.mg-ai-chipmark{
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(205, 184, 159, .55);
  letter-spacing: .14em;
  color: var(--ai-mocha);
}
.mg-ai-chipmark svg{ width: 11px; height: 11px; display: block; color: #B8956D; }
.mg-ai-resume{
  background: var(--ai-beige);
  color: #5E4536;
  letter-spacing: .01em;
  font-size: 12px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.mg-ai-resume svg{ width: 11px; height: 11px; display: block; }
.mg-ai-resume:hover{ background: #EFE2D4; color: #33201A; }
.mg-ai-resume:focus-visible{ outline: 2px solid var(--ai-mocha); outline-offset: 2px; }

.mg-ai-hero-title{
  margin: 14px 0 0;
  font: 800 29px/1.03 var(--ai-font-display);
  letter-spacing: -.04em;
  color: #33201A;
}
.mg-ai-hero-sub{
  margin: 9px 0 0;
  max-width: 27ch;
  font: 500 13.5px/1.5 var(--ai-font-body);
  color: var(--ai-muted);
}

/* ---------- Quick-start rail (opening only) ---------- */
.mg-ai-rail-wrap{ flex: none; padding: 8px 0 8px; }
.mg-ai-rail-head{ display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 16px 7px 22px; }
.mg-ai-rail-label{ font: 600 10.5px/1 var(--ai-font-body); letter-spacing: .2em; color: #9A7C62; }
.mg-ai-rail{
  display: flex; gap: 7px;
  overflow-x: auto;
  padding: 2px 16px 4px;
  scroll-padding: 16px;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mg-ai-rail::-webkit-scrollbar{ display: none; }
.mg-ai-chip{
  position: relative; overflow: hidden;
  flex: none;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 10px 12px 11px;
  border: 0; border-radius: 11px;
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(205, 184, 159, .5);
  color: #33201A;
  font: inherit; text-align: left;
  scroll-snap-align: start;
  cursor: pointer;
  transition: box-shadow .25s ease, transform .25s ease, opacity .2s ease;
}
.mg-ai-chip svg{ width: 15px; height: 15px; display: block; color: var(--ai-mocha); }
.mg-ai-chip-label{ font: 700 13.5px/1.15 var(--ai-font-display); white-space: nowrap; }
.mg-ai-chip--gift{ background: linear-gradient(145deg, #F6EDE2, #EFE2D2); box-shadow: inset 0 0 0 1px rgba(176, 146, 116, .55); }
.mg-ai-chip::after{ /* hover light */
  content: '';
  position: absolute; top: 0; bottom: 0; left: 0; width: 50%;
  background: linear-gradient(100deg, rgba(222, 196, 160, 0), rgba(255, 242, 222, .9), rgba(222, 196, 160, 0));
  transform: translateX(-120%);
  pointer-events: none;
}
.mg-ai-chip:hover{ box-shadow: inset 0 0 0 1px rgba(74, 45, 33, .32), 0 5px 14px rgba(53, 35, 29, .07); transform: translateY(-1px); }
.mg-ai-chip:hover::after{ transform: translateX(260%); transition: transform .7s cubic-bezier(.3, .6, .3, 1); }
.mg-ai-chip:focus-visible{ outline: 2px solid var(--ai-mocha); outline-offset: 2px; }
.mg-ai-chip:disabled{ opacity: .5; cursor: default; }
/* Selection: a short champagne micro-glow before the chat opens. */
.mg-ai-chip.is-pressed{ animation: mg-ai-press .34s ease-out; }
@keyframes mg-ai-press{
  0%  { box-shadow: inset 0 0 0 1px var(--ai-mocha), 0 0 0 0 rgba(205, 184, 159, .75); }
  100%{ box-shadow: inset 0 0 0 1px var(--ai-mocha), 0 0 0 9px rgba(205, 184, 159, 0); }
}

/* ---------- Opening motion: a light stagger each time it appears ---------- */
.mg-ai-panel.is-open .mg-ai-welcome .mg-ai-hero > *,
.mg-ai-panel.is-open .mg-ai-rail-head,
.mg-ai-panel.is-open .mg-ai-chip,
.mg-ai-welcome.is-returning .mg-ai-hero > *{
  animation: mg-ai-rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
.mg-ai-panel.is-open .mg-ai-hero > :nth-child(1){ animation-delay: .06s; }
.mg-ai-panel.is-open .mg-ai-hero > :nth-child(2){ animation-delay: .12s; }
.mg-ai-panel.is-open .mg-ai-hero > :nth-child(3){ animation-delay: .18s; }
.mg-ai-panel.is-open .mg-ai-rail-head{ animation-delay: .22s; }
.mg-ai-panel.is-open .mg-ai-chip:nth-child(1){ animation-delay: .26s; }
.mg-ai-panel.is-open .mg-ai-chip:nth-child(2){ animation-delay: .31s; }
.mg-ai-panel.is-open .mg-ai-chip:nth-child(3){ animation-delay: .36s; }
.mg-ai-panel.is-open .mg-ai-chip:nth-child(4){ animation-delay: .41s; }
.mg-ai-panel.is-open .mg-ai-gem{ animation: mg-ai-fade .9s .1s ease both; }
.mg-ai-chip.is-pressed{ animation-delay: 0s !important; }
/* Leaving for the chat: opening and rail lift away together. */
.mg-ai-welcome.is-leaving > *,
.mg-ai-rail-wrap.is-leaving{ opacity: 0; transform: translateY(-8px); transition: opacity .2s ease, transform .2s ease; }
.mg-ai-chat.is-entering{ animation: mg-ai-rise .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes mg-ai-rise{
  from{ opacity: 0; transform: translateY(8px); }
  to  { opacity: 1; transform: none; }
}
@keyframes mg-ai-fade{ from{ opacity: 0; } to{ opacity: 1; } }

/* ==========================================================================
   Conversation
   ========================================================================== */
.mg-ai-chat{ padding: 20px 22px 14px; }
.mg-ai-thread{ display: flex; flex-direction: column; gap: 18px; }
.mg-ai-thread:empty{ display: none; }
.mg-ai-thread > *{ animation: mg-ai-rise .28s cubic-bezier(.2, .8, .2, 1) both; }
.mg-ai-thread > .mg-ai-products{ animation-delay: .08s; }

.mg-ai-msg{
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
/* Assistant: a full-width text block, no bubble, no repeated name. */
.mg-ai-msg--assistant{
  font: 500 15.5px/1.6 var(--ai-font-body);
  color: #2A1913;
}
.mg-ai-msg--error{ color: var(--ai-muted); }
/* Visitor: compact white note on the right with a fine mocha edge. */
.mg-ai-msg--user{
  align-self: flex-end;
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 10px;
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(74, 45, 33, .22);
  color: #24160F;
  font: 500 15px/1.5 var(--ai-font-body);
}

/* ---------- Typing: three visible dots; the words stay for screen readers ---------- */
.mg-ai-typing{ align-self: flex-start; display: inline-flex; align-items: center; padding: 6px 0; }
.mg-ai-typing > span:first-child{
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mg-ai-dots{ display: inline-flex; align-items: center; gap: 6px; }
.mg-ai-dots span{
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ai-mocha);
  opacity: .45;
  transform: scale(.85);
  animation: mg-ai-dot 1.15s infinite ease-in-out;
}
.mg-ai-dots span:nth-child(2){ animation-delay: .17s; }
.mg-ai-dots span:nth-child(3){ animation-delay: .34s; }
@keyframes mg-ai-dot{
  0%, 65%, 100%{ opacity: .45; background: var(--ai-mocha); transform: scale(.85); box-shadow: 0 0 0 0 rgba(196, 150, 100, 0); }
  30%          { opacity: 1;   background: #C99B68;       transform: scale(1.18); box-shadow: 0 0 8px 3px rgba(196, 150, 100, .45); }
}

/* ---------- Product strip: image-led cards, name and price on a mocha band ---------- */
.mg-ai-products{
  display: flex; gap: 8px;
  margin: -4px -22px 0;
  padding: 0 22px 2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding: 22px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mg-ai-products::-webkit-scrollbar{ display: none; }
.mg-ai-card{
  position: relative;
  overflow: hidden;
  flex: 0 0 146px;
  height: 184px;
  scroll-snap-align: start;
  border-radius: 12px;
  background: linear-gradient(165deg, #F7EEE4 0%, #E8D8C6 100%);
  color: inherit;
  text-decoration: none;
}
.mg-ai-card:focus-visible{ outline: 2px solid var(--ai-mocha); outline-offset: 2px; }
.mg-ai-card-media{
  position: absolute; left: 0; right: 0; top: 0; bottom: 58px;
  display: flex; align-items: center; justify-content: center;
  color: #A98C71;
}
.mg-ai-card-media svg{ width: 84px; height: 84px; transition: transform .4s cubic-bezier(.2, .8, .2, 1); }
.mg-ai-card-media img{ position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.mg-ai-card:hover .mg-ai-card-media svg,
.mg-ai-card:hover .mg-ai-card-media img{ transform: scale(1.05); }
.mg-ai-card-body{
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 58px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  padding: 8px 11px;
  background: linear-gradient(0deg, rgba(47, 28, 20, .95), rgba(58, 35, 25, .86));
  color: #FFF6EC;
}
.mg-ai-card-name{
  font: 600 12.5px/1.25 var(--ai-font-display);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mg-ai-card-price{ display: flex; align-items: baseline; gap: 6px; min-width: 0; padding-right: 26px; }
.mg-ai-card-price strong{ font: 700 13px/1 var(--ai-font-display); color: #E7D5BC; white-space: nowrap; }
.mg-ai-card-price s{ font: 500 11px/1 var(--ai-font-body); color: rgba(255, 240, 226, .55); }
.mg-ai-card-out{
  position: absolute; left: 8px; top: 8px;
  padding: 4px 7px; border-radius: 6px;
  background: rgba(255, 252, 248, .92);
  font: 600 10px/1 var(--ai-font-body); letter-spacing: .12em;
  color: #8A3B2E;
}
/* "İncele": a small arrow disc; the word stays in the card's aria-label. */
.mg-ai-card-cta{
  position: absolute; right: 9px; bottom: 7px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(255, 240, 222, .14);
  font-size: 0; color: transparent;
  transition: background .2s ease;
}
.mg-ai-card-cta::after{
  content: '';
  position: absolute; left: 6px; top: 7px;
  width: 5px; height: 5px;
  border-top: 1.4px solid #FFF6EC; border-right: 1.4px solid #FFF6EC;
  transform: rotate(45deg);
}
.mg-ai-card:hover .mg-ai-card-cta{ background: rgba(231, 213, 188, .35); }

/* ==========================================================================
   Footer: support (only when it matters) + dark command bar + note
   ========================================================================== */
.mg-ai-foot{
  flex: none;
  display: flex; flex-direction: column; gap: 7px;
  padding: 2px 12px calc(9px + env(safe-area-inset-bottom, 0px));
  background: var(--ai-field);
}
.mg-ai-support{
  display: inline-flex; align-items: center; gap: 6px;
  color: #6A4E3E;
  font: 600 12.5px/1 var(--ai-font-body);
  letter-spacing: .01em;
  text-decoration: none;
  transition: color .2s ease;
}
.mg-ai-support svg{ width: 13px; height: 13px; display: block; flex: none; color: #8B6F56; }
.mg-ai-support-via{ font-weight: 500; color: #9A7C62; }
.mg-ai-support-via::before{ content: '· '; }
.mg-ai-support:hover{ color: #33201A; }
.mg-ai-support:focus-visible{ outline: 2px solid var(--ai-mocha); outline-offset: 2px; border-radius: 4px; }
/* In the rail header it is a quiet link; above the bar it appears only when
   an answer or an error points to it. */
.mg-ai-rail-head .mg-ai-support .mg-ai-support-via{ display: none; }
.mg-ai-foot > .mg-ai-support{ display: none; align-self: flex-start; margin-left: 10px; }
.mg-ai-foot > .mg-ai-support.is-highlight:not([hidden]){ display: inline-flex; animation: mg-ai-rise .3s ease both; }

/* Command bar: the header's mocha, floating; champagne edge light on focus. */
.mg-ai-form{
  display: flex; align-items: flex-end; gap: 8px;
  min-height: 50px;
  margin: 0;
  padding: 7px 7px 7px 8px;
  border-radius: 14px;
  background: var(--ai-head-bg);
  box-shadow: 0 8px 22px rgba(40, 24, 17, .18), inset 0 0 0 1px rgba(216, 194, 164, .16);
  transition: box-shadow .3s ease;
}
.mg-ai-form:focus-within{
  box-shadow: 0 8px 22px rgba(40, 24, 17, .18), inset 0 0 0 1px rgba(231, 213, 188, .68), 0 0 0 3px rgba(205, 184, 159, .24);
}
.mg-ai-form-mark{
  flex: none;
  width: 34px; height: 34px;
  margin-bottom: 1px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: rgba(255, 240, 222, .07);
  color: #E7D5BC;
}
.mg-ai-form-mark svg{ width: 13px; height: 13px; display: block; }
.mg-ai-form:focus-within .mg-ai-form-mark svg{ animation: mg-ai-twinkle 2.4s ease-in-out infinite; }
.mg-ai-input{
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 120px;
  padding: 8px 0 7px;
  border: 0;
  background: transparent;
  color: #FFF6EC;
  caret-color: #E7D5BC;
  font: 400 16px/1.35 var(--ai-font-body); /* ≥16px: no iOS zoom on focus */
  resize: none;
  overflow-y: hidden; /* js/ai-assistant.js autosize() turns it on past 120px */
}
.mg-ai-input::placeholder{ color: rgba(255, 240, 226, .52); opacity: 1; }
.mg-ai-input:focus{ outline: none; }
.mg-ai-send{
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  width: 36px; height: 36px;
  border: 0; border-radius: 10px;
  background: #E7D5BC;
  color: #33201A;
  cursor: pointer;
  transition: opacity .25s ease, box-shadow .25s ease, transform .25s ease;
}
.mg-ai-send svg{ width: 16px; height: 16px; display: block; }
.mg-ai-send:hover{ box-shadow: 0 0 14px rgba(231, 213, 188, .5); }
.mg-ai-send:focus-visible{ outline: 2px solid #E7D5BC; outline-offset: 2px; }
.mg-ai-send:disabled{ opacity: .28; cursor: default; box-shadow: none; }
.mg-ai-send:not(:disabled){ box-shadow: 0 0 12px rgba(231, 213, 188, .42); animation: mg-ai-send-on .4s cubic-bezier(.2, .8, .2, 1); }
@keyframes mg-ai-send-on{
  0%  { transform: scale(.9); }
  60% { transform: scale(1.05); }
  100%{ transform: none; }
}
.mg-ai-note{
  margin: 0;
  text-align: center;
  font: 500 10.5px/1.3 var(--ai-font-body);
  letter-spacing: .01em;
  color: #A0897A;
}

.mg-ai-sr{
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Motion — signs of a live advisor: visible, soft, in-palette.
   ========================================================================== */

/* Status pulse: 0 → 6 → 12px ring, .75 → .4 → 0, over a steady halo. */
@keyframes mg-ai-online{
  0%  { box-shadow: 0 0 6px 2px rgba(79, 170, 128, .55), 0 0 0 0    rgba(79, 170, 128, .75); }
  50% { box-shadow: 0 0 6px 2px rgba(79, 170, 128, .55), 0 0 0 6px  rgba(79, 170, 128, .4); }
  100%{ box-shadow: 0 0 6px 2px rgba(79, 170, 128, .55), 0 0 0 12px rgba(79, 170, 128, 0); }
}
/* The launcher carries the same status dot on its icon. */
.mg-ai-launcher .mg-ai-mark::after{
  content: '';
  position: absolute; top: -1px; right: -1px;
  z-index: 2;
  width: 10px; height: 10px;
  border: 1.5px solid #FFF9F2;
  border-radius: 50%;
  background: radial-gradient(circle, #F2FFF8 0, #E3FAEE 1.4px, #5FB38D 3px, #3F8F6B 100%);
  animation: mg-ai-online 1.9s cubic-bezier(.3, .6, .4, 1) infinite;
}


/* Header ambient: a small, still champagne light pooled behind the title's
   left side — not across the header. */
.mg-ai-head::before{
  content: '';
  position: absolute; left: -30px; top: 50%;
  width: 190px; height: 90px;
  margin-top: -45px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(205, 170, 128, .2), rgba(205, 170, 128, 0)); /* warm light on the dark header — static */
  pointer-events: none;
}
/* Header light sweep: a fine champagne band, once, each time the panel opens. */
.mg-ai-head::after{
  content: '';
  position: absolute; top: 0; bottom: 0; left: 0;
  z-index: 2;
  width: 24%;
  background: linear-gradient(100deg,
    rgba(222, 200, 172, 0) 0%,
    rgba(222, 200, 172, .08) 38%,
    rgba(248, 236, 218, .22) 50%,
    rgba(222, 200, 172, .08) 62%,
    rgba(222, 200, 172, 0) 100%);
  transform: translateX(-110%);
  pointer-events: none;
}
.mg-ai-panel.is-open .mg-ai-head::after{ animation: mg-ai-sweep .9s .1s cubic-bezier(.45, .1, .3, 1) both; }
@keyframes mg-ai-sweep{
  from{ transform: translateX(-110%); opacity: 1; }
  85% { opacity: 1; }
  to  { transform: translateX(460%); opacity: 0; }
}

/* Launcher icon: breathing champagne halo, a fine light ring and a bright
   spot travelling round it. Only the icon glows. */
.mg-ai-launcher .mg-ai-mark{ animation: mg-ai-mark-breathe 2.8s ease-in-out infinite; }
@keyframes mg-ai-mark-breathe{
  0%, 100%{ box-shadow: 0 0 0 1.5px rgba(222, 196, 164, .55), 0 0 10px 2px rgba(232, 206, 170, .45); }
  50%     { box-shadow: 0 0 0 1.5px rgba(236, 214, 184, .95), 0 0 20px 6px rgba(232, 206, 170, .8); }
}
.mg-ai-launcher .mg-ai-mark::before{
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    rgba(245, 226, 198, .18) 0 60%,
    rgba(255, 244, 222, 1) 80%,
    rgba(245, 226, 198, .18) 96% 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.2px), #000 calc(100% - 1.8px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2.2px), #000 calc(100% - 1.8px));
  animation: mg-ai-ring 3s linear infinite;
  transition: filter .22s ease;
  pointer-events: none;
}
.mg-ai-launcher:hover .mg-ai-mark::before{ filter: brightness(1.15) drop-shadow(0 0 3px rgba(255, 236, 206, .9)); }
@keyframes mg-ai-ring{ to{ transform: rotate(360deg); } }

/* ==========================================================================
   Mobile: full-screen sheet
   ========================================================================== */
@media (max-width: 640px){
  .mg-ai-launcher{
    right: 14px;
    bottom: calc(18px + var(--ai-offset) + env(safe-area-inset-bottom, 0px));
    padding: 0 6px;
    height: 48px;
  }
  .mg-ai-launcher-label{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  /* Full screen, but it stops at the cookie banner's top edge while that
     banner is shown (--ai-offset = its height, 0 otherwise), so the input
     is never hidden under it. top+bottom (not 100dvh) also follows the
     visual viewport when the on-screen keyboard opens. */
  .mg-ai-panel{
    top: 0; right: 0; left: 0;
    bottom: var(--ai-offset);
    width: 100%; max-width: none;
    height: auto;
    max-height: none;
    border: 0; border-radius: 0;
    box-shadow: none;
  }
  .mg-ai-head{ min-height: calc(68px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); padding-left: 22px; }
  .mg-ai-title{ font-size: 20.5px; }
  .mg-ai-brand{ gap: 11px; }
  .mg-ai-panel[data-mode="chat"] .mg-ai-head .mg-ai-home{ margin-left: 6px; }
  .mg-ai-welcome{ padding: 20px 18px 14px; }
  .mg-ai-consent{ padding: 20px 18px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .mg-ai-gem{ width: 150px; height: 150px; }
  .mg-ai-chat{ padding: 18px 18px 12px; }
  .mg-ai-products{ margin-left: -18px; margin-right: -18px; padding-left: 18px; padding-right: 18px; scroll-padding: 18px; }
  .mg-ai-rail-head{ padding-left: 18px; padding-right: 14px; }
  .mg-ai-rail{ padding-left: 14px; padding-right: 14px; scroll-padding: 14px; }
  .mg-ai-foot{ padding-left: 10px; padding-right: 10px; }
  .mg-ai-msg--user{ max-width: 84%; }
  body.mg-ai-lock{ overflow: hidden; }

  /* Lighter on phones: no hover light (touch). */
  .mg-ai-chip::after{ display: none; }
  .mg-ai-launcher .mg-ai-mark::after{ animation-duration: 2.2s; }
  .mg-ai-launcher .mg-ai-mark::before{ animation-duration: 4s; }
  .mg-ai-launcher .mg-ai-mark{ animation-duration: 3.2s; }
}
/* Narrow phones in chat mode (home + close both shown): a tighter tag. */
@media (max-width: 380px){
  .mg-ai-panel[data-mode="chat"] .mg-ai-brand{ gap: 9px; }
  .mg-ai-panel[data-mode="chat"] .mg-ai-tag{ letter-spacing: .18em; }
  .mg-ai-hero-title{ font-size: 27px; }
}
/* Short screens: the gem steps back so the question never runs into it. */
@media (max-height: 640px){
  .mg-ai-gem{ width: 128px; height: 128px; opacity: .8; }
}

/* Reduced motion: every animation and transition is switched off; resting
   states (visible panel, active send key) remain. */
@media (prefers-reduced-motion: reduce){
  .mg-ai *, .mg-ai *::before, .mg-ai *::after,
  .mg-ai-launcher, .mg-ai-panel{
    animation: none !important;
    transition: none !important;
  }
  .mg-ai-chip::after, .mg-ai-head::after{ display: none; }
  .mg-ai-welcome.is-leaving > *, .mg-ai-rail-wrap.is-leaving{ opacity: 1; transform: none; }
  .mg-ai-dots span{ opacity: .7; }
}
