@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* deep navy base */
  background: #05101e;
}

/* ── Background orbs — all blues ─────────────────────────────────────────── */

.bg-orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(80px);
}

/* Bright blue — top left */
.bg-orb-1 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(37,99,235,0.55) 0%, transparent 65%);
  top: -160px;
  left: -120px;
  animation: drift-1 14s ease-in-out infinite;
}

/* Steel / medium blue — center right */
.bg-orb-2 {
  width: 440px;
  height: 440px;
  background: radial-gradient(circle, rgba(96,165,250,0.4) 0%, transparent 65%);
  top: 5%;
  right: -110px;
  animation: drift-2 18s ease-in-out infinite;
}

/* Deep navy — bottom left */
.bg-orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(30,64,175,0.5) 0%, transparent 65%);
  bottom: -130px;
  left: -80px;
  animation: drift-3 16s ease-in-out infinite;
}

/* Powder / light blue — bottom right */
.bg-orb-4 {
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(147,197,253,0.3) 0%, transparent 65%);
  bottom: -70px;
  right: -60px;
  animation: drift-4 20s ease-in-out infinite;
}

@keyframes drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(40px, 30px) scale(1.06); }
  66%       { transform: translate(-20px, 50px) scale(0.95); }
}

@keyframes drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%       { transform: translate(-50px, 40px) scale(1.08); }
  70%       { transform: translate(20px, -30px) scale(0.94); }
}

@keyframes drift-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  35%       { transform: translate(30px, -40px) scale(1.05); }
  65%       { transform: translate(-10px, 20px) scale(0.97); }
}

@keyframes drift-4 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  45%       { transform: translate(-30px, -25px) scale(1.07); }
  75%       { transform: translate(15px, 35px) scale(0.96); }
}

/* ── Chat container ──────────────────────────────────────────────────────── */

#chat-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  height: 680px;
  max-height: 90vh;
  background: #fff;
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(147,197,253,0.12),
    0 8px 32px rgba(5,16,30,0.5),
    0 32px 80px rgba(5,16,30,0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

#chat-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: linear-gradient(-45deg, #05101e, #0a1830, #06142a, #0c1e3a, #05101e);
  background-size: 400% 400%;
  animation: header-aurora 16s ease infinite;
}

@keyframes header-aurora {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

#chat-header::before,
#chat-header::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(40px);
}

#chat-header::before {
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(37,99,235,0.55) 0%, transparent 70%);
  top: -50px;
  right: -30px;
  animation: drift-1 11s ease-in-out infinite;
}

#chat-header::after {
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(147,197,253,0.35) 0%, transparent 70%);
  bottom: -30px;
  left: 40px;
  animation: drift-3 14s ease-in-out infinite;
}

#header-left {
  display: flex;
  align-items: center;
  gap: 13px;
  position: relative;
  z-index: 1;
}

#avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

#business-name {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.2px;
}

#status-line {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
}

#status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: pulse-green 2.5s ease-in-out infinite;
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0.6); }
  50%       { box-shadow: 0 0 0 5px rgba(74,222,128,0); }
}

#status-text {
  color: rgba(255,255,255,0.45);
  font-size: 12px;
  font-weight: 500;
}

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

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  /* very light blue tint on message background */
  background: #f0f5ff;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: #c0d4f0; border-radius: 2px; }

.message {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: msg-in 0.22s cubic-bezier(0.22,1,0.36,1) both;
}

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

.message.bot {
  background: #fff;
  color: #0a1628;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(10,22,40,0.09);
}

.message.user {
  background: linear-gradient(135deg, #0f2044, #1e40af);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  box-shadow: 0 2px 12px rgba(15,32,68,0.35);
}

/* ── Typing indicator ────────────────────────────────────────────────────── */

#typing-indicator { align-self: flex-start; }
#typing-indicator.hidden { display: none; }

.typing-bubble {
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 4px rgba(10,22,40,0.09);
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8aaad4;
  animation: bounce 1.2s infinite;
  display: inline-block;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* ── Input area ──────────────────────────────────────────────────────────── */

#chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid #d0dff5;
  background: #fff;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  border: 1.5px solid #d0dff5;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #f0f5ff;
  color: #0a1628;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#chat-input:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

#chat-input:disabled { opacity: 0.5; }

#send-btn, #mic-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

#send-btn {
  background: linear-gradient(135deg, #0f2044, #1e40af);
  color: #fff;
}

#send-btn:hover {
  box-shadow: 0 4px 16px rgba(15,32,68,0.45);
  transform: scale(1.06);
}

#send-btn:active  { transform: scale(0.92); }
#send-btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; transform: none; }

#mic-btn {
  background: #e8f0fe;
  color: #3a5280;
}

#mic-btn:hover { background: #d0dff5; }

#mic-btn.recording {
  background: #fee2e2;
  color: #ef4444;
  animation: pulse-rec 1s infinite;
}

@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50%       { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

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

#chat-footer {
  text-align: center;
  padding: 8px 16px 10px;
  background: #fff;
  border-top: 1px solid #e8f0fe;
  flex-shrink: 0;
}

#chat-footer a {
  font-size: 11px;
  color: #8aaad4;
  text-decoration: none;
  margin: 0 6px;
  transition: color 0.2s;
}

#chat-footer a:hover { color: #1e40af; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  body { padding: 0; align-items: flex-end; }
  #chat-container {
    border-radius: 24px 24px 0 0;
    max-width: 100%;
    height: 92vh;
    max-height: 92vh;
  }
}
