/* ─── Host & CSS variables ──────────────────────────────────────────────── */
:host {
  position: fixed;
  left: auto;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: Inter, "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;

  /* ── Brand palette — matches Login page exactly ── */
  --blue-900: #1e3a8a;
  --blue-800: #1e40af;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  --primary-gradient: linear-gradient(140deg, #051642 0%, #0a2a6b 48%, #0e3a8c 100%);
  --primary-color:    #051642;
  --primary-dark:     #030d2d;
  --primary-light:    #1d4ed8;

  --surface-0:     #ffffff;
  --surface-1:     #f8faff;
  --surface-2:     #eef3ff;
  --surface-glass: rgba(255, 255, 255, 0.88);

  --text-color:     #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  --success:      #16a34a;
  --danger:       #dc2626;
  --border-color: rgba(100, 130, 200, 0.18);

  --shadow-panel: 0 24px 64px rgba(15, 30, 80, 0.22), 0 8px 24px rgba(15, 30, 80, 0.1);
  --shadow-fab:   0 16px 36px rgba(29, 78, 216, 0.36), 0 4px 12px rgba(30, 64, 175, 0.2);
  --shadow-card:  0 8px 24px rgba(15, 30, 80, 0.07);

  --radius-sm:   10px;
  --radius-md:   14px;
  --radius-lg:   18px;
  --radius-xl:   22px;
  --radius-pill: 999px;

  --transition-fast: 150ms ease;
  --transition-base: 240ms ease;
  --transition-open: 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
button, input, textarea { font: inherit; }


/* ─── FAB button ────────────────────────────────────────────────────────── */
.chat-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  width: 52px;
  min-width: 52px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-pill);
  color: var(--text-inverse);
  background: #051642;

  cursor: pointer;
  outline: none;
  overflow: visible;
  position: relative;
  transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1), padding 300ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 200ms ease, box-shadow 200ms ease, background 200ms ease, border-color 200ms ease;
}

.chat-toggle-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18); }

/* Closed, not-hovered = plain icon circle. Hover — or the periodic auto-peek —
   expands into a pill with the label. */
.chat-toggle-btn:not(.is-open):hover,
.chat-toggle-btn.auto-peek:not(.is-open) {
  width: 138px;
  padding: 0 18px 0 14px;
}

/* Closed X state */
.chat-toggle-btn.is-open {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  background: #111c3d;
  border-color: rgba(255,255,255,0.12);
}
.chat-toggle-btn.is-open:hover { background: #1e293b; }

.fab-inner {
  display: inline-flex;
  align-items: center;
  gap: 0;
  position: relative;
  z-index: 1;
  transition: gap 260ms ease;
}
.chat-toggle-btn:not(.is-open):hover .fab-inner,
.chat-toggle-btn.auto-peek:not(.is-open) .fab-inner { gap: 10px; }

.fab-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  position: relative;
}
.fab-icon-wrap svg {
  width: 22px;
  height: 22px;
  transform-origin: 50% 50%;
  will-change: transform;
}

.chat-toggle-btn.auto-peek-opening:not(.is-open) .fab-icon-wrap svg {
  animation: headphoneSpinForward 360ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.chat-toggle-btn.auto-peek-closing:not(.is-open) .fab-icon-wrap svg {
  animation: headphoneSpinReverse 360ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes headphoneSpinForward {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes headphoneSpinReverse {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(-360deg);
  }
}

.fab-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  max-width: 0;
  min-width: 0;
  opacity: 0;
  white-space: nowrap;
  overflow: hidden;
  transition: max-width 260ms ease 40ms, opacity 180ms ease;
}
.chat-toggle-btn:not(.is-open):hover .fab-text,
.chat-toggle-btn.auto-peek:not(.is-open) .fab-text { max-width: 100px; opacity: 1; }
.fab-brand { font-size: 0.84rem; font-weight: 800; letter-spacing: 0.01em; }

.fab-close-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.fab-close-icon svg { width: 18px; height: 18px; }

.chat-toggle-btn.auto-peek-open:not(.is-open) .fab-text,
.chat-toggle-btn.auto-peek-open:not(.is-open) .fab-close-icon {
  animation: capsuleReveal 300ms cubic-bezier(0.4, 0, 0.2, 1) 180ms both;
}

@keyframes capsuleReveal {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}


/* ─── Security badge (attached above the launcher) ───────────────────────── */
.greeting-bubble {
  position: absolute;
  bottom: 64px;
  right: 4px;
  width: max-content;
  max-width: 230px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 32px 9px 14px;
  background: #ffffff;
  border: 1px solid rgba(100, 130, 200, 0.18);
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 16px 40px -12px rgba(15, 30, 80, 0.28), 0 4px 12px rgba(15, 30, 80, 0.08);
  z-index: 2;
  transform-origin: bottom right;
  animation: greetIn 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
/* Little tail pointing down toward the FAB */
.greeting-bubble::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-right: 1px solid rgba(100, 130, 200, 0.18);
  border-bottom: 1px solid rgba(100, 130, 200, 0.18);
  transform: rotate(45deg);
}
.greeting-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(36, 43, 124, 0.08);
  color: #051642;
}
.greeting-icon svg { width: 14px; height: 14px; }
.greeting-title { margin: 0; font-size: 0.78rem; font-weight: 700; color: #0f172a; line-height: 1.3; }
.greeting-close {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(15, 30, 80, 0.06);
  color: #64748b;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.greeting-close:hover { background: rgba(15, 30, 80, 0.12); color: #0f172a; }
.greeting-close svg { width: 11px; height: 11px; }

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


/* ─── Chat window ───────────────────────────────────────────────────────── */
.chat-widget-container { position: relative; }

.chat-window {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 412px;
  /* One fixed height used by BOTH the form and the live-chat view so they are
     always the same size. Sized to hug the contact form with only a small gap,
     and leaves room for the FAB + margins on short screens so it never crosses
     the display edge. */
  height: min(668px, calc(100vh - 120px));
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 15px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity var(--transition-open), transform var(--transition-open);
}
.chat-window.is-open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}


/* ─── Header ────────────────────────────────────────────────────────────── */
.chat-header {
  position: relative;
  flex-shrink: 0;

  padding: 14px 20px 15px;

  color: var(--text-inverse);
  background: #051642;
  overflow: hidden;
}

/* Concentric ring lines radiating from the right glow — like the reference banner */
.header-decoration-1 {
  display: none;
}
/* Soft bright core behind the rings */
.header-decoration-2 {
  display: none;
}

/* Unused now — kept empty to avoid layout shift */
.header-grid-overlay { display: none; }

.header-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.header-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: transparent;
  border: none;
  flex-shrink: 0;
}

.header-logo-img { width: 38px; height: 38px; object-fit: contain; display: block; }
.header-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.header-brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: #ffffff;
}

.header-automating {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
}

.header-greeting {
  position: relative;
  z-index: 1;
  margin-top: 9px;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-brand-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.01em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.28);
  animation: pulse 1.8s infinite ease-in-out;
  flex-shrink: 0;
}

.header-actions { display: flex; align-items: center; gap: 8px; align-self: flex-start; }

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.header-btn:hover { background: rgba(255, 255, 255, 0.25); }
.header-btn svg { width: 14px; height: 14px; }

.header-tagline {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.82);
  letter-spacing: 0.01em;
}


/* ─── Body ──────────────────────────────────────────────────────────────── */
.chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: transparent;
}


/* ─── Contact form ──────────────────────────────────────────────────────── */
.form-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 10px 16px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.secure-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 10px;
  background: rgba(36, 43, 124, 0.05);
  border: 1px solid rgba(36, 43, 124, 0.12);
  border-radius: 12px;
}
.secure-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  background: rgba(36, 43, 124, 0.1);
  color: #051642;
}
.secure-card-icon svg { width: 18px; height: 18px; }
.secure-card-text { min-width: 0; }
.secure-card-title { margin: 0; font-size: 0.82rem; font-weight: 700; color: #0f172a; }
.secure-card-sub { margin: 2px 0 0; font-size: 0.72rem; color: #64748b; line-height: 1.35; }

.form-reply-time {
  text-align: center;
  font-size: 0.76rem;
  color: #64748b;
  margin-top: 8px;
}
.form-container::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Security card */
.security-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  margin-bottom: 13px;
  border: 1px solid rgba(99, 130, 220, 0.18);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(238,243,255,0.95), rgba(230,237,255,0.75));
  box-shadow: 0 8px 22px -12px rgba(25, 45, 120, 0.25);
  overflow: hidden;
}

/* Big faded lock watermark on the right (reference detail) */
.security-card::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(120, 145, 220, 0.10);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='11' width='18' height='11' rx='2'/><path d='M7 11V7a5 5 0 0 1 10 0v4'/></svg>") center/28px no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='11' width='18' height='11' rx='2'/><path d='M7 11V7a5 5 0 0 1 10 0v4'/></svg>") center/28px no-repeat;
}

.security-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  color: #051642;
  background: #ffffff;
  border: 1px solid rgba(99, 130, 220, 0.35);
  box-shadow: 0 4px 12px -4px rgba(25, 45, 120, 0.25);
}
.security-icon svg { width: 20px; height: 20px; }

.security-text { padding-right: 56px; }
.security-text h4 {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 800;
  color: #1e293b;
}
.security-text p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #64748b;
}

/* Form */
.contact-form { display: flex; flex-direction: column; gap: 6px; }

.form-group { display: flex; flex-direction: column; gap: 4px; }

.form-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0;
}

.required, .field-error { color: var(--danger); }

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-shell:focus-within {
  border-color: #111c3d;
  box-shadow: 0 0 0 1px #111c3d;
}
.input-shell.has-error { border-color: rgba(220, 38, 38, 0.5); }

.input-shell::before {
  display: none;
}
.textarea-shell::before { display: none; }

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: #334155;
  pointer-events: none;
}
.textarea-icon { top: 14px; }

.form-group input,
.form-group textarea {
  width: 100%;
  border: none;
  outline: none;
  color: var(--text-color);
  background: transparent;
  font-size: 0.9rem;
}
.form-group input { height: 40px; padding: 0 16px 0 42px; }
.form-group textarea { min-height: 50px; padding: 10px 16px 10px 42px; resize: none; }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }

.field-error { margin: 0; font-size: 0.7rem; font-weight: 700; }

.submit-error {
  margin: 0;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid rgba(220, 38, 38, 0.18);
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 600;
  text-align: center;
}

/* Start chat button */
.btn-start-chat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  margin-top: 4px;
  border: none;
  border-radius: 8px;
  color: #ffffff;
  background: #051642;
  box-shadow: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}
.btn-start-chat:hover:not(:disabled) {
  background: #1c2e5c;
}
.btn-start-chat:disabled { cursor: not-allowed; opacity: 1; }
.btn-start-chat svg { width: 18px; height: 18px; }

.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}


/* ─── Chat interface ────────────────────────────────────────────────────── */
.chat-interface {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 300ms var(--transition-open);
}

/* Session banner */
.session-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255,255,255,0.8);
  color: #051642;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  backdrop-filter: blur(8px);
}
.session-banner.resolved {
  color: #15803d;
  background: rgba(240, 253, 244, 0.9);
}
.session-ticket-ref {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  color: #051642;
  background: rgba(36, 43, 124, 0.08);
  border: 1px solid rgba(36, 43, 124, 0.16);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.session-banner.resolved .session-ticket-ref {
  color: #15803d;
  background: rgba(21, 128, 61, 0.08);
  border-color: rgba(21, 128, 61, 0.16);
}
.session-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
  animation: pulse 1.8s infinite ease-in-out;
  flex-shrink: 0;
}
.resolved-icon { width: 14px; height: 14px; flex-shrink: 0; }

/* Messages */
.messages-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px;
  background:
    radial-gradient(circle at 10% 8%, rgba(37, 99, 235, 0.07), transparent 28%),
    linear-gradient(180deg, #f0f5ff 0%, #f8faff 30%, #ffffff 100%);
  scroll-behavior: smooth;
}

/* Empty state */
.empty-conversation {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.8rem;
}

/* Typing dots */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  background: var(--surface-0);
  box-shadow: var(--shadow-card);
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-500);
  animation: typing 1s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 140ms; }
.typing-indicator span:nth-child(3) { animation-delay: 280ms; }

/* Message rows */
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  opacity: 0;
  animation: msgIn 220ms ease forwards;
}
/* Stack conversation from the bottom (near the input) — avoids a big empty
   gap when there are only a few messages, while keeping normal scroll. */
.message-row:first-child { margin-top: auto; }
.row-user    { flex-direction: row-reverse; }
.row-support { flex-direction: row; }

.message-content { display: flex; flex-direction: column; max-width: 80%; min-width: 0; gap: 3px; }
.row-user .message-content    { align-items: flex-end; }
.row-support .message-content { align-items: flex-start; }

.msg-sender-label, .message-time {
  padding: 0 3px;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.msg-sender-label.user-label { color: #051642; }

.message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.86rem;
  line-height: 1.55;
  word-break: break-word;
}
.bubble-support {
  border: 1px solid rgba(100, 130, 200, 0.16);
  border-bottom-left-radius: 5px;
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 4px 14px rgba(15, 30, 80, 0.07);
}
.bubble-user {
  border-bottom-right-radius: 5px;
  color: var(--text-inverse);
  background: #051642;
  box-shadow:#051642;
}


/* ─── Chat footer ───────────────────────────────────────────────────────── */
.chat-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

/* Quick replies */
.quick-replies-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 8px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-replies-bar::-webkit-scrollbar { display: none; }

.quick-reply-chip {
  flex-shrink: 0;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--blue-100);
  background: var(--blue-50);
  color:#051642;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.quick-reply-chip:hover { background: var(--blue-100); border-color: var(--blue-400); }

.suggestion-chip { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.suggestion-chip:hover { background: #dcfce7; border-color: #86efac; }

/* Input row */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 13px;
}

.hidden-file-input { display: none; }

.attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: #1a358c;
  background: rgba(16, 33, 98, 0.06);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.attach-btn:hover { background: rgba(16, 33, 98, 0.12); transform: translateY(-1px); }
.attach-btn svg { width: 16px; height: 16px; pointer-events: none; }

.chat-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(100, 130, 200, 0.26);
  border-radius: var(--radius-pill);
  outline: none;
  color: var(--text-color);
  background: rgba(248, 250, 255, 0.96);
  font-size: 0.86rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-input:focus {
  border-color: var(--blue-500);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  color: var(--text-inverse);
  background: #051642;
  box-shadow: 0 6px 16px rgba(16, 33, 98, 0.30);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}
.send-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(29, 78, 216, 0.36); }
.send-btn:disabled { cursor: not-allowed; opacity: 0.44; box-shadow: none; }
.send-icon { width: 16px; height: 16px; }

/* Footer branding */
.chat-footer-branding {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 14px 10px;
  font-size: 0.67rem;
  color: var(--text-muted);
}
.brand-lock-icon { width: 11px; height: 11px; color: var(--primary-light); flex-shrink: 0; }
.chat-footer-branding strong { color: #051642; }

/* Resolved */
.resolved-actions {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(255,255,255,0.92);
}
.resolved-button { margin: 0; }


/* ─── Emoji picker ──────────────────────────────────────────────────────── */
.emoji-btn-wrap { position: relative; flex-shrink: 0; }
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(15, 30, 80, 0.16);
  width: 188px;
}
.emoji-item {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px; background: transparent; border: none;
  cursor: pointer; font-size: 17px; line-height: 1;
  transition: background var(--transition-fast);
}
.emoji-item:hover { background: var(--blue-50); }


/* ─── Image preview ─────────────────────────────────────────────────────── */
.image-preview-bar { padding: 10px 13px 0; }
.image-preview-wrap { position: relative; display: inline-block; }
.image-preview-thumb {
  display: block; width: 68px; height: 68px;
  object-fit: cover; border-radius: var(--radius-sm);
  border: 2px solid rgba(29, 78, 216, 0.22);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.1);
}
.image-preview-remove {
  position: absolute; top: -7px; right: -7px;
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border: none; border-radius: 50%;
  background: #0f172a; color: #fff; cursor: pointer; padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.22);
}
.image-preview-remove svg { width: 10px; height: 10px; }

/* Image in bubble */
.msg-image {
  display: block; max-width: 200px; max-height: 200px; width: 100%;
  border-radius: var(--radius-sm); object-fit: cover;
  cursor: zoom-in; transition: opacity var(--transition-fast);
}
.msg-image:hover { opacity: 0.88; }
.bubble-image-only { padding: 5px !important; background: transparent !important; box-shadow: none !important; border: none !important; }

/* File attachment link in bubble */
.msg-file-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; text-decoration: underline;
  text-underline-offset: 2px; opacity: 0.9; margin-top: 4px;
  color: inherit;
}
.msg-file-link:hover { opacity: 1; }


/* ─── Fullscreen viewer ─────────────────────────────────────────────────── */
.img-fullscreen-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 160ms ease;
}
.img-fullscreen-img {
  max-width: 92vw; max-height: 88vh;
  border-radius: var(--radius-md);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  object-fit: contain;
}
.img-fullscreen-close {
  position: absolute; top: 18px; right: 18px;
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: rgba(255,255,255,0.14); color: #fff; cursor: pointer;
  transition: background var(--transition-fast);
}
.img-fullscreen-close:hover { background: rgba(255,255,255,0.24); }
.img-fullscreen-close svg { width: 17px; height: 17px; }


/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border-radius: var(--radius-pill); background: rgba(100, 130, 200, 0.36); }


/* ─── Animations ────────────────────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(0.72); opacity: 0.65; }
}
@keyframes typing {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ─── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :host {
    left: auto;
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    right: max(12px, env(safe-area-inset-right, 12px));
  }
  .chat-window {
    position: fixed;
    right: max(10px, env(safe-area-inset-right, 10px));
    left: max(10px, env(safe-area-inset-left, 10px));
    bottom: max(72px, calc(72px + env(safe-area-inset-bottom, 0px)));
    top: max(10px, env(safe-area-inset-top, 10px));
    width: auto; height: auto;
    max-width: 100%; max-height: 100%;
    border-radius: 24px;
  }
  .chat-header { padding: 16px 16px 18px; }
  .header-brand-name { font-size: 0.95rem; }
  .header-greeting { font-size: 0.8rem; margin-top: 9px; }
  .header-logo-wrap { width: 40px; height: 40px; border-radius: 11px; }
  .chat-toggle-btn { height: 48px; min-width: 48px; }
  .chat-toggle-btn.is-open { width: 44px; min-width: 44px; height: 44px; }
  .form-container, .messages-container { padding: 12px; }
  .message-bubble { font-size: 0.83rem; padding: 9px 12px; }
  .chat-input { height: 40px; }
  .send-btn { width: 40px; height: 40px; }
}

@media (max-width: 380px) {
  .chat-window { right: 8px; left: 8px; bottom: 68px; border-radius: 22px; }
  .header-actions { gap: 6px; }
  .header-btn { width: 28px; height: 28px; }
  .fab-brand { font-size: 0.78rem; }
}

/* ─── Session restore spinner ────────────────────────────────────────────── */
.restore-spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px 24px;
  flex: 1;
}
.restore-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(37, 99, 235, 0.15);
  border-top-color: #051642;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.restore-text {
  font-size: 13px;
  color: #64748b;
  margin: 0;
}
.btn-restore-retry {
  padding: 8px 20px;
  background: #051642;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  max-width: 200px;
}
.btn-restore-retry:hover { background: #0a2a6b; }
.btn-restore-new {
  padding: 8px 20px;
  background: transparent;
  color: #64748b;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  max-width: 200px;
}
.btn-restore-new:hover { background: #f8fafc; }
