/* AI agents demo portal — neutral, modern, blue-accented.
   Logical properties only (margin-inline, inset-inline, text-align: start):
   the page flips to RTL for Arabic and a physical left/right would strand
   elements on the wrong side. */

:root {
  --ap-blue: #1E40AF;
  --ap-blue-600: #2563EB;
  --ap-blue-50: #EEF3FF;
  --ap-blue-100: #DBE6FE;
  --ap-ink: #0F172A;
  --ap-ink-2: #334155;
  --ap-muted: #64748B;
  --ap-line: #E2E8F0;
  --ap-bg: #F5F7FB;
  --ap-card: #FFFFFF;
  --ap-sun: #B45309;
  --ap-sun-bg: #FFF7E6;
  --ap-mint: #047857;
  --ap-mint-bg: #E9F9F2;
  --ap-rose: #E11D48;
  --ap-violet: #6D28D9;
  --ap-teal: #0F766E;
  --ap-amber: #B45309;
  --ap-radius: 16px;
  --ap-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --ap-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

[dir="rtl"] { --ap-font: "IBM Plex Sans Arabic", "Plus Jakarta Sans", system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ap-font);
  color: var(--ap-ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(37, 99, 235, .08), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(30, 64, 175, .06), transparent 60%),
    var(--ap-bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.ap-sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[dir="rtl"] .ap-flip { display: inline-block; transform: scaleX(-1); }

.ap-app { min-block-size: 100dvh; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- header */
.ap-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  block-size: 56px; padding-inline: 20px; flex: none;
  background: rgba(255, 255, 255, .8); backdrop-filter: blur(8px);
  border-block-end: 1px solid var(--ap-line);
}
.ap-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-inline-size: 0; }
.ap-brand-mark { display: grid; grid-template-columns: repeat(3, 6px); gap: 3px; align-items: end; padding: 7px; border-radius: 10px; background: var(--ap-blue); }
.ap-brand-mark span { display: block; inline-size: 6px; background: #fff; border-radius: 3px; }
.ap-brand-mark span:nth-child(1) { block-size: 8px; opacity: .7; }
.ap-brand-mark span:nth-child(2) { block-size: 14px; }
.ap-brand-mark span:nth-child(3) { block-size: 10px; opacity: .85; }
.ap-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-inline-size: 0; }
.ap-brand-text strong { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.ap-brand-text small { color: var(--ap-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-header-actions { display: flex; align-items: center; gap: 10px; }
.ap-fiction {
  font-size: 12px; color: var(--ap-muted); border: 1px dashed #CBD5E1; border-radius: 999px;
  padding: 3px 10px; white-space: nowrap;
}
.ap-lang {
  display: inline-flex; border: 1px solid var(--ap-line); border-radius: 999px; padding: 2px; background: #fff;
}
.ap-lang span { padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ap-muted); }
html[lang="en"] .ap-lang span[lang="en"], html[lang="ar"] .ap-lang span[lang="ar"] { background: var(--ap-blue); color: #fff; }

/* ---------------------------------------------------------------- picker */
.ap-picker { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 20px 24px; max-inline-size: 1180px; margin-inline: auto; inline-size: 100%; }
.ap-hero { text-align: center; margin-block-end: 22px; }
.ap-hero h1 { font-size: clamp(24px, 3.2vw, 36px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 8px; font-weight: 800; }
.ap-hero p { margin: 0 auto; max-inline-size: 640px; color: var(--ap-ink-2); }
.ap-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.ap-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; text-align: start;
  text-decoration: none; color: inherit;
  background: var(--ap-card); border: 1px solid var(--ap-line); border-radius: var(--ap-radius);
  padding: 18px; box-shadow: var(--ap-shadow); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.ap-card:hover, .ap-card:focus-visible { transform: translateY(-3px); border-color: var(--ap-blue-100); box-shadow: 0 12px 32px rgba(30, 64, 175, .14); outline: none; }
.ap-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ap-card-avatar { font-size: 26px; inline-size: 52px; block-size: 52px; border-radius: 14px; display: grid; place-items: center; }
.ap-card h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.ap-card-role { color: var(--ap-muted); font-size: 13px; margin: -6px 0 0; }
.ap-card-line { margin: 0; color: var(--ap-ink-2); flex: 1; }
.ap-card-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--ap-muted); }
.ap-card-meta span { background: var(--ap-bg); border-radius: 999px; padding: 3px 9px; }
.ap-card-go { display: inline-flex; align-items: center; gap: 6px; color: var(--ap-blue); font-weight: 700; font-size: 14px; }
.ap-howto { list-style: none; margin: 22px auto 0; padding: 0; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.ap-howto-step { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--ap-line); border-radius: 999px; padding: 6px 14px 6px 6px; font-size: 13.5px; color: var(--ap-ink-2); }
[dir="rtl"] .ap-howto-step { padding: 6px 6px 6px 14px; }
.ap-howto-n { inline-size: 24px; block-size: 24px; border-radius: 50%; background: var(--ap-blue); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.ap-howto-emoji { font-size: 16px; }
.ap-picker-note { text-align: center; color: var(--ap-muted); font-size: 12px; margin-block-start: 18px; }

/* agent colour themes */
.ap-t-support { --ap-tone: var(--ap-blue); --ap-tone-bg: #DFE8FF; }
.ap-t-inquiries { --ap-tone: var(--ap-violet); --ap-tone-bg: #ECE3FF; }
.ap-t-collection { --ap-tone: var(--ap-amber); --ap-tone-bg: #FFEBCF; }
.ap-t-sales { --ap-tone: var(--ap-teal); --ap-tone-bg: #D6F3EE; }
.ap-card-avatar, .ap-avatar { background: var(--ap-tone-bg); color: var(--ap-tone); }

.ap-dir {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; background: var(--ap-tone-bg); color: var(--ap-tone); white-space: nowrap;
}

/* ------------------------------------------------------------- workspace */
.ap-workspace { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px 20px 16px; min-block-size: 0; max-inline-size: 1440px; margin-inline: auto; inline-size: 100%; }
.ap-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ap-back {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ap-line); background: #fff;
  border-radius: 10px; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--ap-ink-2);
}
.ap-back:hover { border-color: var(--ap-blue-100); color: var(--ap-blue); }
.ap-agent-id { display: flex; align-items: center; gap: 10px; min-inline-size: 0; flex: 1; }
.ap-avatar { inline-size: 38px; block-size: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; flex: none; }
.ap-agent-text { display: flex; flex-direction: column; line-height: 1.2; min-inline-size: 0; }
.ap-agent-text strong { font-size: 16px; }
.ap-agent-text small { color: var(--ap-muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-stepper { display: flex; align-items: center; gap: 6px; min-inline-size: 0; }
.ap-step {
  inline-size: 36px; block-size: 36px; border-radius: 10px; border: 1px solid var(--ap-line); background: #fff;
  font-size: 20px; line-height: 1; display: grid; place-items: center; color: var(--ap-ink-2);
}
.ap-step:hover:not(:disabled) { color: var(--ap-blue); border-color: var(--ap-blue-100); }
.ap-step:disabled { opacity: .4; cursor: default; }
.ap-case-select {
  block-size: 36px; border-radius: 10px; border: 1px solid var(--ap-line); background: #fff;
  padding-inline: 10px; max-inline-size: 340px; min-inline-size: 180px; font-weight: 600; font-size: 13.5px;
}

.ap-row { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 16px; flex: 1; min-block-size: 0; }

/* story card */
.ap-story {
  background: var(--ap-card); border: 1px solid var(--ap-line); border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow); display: flex; flex-direction: column; min-block-size: 0; overflow: hidden;
}
.ap-story-summary {
  list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: linear-gradient(135deg, var(--ap-tone-bg), #fff 70%); border-block-end: 1px solid var(--ap-line);
  cursor: default;
}
.ap-story-summary::-webkit-details-marker { display: none; }
.ap-story-emoji { font-size: 30px; inline-size: 48px; block-size: 48px; display: grid; place-items: center; background: #fff; border-radius: 14px; box-shadow: var(--ap-shadow); flex: none; }
.ap-story-headline { font-size: 18.5px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; flex: 1; }
.ap-story-toggle { display: none; }
.ap-story-body { padding: 12px 18px 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px; min-block-size: 0; }
.ap-story-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 14px; }
.ap-block h3 { margin: 0 0 3px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ap-muted); font-weight: 700; display: flex; align-items: baseline; gap: 6px; }
[dir="rtl"] .ap-block h3 { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.ap-block h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ap-muted); }
.ap-block p { margin: 0; color: var(--ap-ink-2); }
.ap-goal p { color: var(--ap-ink); font-weight: 600; }
.ap-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ap-chip {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 9px;
  background: var(--ap-bg); border: 1px solid var(--ap-line); font-size: 12.5px;
}
.ap-chip-k { color: var(--ap-muted); }
.ap-chip-v { font-weight: 700; color: var(--ap-ink); font-variant-numeric: tabular-nums; }
.ap-say-list { display: flex; flex-direction: column; gap: 6px; }
.ap-say-btn {
  text-align: start; border: 1px solid var(--ap-blue-100); background: var(--ap-blue-50); color: var(--ap-blue);
  border-radius: 12px; padding: 7px 12px; font-size: 13.5px; font-weight: 600; line-height: 1.35;
  display: flex; gap: 8px; align-items: flex-start; transition: background .12s ease, transform .12s ease;
}
.ap-say-btn::before { content: "“"; font-size: 18px; line-height: 1; opacity: .5; }
[dir="rtl"] .ap-say-btn::before { content: "”"; }
.ap-say-btn:hover { background: var(--ap-blue-100); }
.ap-say-btn:active { transform: scale(.99); }
.ap-say-btn.is-used { opacity: .55; }
.ap-twist { background: var(--ap-sun-bg); border-radius: 12px; padding: 8px 12px; }
.ap-twist h3 { color: var(--ap-sun); }
.ap-twist p { color: #7C2D12; }
.ap-great { background: var(--ap-mint-bg); border-radius: 12px; padding: 7px 12px; }
.ap-great summary { cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--ap-mint); }
.ap-great p { margin: 6px 0 2px; color: #065F46; font-size: 13.5px; }

.ap-fine { margin: 2px 0 0; font-size: 11.5px; color: #94A3B8; }

/* call panel */
.ap-call {
  background: var(--ap-card); border: 1px solid var(--ap-line); border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow); display: flex; flex-direction: column; min-block-size: 0; overflow: hidden;
}
.ap-call-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-block-end: 1px solid var(--ap-line); }
.ap-modes { display: inline-flex; background: var(--ap-bg); border-radius: 11px; padding: 3px; gap: 2px; }
.ap-modes button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--ap-muted); }
.ap-modes button[aria-selected="true"] { background: #fff; color: var(--ap-blue); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.ap-modes button:disabled { opacity: .45; cursor: not-allowed; }
.ap-accent select { border: 1px solid var(--ap-line); border-radius: 9px; background: #fff; padding: 5px 8px; font-size: 12.5px; }
.ap-status { margin-inline-start: auto; font-size: 12.5px; color: var(--ap-muted); display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ap-status[data-live="1"]::before { content: ""; inline-size: 8px; block-size: 8px; border-radius: 50%; background: #16A34A; box-shadow: 0 0 0 4px rgba(22, 163, 74, .18); }
.ap-status[data-ring="1"]::before { content: ""; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--ap-blue-600); animation: ap-pulse 1s ease-in-out infinite; }

.ap-log { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-block-size: 0; background: linear-gradient(#fff, #FBFCFE); }
.ap-empty { margin: auto; text-align: center; color: var(--ap-muted); max-inline-size: 340px; }
.ap-empty-emoji { font-size: 34px; display: block; margin-block-end: 6px; }
.ap-empty p { margin: 0; }
.ap-msg { max-inline-size: 86%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.ap-msg-user { align-self: flex-end; background: var(--ap-blue); color: #fff; border-end-end-radius: 6px; }
.ap-msg-agent { align-self: flex-start; background: var(--ap-bg); border: 1px solid var(--ap-line); border-end-start-radius: 6px; }
.ap-msg-system { align-self: center; font-size: 12.5px; color: var(--ap-muted); background: transparent; padding: 2px 8px; }
.ap-msg-who { display: block; font-size: 11px; font-weight: 700; opacity: .7; margin-block-end: 2px; }
.ap-tools { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 5px; margin-block: -2px 2px; }
.ap-tool { font-size: 11px; color: var(--ap-teal); background: #E7F7F5; border-radius: 999px; padding: 2px 8px; font-weight: 600; }
.ap-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.ap-typing i { inline-size: 6px; block-size: 6px; border-radius: 50%; background: #94A3B8; animation: ap-dot 1.2s infinite ease-in-out; }
.ap-typing i:nth-child(2) { animation-delay: .15s; }
.ap-typing i:nth-child(3) { animation-delay: .3s; }

.ap-dock { border-block-start: 1px solid var(--ap-line); padding: 12px 14px; background: #fff; }
.ap-voice-controls { display: flex; align-items: center; justify-content: center; gap: 18px; }
.ap-ctl {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid var(--ap-line);
  background: #fff; border-radius: 14px; padding: 7px 14px; font-size: 11.5px; font-weight: 600; color: var(--ap-ink-2); min-inline-size: 64px;
}
.ap-ctl span[aria-hidden] { font-size: 17px; }
.ap-ctl:disabled { opacity: .4; cursor: default; }
.ap-ctl[aria-pressed="true"] { background: #FEF2F2; border-color: #FECACA; color: var(--ap-rose); }
.ap-end:not(:disabled):hover { border-color: #FECACA; color: var(--ap-rose); }
.ap-callbtn {
  display: inline-flex; align-items: center; gap: 10px; border: 0; border-radius: 999px; padding: 12px 26px 12px 18px;
  background: linear-gradient(135deg, var(--ap-blue-600), var(--ap-blue)); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 10px 24px rgba(30, 64, 175, .32); transition: transform .12s ease, box-shadow .12s ease;
}
[dir="rtl"] .ap-callbtn { padding: 12px 18px 12px 26px; }
.ap-callbtn:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(30, 64, 175, .38); }
.ap-callbtn-icon { inline-size: 34px; block-size: 34px; border-radius: 50%; background: rgba(255, 255, 255, .18); display: grid; place-items: center; font-size: 18px; }
.ap-callbtn[data-state="ringing"] .ap-callbtn-icon { animation: ap-ring .9s ease-in-out infinite; }
.ap-callbtn[data-state="live"] { background: linear-gradient(135deg, #F43F5E, #BE123C); box-shadow: 0 10px 24px rgba(225, 29, 72, .3); }
.ap-callbtn:disabled { opacity: .55; cursor: not-allowed; }

.ap-composer { display: flex; gap: 8px; align-items: center; }
.ap-composer input {
  flex: 1; min-inline-size: 0; border: 1px solid var(--ap-line); border-radius: 12px; padding: 11px 14px; background: var(--ap-bg);
}
.ap-composer input:focus { outline: 2px solid var(--ap-blue-100); border-color: var(--ap-blue-600); background: #fff; }
.ap-send { border: 0; border-radius: 12px; background: var(--ap-blue); color: #fff; font-weight: 700; padding: 11px 18px; }
.ap-send:disabled { opacity: .5; cursor: default; }
.ap-newchat { min-inline-size: 44px; padding: 8px; }

@keyframes ap-pulse { 50% { opacity: .35; } }
@keyframes ap-dot { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
@keyframes ap-ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }

/* ----------------------------------------------- desktop: one row, no page scroll */
@media (min-width: 900px) and (min-height: 600px) {
  .ap-app.is-workspace { block-size: 100dvh; overflow: hidden; }
  .ap-row { min-block-size: 0; }
}

/* compact laptop heights (1366×768 and below) */
@media (min-width: 900px) and (max-height: 820px) {
  body { font-size: 14px; }
  .ap-header { block-size: 50px; }
  .ap-workspace { padding-block: 10px 12px; gap: 10px; }
  .ap-story-summary { padding: 10px 16px; }
  .ap-story-emoji { inline-size: 42px; block-size: 42px; font-size: 26px; }
  .ap-story-headline { font-size: 17px; }
  .ap-story-body { padding: 10px 16px 12px; gap: 8px; }
  .ap-say-btn { padding: 6px 11px; font-size: 13px; }
  .ap-msg { font-size: 14px; }
}

/* tablets: picker in two columns */
@media (max-width: 1100px) {
  .ap-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ----------------------------------------------- mobile: stack, sticky call bar */
@media (max-width: 899px) {
  .ap-header { padding-inline: 16px; }
  .ap-fiction { display: none; }
  .ap-workspace { padding: 10px 16px 0; }
  .ap-bar { gap: 8px; }
  .ap-agent-id { order: -1; flex-basis: calc(100% - 120px); }
  .ap-stepper { inline-size: 100%; }
  .ap-case-select { flex: 1; max-inline-size: none; min-inline-size: 0; }
  .ap-row { display: flex; flex-direction: column; gap: 12px; }
  .ap-story-summary { cursor: pointer; }
  .ap-story-toggle { display: block; inline-size: 10px; block-size: 10px; border-inline-end: 2px solid var(--ap-muted); border-block-end: 2px solid var(--ap-muted); transform: rotate(45deg); transition: transform .15s; margin-inline-end: 4px; }
  .ap-story[open] .ap-story-toggle { transform: rotate(-135deg); }
  .ap-story-grid { grid-template-columns: 1fr; gap: 8px; }
  .ap-call { overflow: visible; margin-block-end: 96px; }
  .ap-log { min-block-size: 200px; overflow: visible; }
  /* The call bar is pinned to the viewport so the call button / composer is
     always one tap away, whatever is scrolled into view above it. */
  .ap-dock {
    position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 20;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, .12); border-block-start: 1px solid var(--ap-line);
    padding-block-end: calc(12px + env(safe-area-inset-bottom));
  }
  .ap-voice-controls { gap: 10px; }
  .ap-callbtn { padding: 10px 20px 10px 14px; font-size: 15px; }
  .ap-cards { grid-template-columns: 1fr; }
  .ap-picker { padding: 20px 16px; }
}
