:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-2: #232d3b;
  --border: #2f3d4f;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #25d366;
  --accent-dim: #1da851;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --wa-bg: #0b141a;
  --wa-bubble: #005c4b;
  --wa-chat-bg: #0a1014;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 10% 0%, rgba(37, 211, 102, 0.12), transparent),
    radial-gradient(ellipse 50% 35% at 90% 10%, rgba(59, 130, 246, 0.1), transparent);
  z-index: 0;
}

.header,
.layout,
.footer {
  position: relative;
  z-index: 1;
}

.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
}

.logo {
  font-size: 2rem;
  width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field-group {
  border: none;
  margin: 0 0 1.25rem;
  padding: 0;
}

.field-group legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.field input:invalid:not(:placeholder-shown),
.field textarea:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 500px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, opacity 0.15s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-whatsapp {
  background: var(--accent);
  color: #fff;
}

.btn-whatsapp:hover:not(:disabled) {
  background: var(--accent-dim);
}

.preview-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.preview-header h2 {
  margin: 0;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.whatsapp-frame {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #1f2c37;
  margin-bottom: 1rem;
}

.whatsapp-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  background: #1f2c33;
}

.wa-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #6b7c8a;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.wa-chat-title {
  font-size: 0.9rem;
  font-weight: 500;
}

.whatsapp-chat {
  min-height: 280px;
  max-height: 420px;
  overflow-y: auto;
  padding: 1rem;
  background: var(--wa-chat-bg)
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23182229' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.message-bubble {
  max-width: 92%;
  margin-left: auto;
  padding: 0.55rem 0.7rem 0.45rem;
  background: var(--wa-bubble);
  border-radius: 8px 8px 2px 8px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.message-bubble .placeholder {
  margin: 0;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.85rem;
}

.message-bubble strong {
  font-weight: 700;
}

.message-bubble em {
  font-style: italic;
}

.message-bubble a {
  color: #7fd4ff;
  text-decoration: underline;
}

.message-bubble .line-block {
  margin: 0 0 0.35rem;
}

.message-bubble .line-block:last-child {
  margin-bottom: 0;
}

.message-bubble .spacer {
  height: 0.5rem;
}

.raw-output textarea {
  font-family: "Consolas", "Monaco", monospace;
  font-size: 0.8rem;
  resize: vertical;
  min-height: 180px;
}

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer code {
  background: var(--surface-2);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 100;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}
