/* ===========================================================================
   Live Interpreter — custom CCP demo screen
   LiveUCX / ProUCX dark brand.  Self-contained, no external network assets.
   Tokens mirror the Live AI Agent demo screen (../../demo-screen/styles.css) so
   the two founder demos read as one product.
   =========================================================================== */

:root {
  /* Brand */
  --bg:            #060B22;   /* ProUCX dark navy */
  --bg-2:          #0A1233;   /* raised navy */
  --surface:       #0E1740;   /* card surface */
  --surface-2:     #131E52;   /* caller bubble */
  --line:          rgba(255,255,255,.10);
  --line-strong:   rgba(255,255,255,.18);

  --ink:           #EAF0FF;   /* primary text */
  --muted:         #9AA6C8;   /* secondary text */
  --faint:         #667099;   /* tertiary / timestamps */

  --cyan:          #1BD7E7;   /* accent */
  --blue:          #1B81E7;   /* primary */
  --ok:            #34D399;
  --live:          #FF4D6D;   /* live-call red pulse */

  --radius:        16px;
  --radius-lg:     22px;
  --shadow-card:   0 18px 50px rgba(0,0,0,.45);
  --shadow-glow:   0 0 0 1px rgba(27,215,231,.25), 0 10px 40px rgba(27,129,231,.20);

  --maxw:          1320px;
  --ccp-w:         320px;      /* Amazon Connect Streams CCP native width */

  --font: "Roboto", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  /* Urdu / Arabic-script stack — system fonts so the page renders correctly
     offline at a live demo (Windows: Urdu Typesetting / Segoe UI; macOS+iOS:
     Geeza Pro / Noto Nastaliq; Android+Linux: Noto Naskh/Nastaliq). */
  --font-ur: "Noto Nastaliq Urdu", "Urdu Typesetting", "Jameel Noori Nastaleeq",
             "Noto Naskh Arabic", "Geeza Pro", "Segoe UI", "Tahoma", "Arial", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background:
    radial-gradient(1200px 700px at 82% -10%, rgba(27,129,231,.16), transparent 60%),
    radial-gradient(900px 600px at 0% 110%, rgba(27,215,231,.12), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;                 /* only the transcript scrolls */
}

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

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 30;
  background: var(--blue); color: #fff; padding: 10px 16px;
  border-radius: 10px; text-decoration: none; font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ─────────────────────────── App shell ─────────────────────────── */
.app {
  height: 100dvh;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(14px, 2.2vw, 26px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(12px, 1.4vw, 18px);
}

/* ─────────────────────────── Header ─────────────────────────── */
.app__header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
  padding: clamp(12px, 1.3vw, 16px) clamp(16px, 1.8vw, 22px);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__logo { display: block; height: 30px; width: auto; }
.brand__sep { width: 1px; height: 26px; background: var(--line-strong); }
.brand__title {
  min-width: 0;
}
.brand__name {
  font-weight: 700; font-size: clamp(1rem, 1.4vw, 1.24rem); letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand__kicker {
  color: var(--muted); font-size: clamp(.68rem, .95vw, .78rem);
  letter-spacing: .4px; text-transform: uppercase; margin-top: 1px;
}

.header__mid { min-width: 0; }

/* Call-state pill (identical idiom to the AI-agent demo screen) */
.callstate {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 16px 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.04);
  font-weight: 600; font-size: .9rem; white-space: nowrap;
  transition: background .3s ease, border-color .3s ease, color .3s ease;
}
.callstate__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 0 rgba(255,77,109,0);
}
.callstate[data-state="live"]  { color: #fff; border-color: rgba(255,77,109,.5); background: rgba(255,77,109,.12); }
.callstate[data-state="live"] .callstate__dot { background: var(--live); animation: pulse 1.6s ease-out infinite; }
.callstate[data-state="ended"] { color: var(--muted); border-color: var(--line-strong); }
.callstate[data-state="ended"] .callstate__dot { background: var(--muted); }
.callstate[data-state="idle"] .callstate__dot { background: var(--faint); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,77,109,.55); }
  70%  { box-shadow: 0 0 0 12px rgba(255,77,109,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,77,109,0); }
}

/* ─────────────────────────── Workspace (two panes) ─────────────────────────── */
.workspace {
  min-height: 0;                    /* let children own the scroll */
  display: grid;
  grid-template-columns: var(--ccp-w) minmax(0, 1fr);
  gap: clamp(12px, 1.4vw, 18px);
}

/* ─────────────────────────── Left pane — the CCP ─────────────────────────── */
.ccp {
  min-height: 0;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012)),
    var(--bg-2);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.ccp__head {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.ccp__head .bi { color: var(--cyan); display: inline-flex; }
.ccp__title { font-weight: 700; font-size: .82rem; letter-spacing: .5px; text-transform: uppercase; }

/* The mount area: #ccp-container is a CLEAN, EMPTY element for Streams initCCP.
   The placeholder is a SIBLING layered behind it, so the container has zero
   child nodes until the CCP iframe is injected — a pristine mount point. */
.ccp__mount { position: relative; flex: 1; min-height: 0; }
#ccp-container {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  background: transparent;          /* placeholder shows through until iframe mounts */
}
#ccp-container iframe { width: 100%; height: 100%; border: 0; display: block; }

.ccp__placeholder {
  position: absolute; inset: 0; z-index: 0;   /* behind the mount; opaque CCP iframe covers it */
  pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 12px; padding: 24px;
}
.ccp__placeholder.is-hidden { display: none; }
.ccp__ph-icon {
  width: 66px; height: 66px; border-radius: 18px;
  display: grid; place-items: center;
  color: var(--cyan);
  background: linear-gradient(135deg, rgba(27,215,231,.16), rgba(27,129,231,.20));
  border: 1px solid rgba(27,215,231,.35);
  box-shadow: var(--shadow-glow);
}
.ccp__ph-icon svg { width: 30px; height: 30px; }
.ccp__ph-title { font-weight: 700; font-size: 1.02rem; }
.ccp__ph-sub { color: var(--muted); font-size: .82rem; max-width: 24ch; margin: 0; }

/* ─────────────────────────── Right pane — the transcript (hero) ─────────────────────────── */
.panel {
  min-height: 0;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012)),
    var(--bg-2);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.panel__head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px clamp(14px, 1.8vw, 22px);
  border-bottom: 1px solid var(--line);
}
.panel__title { font-weight: 700; font-size: 1rem; letter-spacing: .2px; }
.panel__head-spacer { flex: 1 1 24px; }

/* Language-pair badge (UR ⇄ EN) */
.langpair {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid rgba(27,215,231,.35);
  background: rgba(27,215,231,.10);
  font-weight: 700; font-size: .8rem; letter-spacing: .6px;
  color: #DFFAFE;
}
.langpair__swap { color: var(--cyan); font-size: .95rem; line-height: 1; }

/* Legend — what's original vs translation */
.legend { display: inline-flex; align-items: center; gap: 14px; font-size: .74rem; color: var(--muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__dot { width: 9px; height: 9px; border-radius: 50%; }
.legend__dot--src { background: var(--ink); }
.legend__dot--dst { background: var(--faint); }

/* Stage — holds the empty state + the scrolling transcript */
.stage { position: relative; flex: 1; min-height: 0; }

.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 8px;
  transition: opacity .4s ease;
}
.empty.is-hidden { opacity: 0; pointer-events: none; }
.empty__pulse { display: flex; align-items: center; gap: 10px; height: 46px; }
.empty__pulse span {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  animation: bob 1.4s ease-in-out infinite; opacity: .9;
}
.empty__pulse span:nth-child(2) { animation-delay: .18s; }
.empty__pulse span:nth-child(3) { animation-delay: .36s; }
@keyframes bob {
  0%, 100% { transform: translateY(6px) scale(.85); opacity: .5; }
  50%      { transform: translateY(-6px) scale(1);  opacity: 1;  }
}
.empty__title { margin: 8px 0 0; font-size: clamp(1.2rem, 2vw, 1.7rem); font-weight: 700; letter-spacing: .2px; }
.empty__sub { margin: 0; color: var(--muted); max-width: 44ch; }

/* Transcript — the scrolling turn column */
.transcript {
  list-style: none; margin: 0;
  padding: clamp(16px, 2.2vw, 28px) clamp(14px, 2vw, 28px) clamp(20px, 2.6vw, 34px);
  height: 100%;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.transcript[aria-hidden="true"] { display: none; }
.transcript::-webkit-scrollbar { width: 10px; }
.transcript::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;
}

/* A turn */
.turn {
  display: flex; flex-direction: column;
  max-width: min(82%, 720px);
  animation: rise .35s cubic-bezier(.2,.7,.3,1) both;
}
.turn--caller { align-self: flex-start; align-items: flex-start; }
.turn--agent  { align-self: flex-end;   align-items: flex-end; }

.turn__meta {
  display: flex; align-items: center; gap: 8px;
  font-size: .72rem; color: var(--faint); margin: 0 4px 5px;
}
.turn__who { font-weight: 700; letter-spacing: .3px; text-transform: uppercase; font-size: .66rem; }
.turn--caller .turn__who { color: var(--muted); }
.turn--agent  .turn__who { color: var(--cyan); }

.bubble {
  padding: 12px 16px 13px;
  border-radius: 18px;
  border: 1px solid var(--line);
  width: 100%;
}
.turn--caller .bubble {
  background: var(--surface-2);
  border-bottom-left-radius: 6px;
}
.turn--agent .bubble {
  background: linear-gradient(135deg, rgba(27,215,231,.16), rgba(27,129,231,.20));
  border-color: rgba(27,215,231,.35);
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-glow);
}

/* Source (original) — prominent */
.turn__src {
  margin: 0;
  font-size: clamp(1rem, 1.25vw, 1.12rem);
  line-height: 1.5;
  color: #F4F8FF;
  word-wrap: break-word; overflow-wrap: anywhere;
}
/* Urdu / Arabic-script rendering — RTL, roomier leading for legibility */
[lang="ur"] {
  font-family: var(--font-ur);
  direction: rtl;
  line-height: 1.9;
  font-size: 1.14em;                /* Arabic script reads smaller at same px */
}
.turn__src[lang="ur"] { text-align: right; }

/* Translation (what the other side heard) — de-emphasised, divider above */
.turn__dst {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line-strong);
}
.turn__dst-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .64rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}
.turn__dst-tag svg { width: 13px; height: 13px; opacity: .85; }
.turn__dst-text {
  margin: 0;
  font-size: .95rem; line-height: 1.5;
  color: var(--muted);
  word-wrap: break-word; overflow-wrap: anywhere;
}
.turn__dst-text[lang="ur"] { text-align: right; }
/* keep the translation label edge-aligned with its script direction */
.turn__dst:dir(rtl) .turn__dst-tag { flex-direction: row-reverse; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Call-start / call-ended divider */
.divider {
  align-self: center;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: .78rem; font-weight: 600;
  padding: 6px 14px; margin: 4px 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.03);
  animation: rise .35s ease both;
}
.divider .bi { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }

/* ─────────────────────────── Footer ─────────────────────────── */
.app__footer {
  display: flex; align-items: center; gap: 12px;
  padding: 2px clamp(6px, 1vw, 12px);
  font-size: .78rem; color: var(--faint);
}
.footer__spacer { flex: 1; }
.footer__brand { letter-spacing: .3px; }

.conn { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); transition: background .3s; }
.conn[data-conn="live"]       .conn__dot { background: var(--ok); }
.conn[data-conn="mock"]       .conn__dot { background: var(--cyan); }
.conn[data-conn="error"]      .conn__dot { background: var(--live); }
.conn[data-conn="connecting"] .conn__dot { background: var(--blue); animation: bob 1s ease-in-out infinite; }
.conn[data-conn="live"]  .conn__label { color: var(--ok); }
.conn[data-conn="mock"]  .conn__label { color: var(--cyan); }
.conn[data-conn="error"] .conn__label { color: var(--live); }

/* ─────────────────────────── Responsive ─────────────────────────── */
/* Stack the panes when the row can't hold a 320px CCP + a usable transcript. */
@media (max-width: 860px) {
  body { overflow: auto; }          /* page scrolls; each pane still self-contained */
  .app { height: auto; min-height: 100dvh; }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .ccp { --ccp-w: auto; min-height: 320px; }
  .ccp__mount { min-height: 260px; }
  .panel { min-height: 60vh; }
}

@media (max-width: 560px) {
  .app__header {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand state";
  }
  .brand      { grid-area: brand; }
  .header__mid{ display: none; }
  .brand__kicker { display: none; }   /* redundant with the CCP "Softphone" label; free up room for the pill */
  .brand__name   { overflow: hidden; text-overflow: ellipsis; }
  .callstate  { grid-area: state; }
  .turn { max-width: 94%; }
  .footer__brand { display: none; }
  .legend { display: none; }
}

/* Big-screen / presentation mode — scale type up for a room */
@media (min-width: 1600px) {
  body { font-size: 18px; }
  .turn { max-width: min(76%, 860px); }
  .brand__logo { height: 34px; }
}

/* ─────────────────────────── Reduced motion ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    scroll-behavior: auto !important; transition-duration: .001ms !important;
  }
  .callstate[data-state="live"] .callstate__dot { box-shadow: 0 0 0 3px rgba(255,77,109,.35); }
  .empty__pulse span { opacity: .9; transform: none; }
}
