:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.15);
  --bg-main: #090d16;
  --bg-panel: rgba(16, 23, 38, 0.85);
  --bg-card: rgba(26, 36, 58, 0.6);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --whatsapp-color: #22c55e;
  --whatsapp-hover: #16a34a;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-full: 9999px;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-panel: rgba(255, 255, 255, 0.9);
  --bg-card: rgba(241, 245, 249, 0.8);
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.16);
  --text-main: #0f172a;
  --text-dim: #475569;
  --text-muted: #94a3b8;
  --primary-light: rgba(37, 99, 235, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(37, 99, 235, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(34, 197, 94, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  overflow: hidden;
}

/* App Container */
.app-wrapper {
  width: 100%;
  max-width: 1000px;
  height: 94vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

/* Top Header */
.app-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-avatar-box {
  position: relative;
}

.brand-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-light);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background-color: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--bg-main);
}

.brand-meta h1 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.3px;
}

.badge-verified {
  font-size: 0.7rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.brand-meta p {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.btn-icon:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-whatsapp {
  background: var(--whatsapp-color);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
}

.btn-whatsapp:hover {
  background: var(--whatsapp-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.35);
}

/* Chat Messages Area */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Welcome Card */
.welcome-card {
  text-align: center;
  max-width: 550px;
  margin: 20px auto 10px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: fadeIn 0.4s ease;
}

.welcome-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: inline-block;
}

.welcome-card h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.welcome-card p {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.prompt-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.prompt-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* Message Bubble */
.message {
  display: flex;
  gap: 12px;
  max-width: 82%;
  animation: slideUp 0.25s ease-out forwards;
}

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

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

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--primary-light);
  border: 1px solid var(--border);
}

.message.user .msg-avatar {
  background: rgba(255, 255, 255, 0.1);
}

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

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.55;
  position: relative;
  word-break: break-word;
}

.message.user .msg-bubble {
  background: var(--primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.message.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.msg-bubble p {
  margin-bottom: 8px;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble ul, .msg-bubble ol {
  margin-left: 20px;
  margin-bottom: 8px;
}

.msg-bubble code {
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
}

.msg-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.message.user .msg-meta {
  justify-content: flex-end;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Input Footer */
.app-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 8px 6px 16px;
  transition: all 0.2s ease;
}

.input-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-field {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.4;
  padding: 6px 0;
  outline: none;
}

.input-field::placeholder {
  color: var(--text-muted);
}

.btn-send {
  background: var(--primary);
  color: white;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  font-size: 1.1rem;
}

.btn-send:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.footer-disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* Modal Settings */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
}

.btn-save {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.2s;
}

.btn-save:hover {
  background: var(--primary-hover);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Mobile responsive */
@media (max-width: 768px) {
  body {
    padding: 0;
  }
  .app-wrapper {
    height: 100vh;
    max-width: 100%;
    border-radius: 0;
    border: none;
  }
  .message {
    max-width: 92%;
  }
  .welcome-card {
    padding: 18px;
    margin: 10px auto;
  }
}
