/* ===========================================================================
   Vobiz Calling for Gorgias — the Vobiz Phone page

   Reference implementations, followed rather than approximated:

     · vobiz-console/docs/VOBIZ_UI_UX_GUIDELINES.md — the stated single source
       of truth for cross-product alignment. Satoshi; orange-500 #ea580c for
       primary actions; blue-grey dark mode, never flat neutral grey.
     · The Vobiz RTC Playground — the closest sibling surface to this panel.
       Its language: #0a0a0a ground, zinc neutrals, 10px bold uppercase
       letterspaced micro-labels, rounded-xl cards, one large orange CTA.

   Inherited from the CTI-rail panel of Vobiz Calling for Salesforce: one
   narrow column, the playground's vocabulary. Here it is a page of its own,
   kept next to Gorgias, so the column is a little wider (see the end).
   =========================================================================== */

:root {
  /* Brand */
  --orange-500: #ea580c;
  --orange-600: #c2410c;
  --orange-soft: rgb(234 88 12 / 0.1);
  --orange-line: rgb(234 88 12 / 0.28);

  /* Light surfaces */
  --bg: #ffffff;
  --card: #ffffff;
  --sunken: #fafafa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;

  /* Text */
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #a1a1aa;

  /* Semantic */
  --ok: #15803d;
  --ok-soft: rgb(21 128 61 / 0.1);
  --err: #dc2626;
  --err-soft: rgb(220 38 38 / 0.1);
  --busy: #1d4ed8;
  --busy-soft: rgb(29 78 216 / 0.1);

  --r: 10px;
  --r-lg: 14px;
  --ring: 0 0 0 3px rgb(234 88 12 / 0.22);
}

/* Dark: the playground's ground, with the guidelines' blue-grey elevation. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --card: #141518;
    --sunken: #0f1011;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --orange-soft: rgb(234 88 12 / 0.14);
    --orange-line: rgb(234 88 12 / 0.35);
    --ok: #4ade80;
    --ok-soft: rgb(74 222 128 / 0.12);
    --err: #f87171;
    --err-soft: rgb(248 113 113 / 0.12);
    --busy: #93c5fd;
    --busy-soft: rgb(147 197 253 / 0.12);
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --card: #141518;
  --sunken: #0f1011;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --orange-soft: rgb(234 88 12 / 0.14);
  --orange-line: rgb(234 88 12 / 0.35);
  --ok: #4ade80;
  --ok-soft: rgb(74 222 128 / 0.12);
  --err: #f87171;
  --err-soft: rgb(248 113 113 / 0.12);
  --busy: #93c5fd;
  --busy-soft: rgb(147 197 253 / 0.12);
}

html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  margin: 0;
  /* The system's own font: nothing is loaded from another site onto the page an Auth Token is typed into. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* The panel fills its host frame; the CRM's CTI rail gives it ~300px. */
.main {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  padding-bottom: 8px;
}

/* ---------- header ------------------------------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  flex: none;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

/* The wordmark is lowercase and tight, as on vobiz.ai. */
.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text);
}

/* Playground pattern: 10px bold uppercase, widely letterspaced. */
.brand-product {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- status ------------------------------------------------------- */

/* A badge holds a STATE, never a sentence — a sentence here is what made the
   header overflow its 300px frame. */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.status-badge.is-ok      { background: var(--ok-soft);     color: var(--ok); }
.status-badge.is-error   { background: var(--err-soft);    color: var(--err); }
.status-badge.is-busy    { background: var(--busy-soft);   color: var(--busy); }
.status-badge.is-pending { background: var(--orange-soft); color: var(--orange-500); }

.status-badge.is-pending::before {
  animation: vbz-pulse 1.4s ease-in-out infinite;
}

@keyframes vbz-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* The sentence gets its own row, where it can wrap and be read. */
.status-message {
  margin: 0 14px 12px;
  padding: 8px 10px;
  border-radius: var(--r);
  font-size: 11.5px;
  line-height: 1.5;
}

.status-message.is-ok      { background: var(--ok-soft);     color: var(--ok); }
.status-message.is-error   { background: var(--err-soft);    color: var(--err); }
.status-message.is-busy    { background: var(--busy-soft);   color: var(--busy); }
.status-message.is-pending { background: var(--orange-soft); color: var(--orange-500); }

/* ---------- steps -------------------------------------------------------- */

.panel {
  padding: 0 14px;
}

.step {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.step:first-child {
  border-top: none;
  padding-top: 0;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--orange-500);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.step-num-optional {
  background: none;
  border: 1px dashed var(--border-strong);
  color: var(--text-3);
}

.step-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}

.step-help {
  margin: 0 0 12px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-2);
}

.step-help a {
  color: var(--orange-500);
  text-decoration: none;
  font-weight: 500;
}

.step-help a:hover {
  text-decoration: underline;
}

.step-help strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- forms -------------------------------------------------------- */

.form-group {
  margin-bottom: 10px;
}

/* Playground micro-label. */
.field-label {
  display: block;
  margin-bottom: 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}

.input,
input[type="text"],
input[type="tel"],
input[type="password"],
select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--sunken);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--orange-500);
  box-shadow: var(--ring);
}

/* Figures are monospaced and tabular so they never reflow. */
.input-mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.input-dial {
  height: 46px;
  font-size: 16px;
  font-weight: 500;
}

select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.hint {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
}

.hint:empty {
  display: none;
}

/* ---------- buttons ------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn-primary {
  background: var(--orange-500);
  color: #fff;
}

.btn-primary:hover:not([disabled]) {
  background: var(--orange-600);
}

.btn-secondary {
  background: var(--card);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not([disabled]) {
  border-color: var(--orange-500);
  color: var(--orange-500);
}

.btn-hangup {
  background: var(--err);
  color: #fff;
}

.btn-accept {
  background: var(--ok);
  color: #fff;
}

/* Decline sends the caller to voicemail. Outlined, so it is never mistaken
   for the solid Hang up of a call in progress. */
.btn-decline {
  background: var(--card);
  border-color: var(--err);
  color: var(--err);
}

.btn-decline:hover:not([disabled]) {
  background: var(--err);
  color: #fff;
}

/* === Incoming call === */
.incoming {
  margin: 0 0 14px;
  padding: 16px;
  background: var(--ok-soft);
  border: 1px solid var(--ok);
  border-radius: var(--r-lg);
  text-align: center;
  animation: incoming-pulse 2s ease-in-out infinite;
}

.incoming-label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ok);
}

.incoming-from {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.incoming-actions {
  display: flex;
  gap: 8px;
}

.incoming-actions .btn {
  flex: 1;
  justify-content: center;
}

.incoming-hint {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--text-3);
}

/* Draws the eye without moving anything — the buttons underneath stay put, so
   a pulse can never shift Accept out from under a click. */
@keyframes incoming-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgb(21 128 61 / 0.30); }
  50%      { box-shadow: 0 0 0 7px rgb(21 128 61 / 0); }
}

@media (prefers-reduced-motion: reduce) {
  .incoming { animation: none; }
}

.btn[disabled],
button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* The sign-in fields while signed in: greyed out, as Log in is. */
.input[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 8px;
}





/* ---------- live call ------------------------------------------------------ */

.call-status {
  margin: 10px 0 0;
  padding: 9px 11px;
  border: 1px solid var(--orange-line);
  border-radius: var(--r);
  background: var(--orange-soft);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--orange-500);
}

audio#vobiz-remote-audio {
  display: none;
}

/* ---------- sign-in tabs ----------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 3px;
  border-radius: 9px;
  background: var(--sunken);
}

.tab {
  flex: 1;
  padding: 6px 10px;
  border: none;
  border-radius: 7px;
  background: none;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab:hover { color: var(--text); }

.tab.is-active {
  background: var(--card);
  color: var(--orange-500);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}

.tab:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ---------- record toggle ---------------------------------------------------- */

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 12px;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  flex: none;
  width: 14px;
  height: 14px;
  margin: 1px 0 0;
  accent-color: var(--orange-500);
  cursor: pointer;
}

.check-row input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 3px;
}

.check-text {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.45;
}

/* Billing is a consequence the agent should see before ticking, not after. */
.check-note {
  display: block;
  font-size: 10.5px;
  color: var(--text-3);
}

/* ---------- FAQ -------------------------------------------------------------- */

.faq {
  margin: 0 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.faq > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  transition: color 0.15s ease;
}

.faq > summary::-webkit-details-marker {
  display: none;
}

.faq > summary:hover {
  color: var(--orange-500);
}

.faq > summary svg {
  color: var(--orange-500);
  flex: none;
}

.faq-item {
  margin-top: 12px;
}

.faq-item h3 {
  margin: 0 0 3px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.faq-item p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-2);
}

/* ---------- misc --------------------------------------------------------------- */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Gorgias ------------------------------------------------------------ */

/* A page of its own rather than a CTI rail: a little more room, and air above. */
.main {
  max-width: 400px;
  padding: 12px 0 24px;
}

.hint.is-ok    { color: var(--ok); }
.hint.is-error { color: var(--err); }

.stack {
  display: grid;
  gap: 8px;
}

.stack .hint {
  margin: 0;
}

.btn-quiet {
  height: 34px;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
}

.btn-quiet:hover:not([disabled]) {
  color: var(--err);
}

/* Who is on the line, from Gorgias. */
.caller {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--sunken);
  text-align: left;
}

.caller-incoming {
  margin: 0 0 12px;
  background: var(--card);
}

.caller-name {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.caller-sub {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-2);
}

.caller-where {
  margin: 8px 0 0;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-2);
}

.caller a,
.call-log a {
  color: var(--orange-500);
  font-weight: 500;
  text-decoration: none;
}

.caller a:hover,
.call-log a:hover {
  text-decoration: underline;
}

.caller-tickets {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.caller-tickets li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.caller-tickets a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pill.is-open   { background: var(--ok-soft); color: var(--ok); }
.pill.is-closed { background: var(--card); color: var(--text-3); border: 1px solid var(--border); }

/* Where the last call was logged. */
.call-log {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--r);
  font-size: 12px;
  line-height: 1.5;
}

.call-log.is-pending { background: var(--orange-soft); color: var(--orange-500); }
.call-log.is-ok      { background: var(--ok-soft);     color: var(--ok); }
.call-log.is-error   { background: var(--err-soft);    color: var(--err); }

/* A Call link handed to the Vobiz Phone already open in another tab. */
.handoff {
  margin: 0 14px 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--sunken);
  text-align: center;
}

.handoff-text {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ---------- Pop out ------------------------------------------------------- */

.popout-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 14px 12px;
}

.btn-compact {
  width: auto;
  flex: none;
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.popout-hint {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-3);
}

/* The floating window: the page's stylesheet, loaded into a window of its own. */
.mini-body {
  overflow: hidden;
}

.mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100vh;
  padding: 12px 14px;
}

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.mini-brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mini-label {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.mini-who {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mini-name,
.mini-note {
  margin: 0;
  font-size: 12px;
  color: var(--text-2);
}

.mini-clock {
  margin: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.mini-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.mini-actions .btn {
  flex: 1;
  height: 38px;
}

/* A link, drawn as one: it opens the call's ticket in Gorgias. */
.mini-ticket {
  margin: 6px 0 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--orange-500);
  text-align: left;
  cursor: pointer;
}

.mini-ticket:hover {
  text-decoration: underline;
}
