/* نافذة دردشة OTO (web/widget/widget.js) — ما يراه زائر موقع المحل أو تطبيقه.
   OTO's chat window as a visitor sees it on a business's website or app; the
   builder's live preview draws the same. Its own light look on purpose: it
   sits on the business's site, not inside OTO Desk. Every rule is scoped
   under .otw so a website's own styles and these never meet. */
.otw {
  --otw-c: #008080; --otw-ink: #ffffff;
  --otw-bg: #ffffff; --otw-bg2: #f3f6f8; --otw-text: #182830; --otw-muted: #56656f;
  --otw-line: rgba(24, 40, 48, .13);
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  font-family: var(--otw-font, inherit); font-size: 14px; line-height: 1.5; color: var(--otw-text);
  color-scheme: light;
}
/* the side of the screen is physical, whatever the page's direction */
.otw > .otw-win, .otw > .otw-launcher { margin-left: 0; margin-right: 0; }
.otw.side-right > .otw-win, .otw.side-right > .otw-launcher { margin-left: auto; }
.otw.side-left > .otw-win, .otw.side-left > .otw-launcher { margin-right: auto; }
.otw *, .otw *::before, .otw *::after { box-sizing: border-box; }

.otw-win {
  width: 360px; max-width: 100%; height: 540px; max-height: 78vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--otw-bg); border: 1px solid var(--otw-line); border-radius: 18px;
  box-shadow: 0 14px 40px rgba(24, 40, 48, .2), 0 2px 6px rgba(24, 40, 48, .1);
}
.otw-win[hidden] { display: none; }

.otw-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--otw-c); color: var(--otw-ink); }
.otw-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.otw-who b { font-size: 15px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.otw-who small { font-size: 12px; opacity: .88; }
.otw-av {
  width: 38px; height: 38px; flex: none; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
  background: rgba(255, 255, 255, .22); color: inherit;
}
.otw-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.otw-av.sm { width: 26px; height: 26px; font-size: 12px; background: var(--otw-c); color: var(--otw-ink); }
.otw-icon {
  width: 32px; height: 32px; flex: none; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: inherit; font: inherit; font-size: 20px; line-height: 1;
}
.otw-icon:hover { background: rgba(255, 255, 255, .18); }

.otw-log { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--otw-bg2); }
.otw-row { display: flex; align-items: flex-end; gap: 6px; }
.otw-row.me { justify-content: flex-end; }
.otw-bubble {
  max-width: 82%; padding: 8px 12px; border-radius: 14px;
  background: var(--otw-bg); border: 1px solid var(--otw-line);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.otw-row.bot .otw-bubble { border-end-start-radius: 4px; }
.otw-row.me .otw-bubble { background: var(--otw-c); color: var(--otw-ink); border-color: transparent; border-end-end-radius: 4px; }
.otw-bubble.muted { color: var(--otw-muted); }
.otw-bubble.form { width: 82%; white-space: normal; }
.otw-note {
  align-self: center; max-width: 92%; padding: 4px 10px; border: 1px dashed var(--otw-line); border-radius: 10px;
  font-size: 12px; color: var(--otw-muted); text-align: center;
}
.otw-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-inline-start: 32px; }
.otw-chip {
  padding: 6px 12px; border: 1px solid var(--otw-c); border-radius: 999px; cursor: pointer;
  background: var(--otw-bg); color: var(--otw-c); font: inherit; font-size: 13px; font-weight: 600; text-align: start;
}
.otw-chip:hover { background: var(--otw-c); color: var(--otw-ink); }
.otw-chip.ghost { border-color: var(--otw-line); color: var(--otw-muted); font-weight: 500; }
.otw-chip.ghost:hover { background: var(--otw-bg2); color: var(--otw-text); }
.otw-link {
  display: flex; flex-direction: column; margin-top: 8px; padding: 8px 10px; border-radius: 10px;
  background: var(--otw-bg2); color: var(--otw-c); font-weight: 600; text-decoration: none; white-space: normal;
}
.otw-link small { color: var(--otw-muted); font-weight: 400; }

.otw-typing { display: inline-flex; align-items: center; gap: 4px; padding: 11px 12px; }
.otw-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--otw-muted); animation: otw-blink 1s infinite ease-in-out; }
.otw-typing i:nth-child(2) { animation-delay: .15s; }
.otw-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes otw-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.otw-foot { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--otw-line); background: var(--otw-bg); }
.otw-foot.hint { justify-content: center; font-size: 12.5px; color: var(--otw-muted); }
.otw-input {
  flex: 1; min-width: 0; padding: 9px 14px; border: 1px solid var(--otw-line); border-radius: 999px;
  background: var(--otw-bg); color: var(--otw-text); font: inherit;
}
.otw-input:focus { outline: none; border-color: var(--otw-c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--otw-c) 18%, transparent); }
.otw-send {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; background: var(--otw-c); color: var(--otw-ink);
}
.otw-send-ic { width: 16px; height: 16px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%, 0 60%, 60% 50%, 0 40%); }
[dir=rtl] .otw-send-ic { transform: scaleX(-1); }
.otw-send[disabled], .otw-input[disabled] { opacity: .55; cursor: default; }

.otw-form { display: flex; flex-direction: column; gap: 8px; }
.otw-field { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--otw-muted); }
.otw-field b { color: #b42318; }
.otw-field input, .otw-field textarea {
  padding: 7px 9px; border: 1px solid var(--otw-line); border-radius: 8px;
  background: var(--otw-bg); color: var(--otw-text); font: inherit; resize: vertical;
}
.otw-field input:focus, .otw-field textarea:focus { outline: none; border-color: var(--otw-c); }
.otw-submit {
  align-self: flex-start; padding: 7px 16px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--otw-c); color: var(--otw-ink); font: inherit; font-weight: 600;
}
.otw-submit[disabled] { opacity: .55; cursor: default; }
.otw-err { margin: 0; font-size: 12px; color: #b42318; }
.otw-err:empty { display: none; }

.otw-launcher {
  width: 56px; height: 56px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; background: var(--otw-c); color: var(--otw-ink);
  box-shadow: 0 6px 18px rgba(24, 40, 48, .25);
}
.otw-dots { width: 24px; height: 19px; border-radius: 10px 10px 10px 3px; background: currentColor; }
[dir=rtl] .otw-dots { border-radius: 10px 10px 3px 10px; }
.otw-x { position: relative; width: 18px; height: 18px; }
.otw-x::before, .otw-x::after { content: ''; position: absolute; left: 0; right: 0; top: 8px; height: 2px; border-radius: 1px; background: currentColor; transform: rotate(45deg); }
.otw-x::after { transform: rotate(-45deg); }

.otw-icon:focus-visible, .otw-chip:focus-visible, .otw-send:focus-visible, .otw-submit:focus-visible,
.otw-launcher:focus-visible, .otw-link:focus-visible { outline: 2px solid var(--otw-c); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .otw-typing i { animation: none; opacity: .6; } }

/* a message from the business's team (step 3: the public chat) */
.otw-team-who { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 700; color: var(--otw-c); }

/* the window filling its frame: the public chat page, in a website's frame or opened as a link */
.otw.fill { display: block; width: 100%; height: 100%; }
.otw.fill > .otw-win {
  width: 100%; max-width: none; height: 100%; max-height: none;
  border: 0; border-radius: 0; box-shadow: none;
}

/* chat.964-tech.com/w/<id>: the page around it */
body.otw-page {
  margin: 0; background: #e9eef1;
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", sans-serif;
}
body.otw-page #otw-host { position: fixed; inset: 0; }
body.otw-page.embed { background: #ffffff; }
/* opened as a plain link on a wide screen: one column in the middle, not a stretched window */
@media (min-width: 640px) {
  body.otw-page:not(.embed) #otw-host { inset: 24px auto 24px 50%; width: 440px; transform: translateX(-50%); }
  body.otw-page:not(.embed) .otw.fill > .otw-win {
    border: 1px solid var(--otw-line); border-radius: 18px;
    box-shadow: 0 14px 40px rgba(24, 40, 48, .18), 0 2px 6px rgba(24, 40, 48, .08);
  }
}
.otw-gone {
  display: grid; place-items: center; height: 100%; padding: 24px; text-align: center;
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; color: #56656f;
}
