/**
 * Customer Assist — widget styles.
 *
 * Every rule is scoped under .ca-root. This loads on top of whichever portal
 * theme the customer sees, so it inherits nothing deliberately and leaks
 * nothing outward.
 */

.ca-root {
  --ca-bg: #ffffff;
  --ca-fg: #1f2933;
  --ca-muted: #6b7684;
  --ca-line: #e1e5ea;
  --ca-accent: #1d6f5c;
  --ca-accent-fg: #ffffff;
  --ca-you: #eef3f8;
  --ca-error: #8a2b20;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ca-fg);
}

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

/* --- bubble --- */

.ca-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px 11px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ca-accent);
  color: var(--ca-accent-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(16, 32, 48, .22);
}

.ca-bubble:hover { filter: brightness(1.08); }
.ca-bubble:focus-visible { outline: 3px solid #90c8b8; outline-offset: 2px; }

.ca-bubble-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  font-weight: 700;
}

.ca-is-open .ca-bubble { display: none; }

/* --- panel --- */

.ca-panel {
  display: flex;
  flex-direction: column;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 40px);
  background: var(--ca-bg);
  border: 1px solid var(--ca-line);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(16, 32, 48, .24);
  overflow: hidden;
}

.ca-panel[hidden] { display: none; }

.ca-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 12px 16px;
  border-bottom: 1px solid var(--ca-line);
  background: #f7f9fb;
}

.ca-title { flex: 1; font-weight: 700; }

.ca-restart,
.ca-close {
  border: 0;
  background: transparent;
  color: var(--ca-muted);
  font: inherit;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.ca-restart { font-size: 12px; }
.ca-close { font-size: 20px; line-height: 1; }
.ca-restart:hover, .ca-close:hover { background: #e9eef3; color: var(--ca-fg); }
.ca-restart[disabled] { opacity: .4; cursor: default; }

/* --- log --- */

.ca-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  -webkit-overflow-scrolling: touch;
}

.ca-msg { margin: 0 0 14px; }
.ca-msg :first-child { margin-top: 0; }
.ca-msg :last-child { margin-bottom: 0; }
.ca-msg p { margin: 0 0 8px; }
.ca-msg ol, .ca-msg ul { margin: 0 0 8px; padding-left: 22px; }
.ca-msg li { margin: 0 0 5px; }
.ca-msg code {
  background: #f1f4f7;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 92%;
}
.ca-msg a { color: var(--ca-accent); }
.ca-head { font-weight: 700; margin-top: 12px; }

.ca-msg-you {
  margin-left: auto;
  max-width: 85%;
  width: fit-content;
  background: var(--ca-you);
  border-radius: 12px 12px 2px 12px;
  padding: 8px 12px;
}

.ca-error { color: var(--ca-error); }

.ca-retry {
  margin-top: 6px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.ca-retry[disabled] { opacity: .5; cursor: default; }

/* --- waiting ---
   The clock is the honest part: there is no streaming, so elapsed time is the
   only real progress signal we have. */

.ca-waiting {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ca-muted);
  font-size: 13px;
}

.ca-wait-clock { font-variant-numeric: tabular-nums; }

.ca-dots { display: inline-flex; gap: 3px; }
.ca-dots i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: ca-pulse 1.2s infinite ease-in-out;
}
.ca-dots i:nth-child(2) { animation-delay: .18s; }
.ca-dots i:nth-child(3) { animation-delay: .36s; }

@keyframes ca-pulse {
  0%, 60%, 100% { opacity: .25; }
  30% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ca-dots i { animation: none; opacity: .6; }
}

/* --- composer --- */

.ca-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--ca-line);
}

.ca-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--ca-line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: inherit;
  background: #fff;
  max-height: 120px;
}

.ca-input:focus { outline: 2px solid var(--ca-accent); outline-offset: -1px; }
.ca-input[disabled] { background: #f4f6f8; }

.ca-send {
  border: 0;
  border-radius: 8px;
  background: var(--ca-accent);
  color: var(--ca-accent-fg);
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  cursor: pointer;
}
.ca-send[disabled] { opacity: .5; cursor: default; }

.ca-foot {
  padding: 8px 14px 12px;
  font-size: 12px;
  color: var(--ca-muted);
  border-top: 1px solid var(--ca-line);
  background: #fbfcfd;
}

.ca-foot a { color: var(--ca-accent); margin-left: 4px; }

/* --- phone --- */

@media (max-width: 480px) {
  .ca-root { right: 12px; bottom: 12px; left: 12px; }
  .ca-panel {
    width: auto;
    height: calc(100vh - 24px);
    max-height: none;
  }
}
