/* Olympic Institute – Chat Assistant. Colours come from the theme's own tokens, so the light
   and dark modes follow the site; the fallbacks only matter on a page without the theme. */

.oi-chat {
  --oc-bg: var(--bg-elev, #ffffff);
  --oc-bg-2: var(--bg, #f2f7fb);
  --oc-text: var(--text, #0b2545);
  --oc-soft: var(--muted, #4a6786);
  --oc-line: var(--line, rgba(0, 54, 124, .14));
  --oc-brand: var(--grad-navy, linear-gradient(135deg, #00367c 0%, #0a4f9e 100%));
  --oc-brand-solid: var(--navy, #00367c);
  --oc-on-brand: #ffffff;
  --oc-bot: var(--bg-elev-2, #f8fbfe);
  --oc-user: var(--navy, #00367c);
  --oc-accent: var(--cyan-fg, #0b6788);
  --oc-shadow: 0 24px 60px -18px rgba(11, 37, 69, .45), 0 0 0 1px var(--oc-line);
  font-family: var(--font-body, 'Tajawal', 'Cairo', 'Segoe UI', Tahoma, sans-serif);
}
/* the theme lifts body-level blocks into their own layer (z-index 1), which would trap the window
   under the contact dock; the wrapper itself must not form a layer */
#oi-chat { position: static; z-index: auto; }
[data-theme="dark"] .oi-chat {
  --oc-bot: var(--bg-elev-2, #0c2c4e);
  --oc-user: #0a5ab4;
  --oc-shadow: 0 24px 60px -18px rgba(0, 0, 0, .7), 0 0 0 1px var(--oc-line);
}

/* ---------- the button ---------- */
.dock__btn--chat {
  background: var(--grad-navy, linear-gradient(135deg, #00367c 0%, #0a4f9e 100%));
  border: 0;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
[data-theme="dark"] .dock__btn--chat { background: var(--cyan, #30bef0); color: #04182f; }

.oi-chat-launcher {
  position: fixed;
  z-index: 60;
  inset-block-end: clamp(16px, 3vw, 26px);
  inset-inline-end: clamp(14px, 2.4vw, 24px);
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #00367c 0%, #0a4f9e 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .55);
}
.oi-chat-launcher svg { width: 27px; height: 27px; }
.oi-chat-launcher:focus-visible, .dock__btn--chat:focus-visible { outline: 3px solid var(--cyan, #30bef0); outline-offset: 3px; }
.oi-chat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the window: beside the dock, so WhatsApp stays in reach ---------- */
.oi-chat__panel {
  position: fixed;
  z-index: 1000;
  inset-block-end: clamp(16px, 3vw, 26px);
  inset-inline-end: calc(clamp(14px, 2.4vw, 24px) + 54px + 16px);
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 120px));
  height: min(640px, calc(100vh - 110px));
  height: min(640px, calc(100dvh - 110px));
  background: var(--oc-bg);
  color: var(--oc-text);
  border-radius: 20px;
  box-shadow: var(--oc-shadow);
  overflow: hidden;
  animation: oi-chat-in .18s ease-out;
}
.oi-chat__panel[hidden] { display: none; }
@keyframes oi-chat-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.oi-chat__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--oc-brand);
  color: var(--oc-on-brand);
}
.oi-chat__logo { width: 36px; height: 36px; border-radius: 50%; background: #fff; object-fit: contain; padding: 3px; flex: none; }
.oi-chat__titles { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.oi-chat__name { font-family: var(--font-head, 'Cairo', sans-serif); font-size: 15px; font-weight: 800; }
.oi-chat__sub { font-size: 12px; opacity: .85; }
.oi-chat__icon {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .12);
  color: inherit; cursor: pointer;
}
.oi-chat__icon svg { width: 18px; height: 18px; }
.oi-chat__icon:hover { background: rgba(255, 255, 255, .22); }
.oi-chat__icon:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.oi-chat__list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--oc-bg-2);
}
.oi-chat__msg { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.oi-chat__msg--bot { align-self: flex-start; }
.oi-chat__msg--user { align-self: flex-end; }
.oi-chat__bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.oi-chat__msg--bot .oi-chat__bubble { background: var(--oc-bot); color: var(--oc-text); border: 1px solid var(--oc-line); border-start-start-radius: 4px; }
.oi-chat__msg--user .oi-chat__bubble { background: var(--oc-user); color: #fff; border-start-end-radius: 4px; }
.oi-chat__a { color: var(--oc-accent); text-decoration: underline; text-underline-offset: 2px; }
.oi-chat__msg--user .oi-chat__a { color: #fff; }

.oi-chat__cards { display: flex; flex-direction: column; gap: 8px; }
.oi-chat__card {
  background: var(--oc-bg);
  border: 1px solid var(--oc-line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.oi-chat__card-title { font-weight: 800; color: var(--oc-text); text-decoration: none; font-size: 14px; }
.oi-chat__card-title:hover { text-decoration: underline; }
.oi-chat__card-price { color: var(--oc-accent); font-weight: 700; font-size: 13.5px; }
.oi-chat__card-meta { color: var(--oc-soft); font-size: 12.5px; }
.oi-chat__card-acts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.oi-chat__links { display: flex; flex-wrap: wrap; gap: 6px; }
.oi-chat__btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--oc-line);
  background: var(--oc-bg);
  color: var(--oc-text);
  font-size: 13px; font-weight: 700;
  text-decoration: none;
}
.oi-chat__btn:hover { border-color: var(--oc-brand-solid); }
.oi-chat__btn--primary { background: var(--oc-brand); color: #fff; border-color: transparent; }
.oi-chat__btn--wa { background: #25d366; color: #fff; border-color: transparent; }
[data-theme="dark"] .oi-chat__btn--wa { color: #04182f; }
.oi-chat__btn:focus-visible, .oi-chat__chip:focus-visible, .oi-chat__a:focus-visible { outline: 2px solid var(--cyan, #30bef0); outline-offset: 2px; }

.oi-chat__chips {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  background: var(--oc-bg-2);
  border-top: 1px solid var(--oc-line);
}
.oi-chat__chips[hidden] { display: none; }
.oi-chat__chip {
  flex: none;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--oc-brand-solid);
  background: var(--oc-bg);
  color: var(--oc-brand-solid);
  font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
[data-theme="dark"] .oi-chat__chip { color: var(--cyan-fg, #6fd3f7); border-color: var(--cyan-fg, #6fd3f7); }
.oi-chat__chip:hover { background: var(--oc-brand-solid); color: #fff; }

.oi-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 6px;
  background: var(--oc-bg);
  border-top: 1px solid var(--oc-line);
}
.oi-chat__input {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--oc-line);
  border-radius: 12px;
  background: var(--oc-bg-2);
  color: var(--oc-text);
  font: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming in */
  line-height: 1.4;
}
.oi-chat__input:focus { outline: 2px solid var(--oc-brand-solid); outline-offset: 0; border-color: transparent; }
.oi-chat__hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; opacity: 0; }
.oi-chat__send {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border: 0; border-radius: 12px;
  background: var(--oc-brand);
  color: #fff; cursor: pointer;
}
[dir="rtl"] .oi-chat__send svg { transform: scaleX(-1); }
.oi-chat__send svg { width: 20px; height: 20px; }
.oi-chat__send:focus-visible { outline: 2px solid var(--cyan, #30bef0); outline-offset: 2px; }
.oi-chat__note { margin: 0; padding: 2px 12px 8px; font-size: 11px; color: var(--oc-soft); background: var(--oc-bg); }

.oi-chat__typing .oi-chat__bubble { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.oi-chat__typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--oc-soft); animation: oi-chat-dot 1s infinite ease-in-out; }
.oi-chat__typing span:nth-child(2) { animation-delay: .15s; }
.oi-chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes oi-chat-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- phones: the window takes the whole screen ---------- */
@media (max-width: 600px) {
  .oi-chat__panel {
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  html.oi-chat-locked, html.oi-chat-locked body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .oi-chat__panel { animation: none; }
  .oi-chat__typing span { animation: none; opacity: .7; }
}
@media print { .oi-chat, .oi-chat-launcher, .dock__btn--chat { display: none !important; } }
