/* ──────────────────────────────────────────────────────────────
   customer.css — Premium widget chat (Notion/Vercel/Linear)
   Branded gradient header · rounded asymmetric bubbles · pill composer
────────────────────────────────────────────────────────────── */

html, body { height: 100%; }
body {
  background: var(--bg-base);
  font-size: 14px;
  line-height: 1.55;
}

/* Faux-page ambient ground so the widget feels embedded */
.page-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at 20% 30%, rgba(79,142,247,0.08), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(99,102,241,0.07), transparent 50%),
    var(--bg-base);
}

/* ── Widget shell ──────────────────────────────────────────── */

.chat-app {
  width: 100%;
  max-width: 460px;
  height: min(720px, calc(100vh - 64px));
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: rise 0.5s cubic-bezier(.2,.7,.25,1) both;
}

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

/* ── Branded header ────────────────────────────────────────── */

.chat-header {
  position: relative;
  padding: 16px 18px;
  background: linear-gradient(135deg, #4f8ef7 0%, #6366f1 100%);
  color: white;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "avatar info actions"
    "name name name";
  column-gap: 12px;
  row-gap: 8px;
  overflow: hidden;
}

.chat-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.18), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.10), transparent 40%);
  pointer-events: none;
}

.agent-avatar {
  grid-area: avatar;
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ea6ff 0%, #818cf8 100%);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.25);
  flex-shrink: 0;
}

.agent-avatar-letter { line-height: 1; position: relative; }

.agent-avatar-online {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2bb673;
  border: 2px solid #4f8ef7;
}

.agent-info {
  grid-area: info;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  position: relative;
}

.agent-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.agent-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  opacity: 0.92;
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #86efac;
  box-shadow: 0 0 0 0 rgba(134,239,172,0.6);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(134,239,172,0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(134,239,172,0); }
}

.header-actions {
  grid-area: actions;
  display: flex;
  gap: 6px;
  align-items: center;
  position: relative;
}

.header-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
}

.header-icon-btn:hover { background: rgba(255,255,255,0.25); }

.header-name-pill {
  grid-area: name;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: start;
  justify-self: start;
  padding: 4px 10px;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.005em;
  position: relative;
}

.header-name-pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #86efac;
}

/* ── Messages ──────────────────────────────────────────────── */

.chat-messages {
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-base);
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 85%;
  animation: msg-in 0.35s cubic-bezier(.2,.7,.25,1) both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.bot  { align-self: flex-start; }
.msg.user { align-self: flex-end; align-items: flex-end; }

.msg-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.01em;
  padding: 0 4px;
  display: none;  /* keep label simple — bubbles carry identity via shape/color */
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg-bubble a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.msg.user .msg-bubble a {
  color: #fff;
}

.msg.bot .msg-bubble {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow-sm);
}

.msg.user .msg-bubble {
  background: var(--brand);
  color: white;
  border-bottom-right-radius: 5px;
  box-shadow: 0 1px 2px rgba(79,142,247,0.4);
}

.msg.bot.escalated .msg-bubble {
  border-color: var(--orange);
  background: linear-gradient(0deg, var(--orange-soft), var(--orange-soft)), var(--bg-elev);
}

.msg-time {
  font-size: 10px;
  color: var(--text-faint);
  padding: 0 4px;
  font-feature-settings: "tnum";
}

/* Typing indicator */
.typing-indicator .msg-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  height: auto;
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: bounce 1.3s ease-in-out infinite;
}

.typing-indicator .dot:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ── Composer (pill-shaped) ────────────────────────────────── */

.chat-input-bar {
  margin: 12px 14px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--line);
  background: var(--bg-app);
  border-radius: 999px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-bar:focus-within {
  border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.composer-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.composer-icon-btn:hover { color: var(--text); background: var(--bg-hover); }

#msg-input {
  flex: 1;
  height: 32px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13.5px;
  letter-spacing: -0.005em;
  padding: 0 4px;
}

#msg-input::placeholder { color: var(--text-faint); }

#send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: white;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
}

#send-btn:hover:not(:disabled) {
  background: var(--brand-strong);
  transform: translateY(-1px);
}

#send-btn:active:not(:disabled) { transform: translateY(0); }

#send-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Footer ────────────────────────────────────────────────── */

.chat-foot {
  padding: 8px 16px 14px;
  display: flex;
  justify-content: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-faint);
}

.foot-strong { font-weight: 600; color: var(--text-muted); }
.foot-link { color: var(--text-faint); text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 520px) {
  .page-stage { padding: 0; }
  .chat-app {
    height: 100vh;
    max-width: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}
