:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface2: #ffffff;
  --border: #bbbbbb;
  --accent: #0d9bfa;
  --accent-dim: #106eea;
  --text: #16181c;
  --text-muted: #7a7f8e;
  --wa-green: #25d366;
  --wa-green-dim: #1aad54;
  --radius-lg: 14px;
  --radius-sm: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
.chat-header {
  justify-content: space-between;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* 🚨 Dynamic Header Action Button (Close/Back) */
.header-action-btn {
  background: transparent;
  border: none;
  color: rgb(0, 0, 0); /* Change this if your header background is light */
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  padding: 0 5px;
  transition: opacity 0.2s;
}

.header-action-btn:hover {
  opacity: 1;
}

.header-avatar {
  width: 36px;
  height: 36px;
  /* border-radius: 50%;
    background: var(--accent); */
  margin-right: 5px;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}

.header-title {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

.header-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wa-green-dim);
  box-shadow: 0 0 5px var(--wa-green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

/* ── Assignee bar ── */
#assigneeDisplay {
  display: none;
  font-size: 12px;
  padding: 8px 16px;
  background: rgba(200, 240, 77, 0.08);
  border-bottom: 1px solid rgba(200, 240, 77, 0.15);
  color: #274458;
}

/* ── Messages ── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar {
  width: 3px;
}

#messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: fadeUp 0.2s ease both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.agent {
  align-items: flex-start;
}

.msg.user {
  align-items: flex-end;
}

.msg-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 3px;
}

.msg-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.msg.agent .msg-bubble {
  background: #e6e6e6;
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: #ffffff;
  font-weight: 500;
  border-bottom-right-radius: 3px;
}

.meta {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 3px;
}

/* ── #chatShell wrapper ── */
#chatShell {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ══════════════════════════════════════
    START PANEL  –  Split Layout
══════════════════════════════════════ */
#startPanel {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

#startPanel::-webkit-scrollbar {
  width: 3px;
}

#startPanel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Section headings */
.section-label {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}

.webchat .section-icon {
  background: rgba(200, 240, 77, 0.12);
}

.whatsapp .section-icon {
  background: rgba(37, 211, 102, 0.12);
}

/* Shared field styles */
.field {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  margin-bottom: 7px;
  display: block;
}

.field::placeholder {
  color: var(--text-muted);
}

.field:focus {
  border-color: var(--accent);
}

.field.wa:focus {
  border-color: var(--wa-green);
}

/* Buttons */
.btn {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    all 0.2s,
    transform 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn:active {
  transform: scale(0.97);
}

#startBtn {
  background: var(--accent);
  color: #ffffff;
}

#startBtn:hover {
  background: var(--accent-dim);
}

#waBtn {
  background: var(--wa-green);
  color: #fff;
  margin-top: 2px;
}

#waBtn:hover {
  background: var(--wa-green-dim);
}

#waBtn svg {
  width: 18px;
  height: 18px;
  fill: #fff;
  flex-shrink: 0;
}

/* ── OR Divider ── */
.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.or-divider span {
  font-size: 10px;
  font-weight: 700;
  font-family: "Syne", sans-serif;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ── Menu panel (returning user) ── */
#menuPanel {
  display: none;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  overflow-y: auto;
}

#menuPanel h3 {
  font-family: "Syne", sans-serif;
  font-size: 13px;
  margin-bottom: 10px;
}

.button-primary{
  display: block;
  width: 100%;
  margin-bottom: 7px;
  padding: 9px 12px;
  background: var(--accent);
  border: 1px solid #2772a3;
  border-radius: 5px;
  color: #ffffff;
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.2s,
    all 0.2s;
}

#menuPanel button:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

#menuPanel small {
  color: #636363;
  font-size: 11px;
  display: block;
  margin-top: 2px;
}

/* ── Reply panel ── */
#replyPanel {
  display: none;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#replyPanel.visible {
  display: flex;
}

#messageText {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  padding: 9px 12px;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s;
}

#messageText::placeholder {
  color: var(--text-muted);
}

#messageText:focus {
  border-color: var(--accent);
}

#sendBtn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition:
    all 0.15s,
    transform 0.12s;
}

#sendBtn:hover {
  background: var(--accent-dim);
}

#sendBtn:active {
  transform: scale(0.93);
}

#sendBtn svg {
  width: 17px;
  height: 17px;
  fill: #ffffff;
}

/* Add to webchat.css */

.spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 2px solid #ffffff;
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.btn:disabled,
button:disabled {
  opacity: 0.7;
  cursor: not-allowed !important;
  transform: none !important;
  pointer-events: none;
}

/* History Items in the Menu */
.history-item {
  background: #f8f9fa;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  text-align: left;
}

.history-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Small UI Buttons */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
  flex: 1;
}

.btn-sm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-reopen {
  background-color: #007bff;
  color: white;
}

.btn-close {
  background-color: #f1f3f5;
  color: #495057;
  border: 1px solid #ced4da;
}

/* Interactive Prompt Bubbles */
.interactive-prompt {
  display: flex;
  justify-content: center;
  margin: 15px 0;
}

.system-bubble {
  background-color: #ebf2f7;
  border: 1px solid #c4dced;
  color: #3f3f3f;
  padding: 10px;
  border-radius: 10px;
  text-align: center;
  width: 100%;
}

.prompt-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}

.btn-resolve, .btn-pending, .btn-continue, .btn-reopen, .btn-close {
  background-color: #ffffff; 
  border: 1px solid #007acc;
  color: #007acc;
}
.btn-resolve:hover, .btn-pending:hover, .btn-continue:hover, .btn-reopen:hover, .btn-close:hover {
  background-color: #007acc;
  color: white;
}


/* 🔥 Overlay base */
.overlay {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(6px);
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* hidden state */
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* popup card */
.overlay-card {
  background: white;
  border-radius: 14px;
  padding: 18px;
  width: 85%;
  max-width: 280px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);

  transform: scale(0.9);
  opacity: 0;
  animation: overlayPop 0.25s ease forwards;
}

/* animation similar to chatPop */
@keyframes overlayPop {
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* buttons layout */
.overlay-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
