/* =====================================================================
   Orderyfy order chat (17 Oct 2026): partials/chat-widget.blade.php + assets/js/oa-bot.js.
   Every class starts with .oa-bot- (never the old template chat's np- names, which it hides and restyles).
   The widget also renders on legacy template pages, whose reset strips borders, margins and
   outlines from everything, so box-sizing, fonts, borders, [hidden] and the focus ring are all
   set here. Logical properties only, so Urdu (RTL) mirrors by itself.
   Layers: launcher 79 (over the install pill 78 and the docks 75, under the tab bar 80, which it
   never touches); panel 95 (over the bars, under the drawer 100, toasts, cart sidebar 300,
   sheets 400 and the one-shop dialog, so every existing overlay still covers it).
   ===================================================================== */

.oa-bot, .oa-bot *, .oa-bot *::before, .oa-bot *::after { box-sizing: border-box; }
.oa-bot { font-family: var(--oa-font); color: var(--oa-ink); line-height: 1.45; font-size: 15px; }
.oa-bot [hidden] { display: none !important; }
.oa-bot :focus-visible { outline: 3px solid var(--oa-lime-600); outline-offset: 2px; }
.oa-bot button { font: inherit; color: inherit; cursor: pointer; margin: 0; }
.oa-bot :is(h2, p) { margin: 0; }
.oa-bot img { max-width: 100%; }

/* -------------------------------------------------------------- launcher */
/* R14: bottom-right on every page and in both languages, above the tab bar, the docks and the
   shop's cart bar (all through --oa-above-tabbar) and clear of the phone's safe area. */
.oa-bot-fab {
  position: fixed; z-index: 79;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(max(var(--oa-above-tabbar, 16px), 16px + var(--oa-safe-b, 0px)) + 4px);
  width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--oa-lime); color: var(--oa-ink);
  box-shadow: 0 8px 24px rgba(26, 26, 26, .24), 0 0 0 3px #fff;
  transition: transform .15s ease, opacity .2s ease, background-color .15s;
  animation: oa-bot-pop .35s ease .6s both;
}
.oa-bot-fab:hover { background: var(--oa-lime-600); }
.oa-bot-fab:active { transform: scale(.95); }
.oa-bot-fab .oa-ic { width: 26px; height: 26px; }
.oa-bot-dot {
  position: absolute; top: 2px; inset-inline-end: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--oa-sale); box-shadow: 0 0 0 2px #fff;
}
/* In Urdu the install pill takes the bottom right: the chat button sits just above it. */
html[dir="rtl"].oa-has-installpill .oa-bot-fab { bottom: calc(max(var(--oa-above-tabbar, 16px), 16px + var(--oa-safe-b, 0px)) + 54px); }
/* While the panel is open the button would only sit on top of it. */
.oa-bot.is-open .oa-bot-fab { opacity: 0; pointer-events: none; }
@media (min-width: 900px) {
  .oa-bot-fab { right: 24px; bottom: 24px; }
  html[dir="rtl"].oa-has-installpill .oa-bot-fab { bottom: 74px; }
  .oa-bot.is-open .oa-bot-fab { opacity: 1; pointer-events: auto; }
}
@keyframes oa-bot-pop { from { opacity: 0; transform: scale(.6); } }

/* Phones: room under the last row, so the button never sits on content; and out of the way of
   the keyboard and the search suggestions while a field elsewhere on the page has focus. */
@media (max-width: 899.98px) {
  html.oa-has-bot body.oa-has-tabbar .oa-tabbar-spacer { height: calc(var(--oa-tabbar-h) + 26px + 66px + var(--oa-safe-b)); }
  html.oa-has-bot.oa-has-installpill body.oa-has-tabbar .oa-tabbar-spacer { height: calc(var(--oa-tabbar-h) + 26px + 66px + 50px + var(--oa-safe-b)); }
  html.oa-has-bot body.oa-has-dock { padding-bottom: calc(84px + 66px + var(--oa-safe-b)) !important; }
  html.oa-bot-away .oa-bot-fab { opacity: 0; pointer-events: none; }
}

/* ----------------------------------------------------------------- panel */
/* KAN-49: phones get the desktop's floating card too, instead of the full screen that read as
   "the whole site is a chat": bottom right where the launcher sits (above the tab bar, the docks,
   the shop's cart bar and the product's add bar, through the launcher's own offset), at most
   380 px wide and 70% of the screen tall (the small viewport, so it holds still while the
   browser's bars slide), so the page stays in sight around it. A tap outside closes it (oa-bot.js). */
.oa-bot-panel {
  position: fixed; z-index: 95; display: flex; flex-direction: column; overflow: hidden;
  background: var(--oa-bg); color: var(--oa-ink);
  --oa-bot-b: calc(max(var(--oa-above-tabbar, 16px), 16px + var(--oa-safe-b, 0px)) + 4px);
  inset: auto; right: max(12px, env(safe-area-inset-right, 0px)); bottom: var(--oa-bot-b);
  width: calc(100vw - 24px); width: min(380px, calc(100vw - 24px));
  height: 70vh;
  height: min(540px, 70vh, calc(100vh - var(--oa-bot-b) - var(--oa-safe-t, 0px) - 16px));
  height: min(540px, 70svh, calc(100svh - var(--oa-bot-b) - var(--oa-safe-t, 0px) - 16px));
  border-radius: 20px; box-shadow: var(--oa-sh-float), 0 0 0 1px rgba(26, 26, 26, .05);
  transform: translateY(16px) scale(.96); transform-origin: 100% 100%; opacity: 0;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s ease;
}
.oa-bot-panel.is-open { transform: none; opacity: 1; }
.oa-bot-panel:focus { outline: none; }
html.oa-bot-lock { overflow: hidden !important; }
/* In Urdu the install pill lifts the launcher: the card sits on the same spot. */
html[dir="rtl"].oa-has-installpill .oa-bot-panel { --oa-bot-b: calc(max(var(--oa-above-tabbar, 16px), 16px + var(--oa-safe-b, 0px)) + 54px); }
@media (max-width: 899.98px) {
  /* KAN-49: a field in the chat has focus and the keyboard is up: oa-bot.js gives the visible
     part of the screen (--oa-bot-vh / --oa-bot-vy from visualViewport) and the card fills it
     just above the keyboard, up to its usual 540 px, so the composer never hides behind it. */
  .oa-bot-panel.is-kb {
    --oa-bot-kh: min(540px, calc(var(--oa-bot-vh, 100vh) - 16px - var(--oa-safe-t, 0px)));
    top: calc(var(--oa-bot-vy, 0px) + var(--oa-bot-vh, 100vh) - 8px - var(--oa-bot-kh));
    bottom: auto; height: var(--oa-bot-kh);
  }
  /* Chips never squeeze the conversation out of the smaller card. */
  .oa-bot-panel .oa-bot-quick { max-height: min(40vh, 40%); }
}
@media (min-width: 900px) {
  .oa-bot-panel {
    inset: auto; right: 24px; bottom: 96px; width: 380px;
    height: min(620px, calc(100vh - 140px));
    border-radius: 22px; box-shadow: var(--oa-sh-float), 0 0 0 1px rgba(26, 26, 26, .05);
    transform: translateY(16px) scale(.98); transform-origin: 50% 50%;
  }
  .oa-bot-panel.is-open { transform: none; }
  html[dir="rtl"].oa-has-installpill .oa-bot-panel { bottom: 146px; height: min(620px, calc(100vh - 190px)); }
}

/* Header: the lime of the app bars, with the brand mark. KAN-49: the card no longer reaches the
   phone's status bar, so no safe-area padding (the keyboard fit keeps clear of it instead). */
.oa-bot-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 8px 8px 14px; padding-inline: 14px 8px;
  background: var(--oa-lime); color: var(--oa-ink); border: 0;
}
.oa-bot-mark { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #fff; box-shadow: 0 0 0 2px #fff; display: block; }
.oa-bot-mark img { width: 40px; height: 40px; display: block; object-fit: cover; }
.oa-bot-id { flex: 1 1 auto; min-width: 0; }
.oa-bot-id h2 { font-family: var(--oa-display); font-size: 17px; line-height: 22px; font-weight: 800; color: var(--oa-ink); letter-spacing: -.01em; }
.oa-bot-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; line-height: 18px; color: var(--oa-on-lime-mute); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oa-bot-online { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--oa-ok); box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
.oa-bot-status.is-waiting .oa-bot-online { background: var(--oa-star); }
.oa-bot-hbtn {
  flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--oa-ink); display: inline-flex; align-items: center; justify-content: center;
}
.oa-bot-hbtn:hover { background: rgba(26, 26, 26, .08); }

/* ------------------------------------------------------------------- log */
.oa-bot-log {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 4px; padding: 14px 12px 8px;
}
.oa-bot-row { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.oa-bot-row.is-me { justify-content: flex-end; }
.oa-bot-row.is-first { margin-top: 8px; }
.oa-bot-row:first-child { margin-top: 0; }
.oa-bot-av { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; align-self: flex-end; }
.oa-bot-av img { width: 28px; height: 28px; display: block; }
.oa-bot-msg {
  max-width: 82%; padding: 9px 13px; border-radius: 18px; border: 1px solid transparent;
  font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal;
  animation: oa-bot-in .22s ease both;
}
.oa-bot-row.is-bot .oa-bot-msg { background: #fff; border-color: var(--oa-border); color: var(--oa-ink); }
.oa-bot-row.is-bot.is-first .oa-bot-msg { border-end-start-radius: 6px; }
.oa-bot-row.is-me .oa-bot-msg { background: var(--oa-lime); color: var(--oa-ink); border-end-end-radius: 6px; }
.oa-bot-msg .oa-ic { display: inline-block; vertical-align: -2px; margin-inline-end: 4px; }
html[lang="ur"] .oa-bot-msg { line-height: 1.8; }
@keyframes oa-bot-in { from { opacity: 0; transform: translateY(6px); } }

/* A line from the widget itself (offline, timed out, try again). */
.oa-bot-sys {
  align-self: center; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  margin: 8px 0; padding: 6px 12px; border-radius: 12px; background: var(--oa-sunk);
  font-size: 13px; line-height: 1.4; color: var(--oa-ink-2); text-align: center; max-width: 92%;
}
.oa-bot-sys .oa-btn { min-height: 36px; }

/* Typing: three dots for at least ~600 ms, then the bubbles one by one. */
.oa-bot-typing { flex: 0 0 auto; display: flex; align-items: center; padding: 0 12px 6px 46px; padding-inline: 46px 12px; }
.oa-bot-dots { display: inline-flex; gap: 4px; padding: 11px 13px; border-radius: 18px; border-end-start-radius: 6px; background: #fff; border: 1px solid var(--oa-border); }
.oa-bot-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--oa-faint); animation: oa-bot-blink 1.2s infinite ease-in-out; }
.oa-bot-dots i:nth-child(2) { animation-delay: .15s; }
.oa-bot-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes oa-bot-blink { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------------------------------------------------------- quick replies */
.oa-bot-quick { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 12px 8px; max-height: 40vh; overflow-y: auto; }
.oa-bot-quick .oa-chip { height: auto; min-height: 40px; padding: 6px 14px; white-space: normal; text-align: start; line-height: 1.3; border: 1.5px solid var(--oa-border-2); background: #fff; }
.oa-bot-quick .oa-chip:hover { border-color: var(--oa-ink); background: #fff; }
.oa-bot-quick .oa-chip img { width: 26px; height: 26px; margin-inline-start: -6px; }
.oa-bot-quick .oa-chip.is-shop { border-color: var(--oa-lime-600); background: var(--oa-lime-50); font-weight: 700; }

/* ------------------------------------------------------------------ cards */
.oa-bot-card {
  width: calc(100% - 34px); margin-inline-start: 34px; margin-top: 4px;
  background: #fff; border: 1px solid var(--oa-border); border-radius: 16px; padding: 10px;
  animation: oa-bot-in .22s ease both;
}
.oa-bot-card.is-past { opacity: .55; }
.oa-bot-card.is-past :is(button, input, select, textarea) { pointer-events: none; }
.oa-bot-card-t { display: flex; align-items: center; gap: 8px; font-family: var(--oa-display); font-weight: 800; font-size: 15px; margin: 2px 2px 8px; }
.oa-bot-card .oa-btn { min-height: 46px; }
.oa-bot-card .oa-btn + .oa-btn, .oa-bot-card .oa-btn + a.oa-btn { margin-top: 8px; }
.oa-bot-card a.oa-btn { text-decoration: none; }

/* Shops: every approved shop of the type, open first (R5). */
.oa-bot-shop {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px; margin: 0;
  border: 0; border-radius: 12px; background: transparent; text-align: start;
}
.oa-bot-shop + .oa-bot-shop { border-top: 1px solid var(--oa-border); border-radius: 0 0 12px 12px; }
.oa-bot-shop:hover { background: var(--oa-sunk); }
.oa-bot-logo { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; }
.oa-bot-logo .oa-ini { font-size: 14px; }
.oa-bot-shop-t { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.oa-bot-shop-t strong { font-weight: 700; font-size: 15px; line-height: 1.3; }
.oa-bot-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--oa-mute); font-weight: 600; }
.oa-bot-meta .oa-ic { display: inline-block; }
.oa-bot-shop.is-closed strong { color: var(--oa-ink-2); }
.oa-bot-shop > .oa-ic { color: var(--oa-faint); }

/* Products: price or "Today's rate", sizes, − qty +, Add. */
.oa-bot-item { padding: 8px 4px; }
.oa-bot-item + .oa-bot-item { border-top: 1px solid var(--oa-border); }
.oa-bot-item-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.oa-bot-item-n { font-weight: 700; font-size: 14.5px; line-height: 1.35; }
.oa-bot-item-d { display: block; font-size: 12.5px; color: var(--oa-mute); font-weight: 500; margin-top: 2px; }
.oa-bot-price { flex: 0 0 auto; font-weight: 800; font-size: 14px; color: var(--oa-lime-ink); white-space: nowrap; }
.oa-bot-price.is-rate { color: var(--oa-ink-2); font-weight: 700; }
.oa-bot-sizes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.oa-bot-sizes .oa-chip { height: 34px; padding: 0 12px; font-size: 13px; }
.oa-bot-sizes .oa-chip[disabled] { opacity: .45; cursor: not-allowed; }
.oa-bot-sizes.is-need .oa-chip { border-color: var(--oa-sale); }
.oa-bot-item-f { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.oa-bot-qty { display: inline-flex; align-items: center; border-radius: 999px; background: var(--oa-sunk); flex: 0 0 auto; }
.oa-bot-qty button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.oa-bot-qty button[disabled] { opacity: .35; cursor: default; }
.oa-bot-qty output { min-width: 26px; text-align: center; font-weight: 800; font-size: 15px; }
.oa-bot-add { flex: 1 1 auto; min-height: 44px !important; border-radius: 12px !important; }
.oa-bot-add.is-done { background: var(--oa-lime-50); color: var(--oa-lime-ink); }
.oa-bot-out { font-size: 12.5px; font-weight: 700; color: var(--oa-mute); }
.oa-bot-closed { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 2px 8px; font-size: 13px; color: var(--oa-ink-2); font-weight: 600; }

/* Details form (R7): the app's own fields. */
.oa-bot-form .oa-field { margin-bottom: 10px; gap: 4px; }
.oa-bot-form .oa-field > label { font-size: 12.5px; }
.oa-bot-form :is(.oa-input, select, textarea) { min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--oa-border-2); background-color: #fff; font-size: 16px; width: 100%; }
.oa-bot-form textarea { min-height: 70px; resize: vertical; }
.oa-bot-form .has-err :is(.oa-input, select, textarea) { border-color: var(--oa-sale); }
.oa-bot-form .oa-err { display: block; }

/* Summary (R8) and the placed order. */
.oa-bot-lines { list-style: none; margin: 0 0 6px; padding: 0; }
.oa-bot-lines li, .oa-bot-sum { display: flex; justify-content: space-between; gap: 10px; padding: 5px 2px; font-size: 14px; }
.oa-bot-lines li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.oa-bot-lines li span:last-child, .oa-bot-sum span:last-child { white-space: nowrap; font-weight: 700; }
.oa-bot-sum { border-top: 1px solid var(--oa-border); }
.oa-bot-sum.is-total { font-weight: 800; font-size: 15.5px; }
.oa-bot-sum.is-total span:last-child { font-weight: 800; }
.oa-bot-note2 { margin: 2px 2px 6px; font-size: 12.5px; color: var(--oa-mute); font-weight: 600; }
.oa-bot-to { margin: 6px 2px 10px; padding: 8px 10px; border-radius: 10px; background: var(--oa-sunk); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.oa-bot-to strong { display: block; font-size: 12px; color: var(--oa-mute); }
.oa-bot-placed { text-align: center; padding: 6px 4px 2px; }
.oa-bot-placed .oa-ic { margin: 0 auto 6px; color: var(--oa-ok); width: 34px; height: 34px; }
.oa-bot-placed h3 { margin: 0 0 4px; font-family: var(--oa-display); font-size: 17px; font-weight: 800; }
.oa-bot-placed .oa-bot-num { font-size: 15px; font-weight: 800; margin: 0 0 4px; }

/* -------------------------------------------------------------- composer */
.oa-bot-composer {
  flex: 0 0 auto; position: relative; display: flex; align-items: flex-end; gap: 6px; margin: 0;
  padding: 8px 10px; background: #fff; border-top: 1px solid var(--oa-border);
}
.oa-bot-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.oa-bot-text {
  flex: 1 1 auto; min-width: 0; min-height: 44px; max-height: 120px; margin: 0; padding: 11px 14px;
  border: 1.5px solid transparent; border-radius: 22px; background: var(--oa-sunk); color: var(--oa-ink);
  font: inherit; font-size: 16px; line-height: 20px; resize: none; outline: none; overflow-y: auto;
}
.oa-bot-text:focus { border-color: var(--oa-lime-600); background: #fff; }
.oa-bot-text::placeholder { color: var(--oa-faint); }
.oa-bot-mic, .oa-bot-send {
  flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.oa-bot-mic { background: var(--oa-sunk); color: var(--oa-ink); }
.oa-bot-mic.is-on { background: var(--oa-sale); color: #fff; animation: oa-bot-pulse 1.2s infinite; }
.oa-bot-send { background: var(--oa-lime); color: var(--oa-ink); }
.oa-bot-send:hover { background: var(--oa-lime-600); }
.oa-bot-send[disabled] { background: #E5E7E1; color: #A3A79E; cursor: default; }
@keyframes oa-bot-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(215, 38, 61, .45); } 50% { box-shadow: 0 0 0 8px rgba(215, 38, 61, 0); } }
/* KAN-49: the card sits above the tab bar and the keyboard, never on the home indicator: no safe-area padding. */
.oa-bot-note { flex: 0 0 auto; margin: 0; padding: 0 12px 8px; background: #fff; font-size: 11.5px; line-height: 16px; color: var(--oa-mute); text-align: center; }

.oa-bot .is-loading { opacity: .6; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .oa-bot-fab, .oa-bot-panel, .oa-bot-msg, .oa-bot-card, .oa-bot-mic.is-on { animation: none !important; transition: none !important; }
  .oa-bot-dots i { animation: none; opacity: .7; }
}
