:root {
  --bg: #f7f9fc;
  --text-primary: #0f172a;
  --text-muted: #4b5563;
  --card-bg: rgba(255, 255, 255, 0.96);
  --card-border: rgba(15, 23, 42, 0.08);
  --user-bubble: #2563eb;
  --agent-bubble: #0f172a;
  --system-bubble: #6b7280;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  overflow: hidden;
  position: relative;
}

html {
  font-size: 14px;
}

@media (min-width: 1440px) {
  html {
    font-size: 13px;
  }
}

body::before, body::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(10px 10px at 12% 24%, rgba(59, 130, 246, 0.24), transparent 60%),
    radial-gradient(8px 8px at 82% 12%, rgba(16, 185, 129, 0.24), transparent 60%),
    radial-gradient(9px 9px at 32% 78%, rgba(14, 165, 233, 0.2), transparent 60%),
    radial-gradient(7px 7px at 90% 68%, rgba(94, 92, 255, 0.18), transparent 60%),
    radial-gradient(6px 6px at 50% 40%, rgba(99, 102, 241, 0.14), transparent 60%),
    radial-gradient(6px 6px at 18% 60%, rgba(52, 211, 153, 0.14), transparent 60%);
  background-repeat: no-repeat;
  animation: floatDots 16s ease-in-out infinite alternate;
  z-index: 0;
}

@keyframes floatDots {
  0% { transform: translateY(0px); opacity: 0.9; }
  50% { transform: translateY(-8px); opacity: 0.8; }
  100% { transform: translateY(8px); opacity: 0.9; }
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 32px 48px;
}

.chat-shell {
  width: min(880px, 100%);
  height: 85vh;
  max-height: 840px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.15);
  position: relative;
  z-index: 1;
}

.chat-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(7px 7px at 20% 18%, rgba(59, 130, 246, 0.12), transparent 55%),
    radial-gradient(5px 5px at 80% 24%, rgba(16, 185, 129, 0.12), transparent 55%),
    radial-gradient(6px 6px at 32% 70%, rgba(14, 165, 233, 0.1), transparent 55%),
    radial-gradient(5px 5px at 88% 72%, rgba(94, 92, 255, 0.1), transparent 55%);
  opacity: 0.7;
  z-index: 0;
}

.brand-mark {
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  background: transparent;
  padding: 30px 0 2px;
  border-radius: 0;
  box-shadow: none;
  z-index: 3;
  pointer-events: none;
}

.brand-mark img {
  display: block;
  width: min(260px, 70vw);
  height: auto;
}

.chat-header {
  padding: 28px 32px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  display: flex;
  gap: 16px;
  align-items: center;
  position: relative;
  z-index: 2;
}

.header-text {
  flex: 1;
}

.chat-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-logo-mobile {
  display: none;
  max-width: 220px;
  width: 100%;
  height: auto;
}

.chat-header p {
  margin: 6px 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.end-chat-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(150deg, #ef4444, #dc2626);
  color: #ffffff;
  border: 1px solid rgba(220, 38, 38, 0.9);
  border-radius: 999px;
  padding: 12px 24px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  align-self: center;
  font-size: 0.98rem;
}

.end-chat-button:hover:not(:disabled) {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(220, 38, 38, 0.35);
}

.end-chat-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: linear-gradient(130deg, rgba(252, 165, 165, 0.18), rgba(239, 68, 68, 0.32));
  color: #ffe9e9;
  border-color: rgba(248, 113, 113, 0.5);
}

.warning-banner {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #b91c1c;
  border-radius: 12px;
  font-size: 0.9rem;
}

.chat-body {
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 2;
}

.status-indicator {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 8px 16px;
  visibility: hidden;
}

@media (max-width: 768px) {
  body {
    padding: 48px 8px 28px;
  }

  .chat-shell {
    width: 100%;
  }

  .brand-mark {
    display: none;
  }

  .header-logo-mobile {
    display: block;
    max-width: 180px;
    width: 60%;
    height: auto;
    margin-bottom: 6px;
    object-fit: contain;
  }

  .chat-header h1 {
    display: none;
  }

  .chat-body {
    padding: 20px 16px;
  }

  .chat-footer {
    padding: 12px 16px;
  }
}

.quick-inline {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.quick-inline button {
  flex: 1 1 0;
  min-width: 0;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(165deg, #16a34a, #0f7b36);
  border: 1px solid rgba(15, 123, 54, 0.15);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.quick-inline button.secondary {
  background: linear-gradient(165deg, #2563eb, #1d4ed8);
  border-color: rgba(37, 99, 235, 0.2);
}

.quick-inline button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.quick-inline button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  gap: 6px;
  position: relative;
  z-index: 2;
}

.visit-prompt {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-end;
  width: 120px;
  margin: -4px 0 8px;
  align-items: stretch;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.visit-btn {
  border: none;
  border-radius: 12px;
  padding: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  color: #f9fafb;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.visit-yes {
  background: linear-gradient(170deg, #3a9f78, #2c7b5c);
  box-shadow: 0 2px 6px rgba(44, 123, 92, 0.18);
}

.visit-no {
  background: linear-gradient(170deg, #d98691, #c55d67);
  box-shadow: 0 2px 6px rgba(197, 93, 103, 0.18);
}

.visit-btn:hover {
  transform: translateY(-1px);
}

.visit-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.visit-btn.muted {
  opacity: 0.25;
  box-shadow: none;
}

.visit-btn.selected {
  opacity: 0.8;
  box-shadow: 0 2px 6px rgba(44, 123, 92, 0.18);
}

.location-prompt {
  width: 220px;
  gap: 10px;
}

.location-prompt .visit-btn {
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.location-prompt .visit-btn:nth-of-type(1) {
  background: linear-gradient(160deg, #2563eb, #1d4ed8);
}

.location-prompt .visit-btn:nth-of-type(2) {
  background: linear-gradient(160deg, #16a34a, #0f7b36);
}

.location-prompt .visit-btn:nth-of-type(3) {
  background: linear-gradient(160deg, #f59e0b, #d97706);
}

.location-prompt .visit-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.treatment-prompt {
  width: 260px;
  gap: 10px;
}

.treatment-prompt .visit-btn {
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.treatment-prompt .visit-btn:nth-of-type(1) { background: linear-gradient(160deg, #2563eb, #1d4ed8); }
.treatment-prompt .visit-btn:nth-of-type(2) { background: linear-gradient(160deg, #0ea5e9, #0284c7); }
.treatment-prompt .visit-btn:nth-of-type(3) { background: linear-gradient(160deg, #16a34a, #0f7b36); }
.treatment-prompt .visit-btn:nth-of-type(4) { background: linear-gradient(160deg, #a855f7, #7c3aed); }
.treatment-prompt .visit-btn:nth-of-type(5) { background: linear-gradient(160deg, #f59e0b, #d97706); }
.treatment-prompt .visit-btn:nth-of-type(6) { background: linear-gradient(160deg, #6b7280, #4b5563); }

.treatment-prompt .visit-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.date-prompt {
  align-self: flex-end;
  gap: 10px;
  width: 320px;
}

.date-picker-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
}

.date-input {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.time-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.time-chip {
  flex: 1 1 48%;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(165deg, #2563eb, #1d4ed8);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  border: 1px solid rgba(37, 99, 235, 0.2);
  position: relative;
}

.time-chip.selected {
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.35);
  background: linear-gradient(165deg, #1b3c9b, #122f7a);
  border-color: rgba(25, 65, 170, 0.5);
}

.time-chip.selected::before {
  content: "✓";
  position: absolute;
  left: 10px;
  font-weight: 800;
  color: #e2e8f0;
}

.time-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.time-chip:not(:disabled):hover {
  transform: translateY(-1px);
}

.date-note {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.date-submit {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(165deg, #16a34a, #0f7b36);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  border: 1px solid rgba(15, 123, 54, 0.15);
}

.date-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.message.agent {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
}

.message.system {
  align-self: center;
  max-width: 60%;
}

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 0.97rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.02);
  color: #0b1220;
  position: relative;
  z-index: 2;
}

.message.agent .bubble {
  background: #e4e9f3;
  color: #0f172a;
}

.message.user .bubble {
  background: var(--user-bubble);
  color: #f9fafb;
}

.message.system .bubble {
  background: var(--system-bubble);
  color: #f9fafb;
}

.timestamp {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.sender-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.message-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.message.user .message-meta,
.visit-prompt .message-meta {
  align-self: flex-end;
}

.chat-footer {
  padding: 20px 24px 24px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  gap: 12px;
  background: #f8fafc;
  position: relative;
  z-index: 2;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
}

.chat-form {
  display: flex;
  gap: 12px;
  flex: 1;
}

.chat-input {
  flex: 1;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-input:focus {
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.send-button {
  border: none;
  border-radius: 12px;
  padding: 12px 30px;
  font-size: 0.98rem;
  font-weight: 700;
  color: #0b1220;
  background: linear-gradient(130deg, #c7d2fe, #a5b4fc);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  border: 1px solid rgba(79, 70, 229, 0.25);
}

.send-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.22);
}

.send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-indicator {
  position: static;
  text-align: center;
  margin: 0 auto;
  padding: 6px 0;
}
