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

:root {
  --bg:       #09090b;
  --bg2:      #0f0f12;
  --bg3:      #18181c;
  --bg4:      #222228;
  --border:   rgba(255,255,255,0.07);
  --border2:  rgba(255,255,255,0.12);
  --accent:   #FF5733;
  --accent2:  #ff7a5c;
  --accent-glow: rgba(255,87,51,0.18);
  --white:    #ffffff;
  --muted:    rgba(255,255,255,0.45);
  --muted2:   rgba(255,255,255,0.25);
  --radius:   16px;
  --radius-sm: 10px;
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--white);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Ambient background glows ── */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(255,87,51,0.06) 0%, transparent 70%);
  top: -200px; left: -100px;
}
.bg-glow-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(255,87,51,0.04) 0%, transparent 70%);
  bottom: -100px; right: -100px;
}

/* ── Layout ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(15,15,18,0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), #c43a1f);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 20px rgba(255,87,51,0.3);
}

.header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.header-subtitle {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.15);
  padding: 5px 10px;
  border-radius: 999px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.6);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-clear-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.header-clear-btn:hover {
  background: var(--bg4);
  color: var(--white);
  border-color: var(--border2);
}

/* ── Chat area ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar { width: 3px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

/* ── Empty state ── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 40px 20px;
  animation: fadeInUp 0.5s ease;
}

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

.empty-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, rgba(255,87,51,0.15), rgba(255,87,51,0.05));
  border: 1px solid rgba(255,87,51,0.25);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  box-shadow: 0 0 40px rgba(255,87,51,0.1);
}

.empty-state h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.02em;
}

.empty-state p {
  font-size: 0.83rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 380px;
}

.empty-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover {
  background: var(--bg4);
  border-color: rgba(255,87,51,0.35);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.chip-icon { font-size: 1rem; }

/* ── Messages ── */
.message {
  display: flex;
  gap: 12px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  animation: msgIn 0.25s ease;
}

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

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

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  align-self: flex-end;
}

.message.user .avatar {
  background: linear-gradient(135deg, var(--accent), #c43a1f);
  color: #fff;
  box-shadow: 0 0 12px rgba(255,87,51,0.3);
}
.message.ai .avatar {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--muted);
}

.bubble {
  padding: 13px 17px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.7;
  max-width: calc(100% - 46px);
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  background: linear-gradient(135deg, var(--accent), #d94520);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 20px rgba(255,87,51,0.25);
}

.message.ai .bubble {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--white);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

/* Markdown in AI bubbles */
.bubble strong { font-weight: 700; color: var(--accent2); }
.bubble em { font-style: italic; color: rgba(255,255,255,0.65); }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.bubble code {
  background: rgba(255,255,255,0.07);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.82em;
}

/* Images in bubble */
.bubble img {
  max-width: 100%;
  border-radius: 10px;
  margin-top: 8px;
  display: block;
}

/* Attachment preview */
.attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 0.78rem;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 6px 4px;
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Message label (Mensagem X de Y) ── */
.msg-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  opacity: 0.75;
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg-label::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.6;
}

/* ── Input area ── */
.input-area {
  flex-shrink: 0;
  padding: 12px 20px 18px;
  background: rgba(15,15,18,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}

.input-wrap {
  max-width: 780px;
  margin: 0 auto;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 10px 10px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap:focus-within {
  border-color: rgba(255,87,51,0.4);
  box-shadow: 0 0 0 3px rgba(255,87,51,0.07);
}

.input-wrap.drag-over {
  border-color: rgba(255,87,51,0.6);
  background: rgba(255,87,51,0.03);
  box-shadow: 0 0 0 3px rgba(255,87,51,0.1);
}

/* Attachment strip */
.attach-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 0;
}

.attach-thumb {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border2);
  flex-shrink: 0;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }

.attach-thumb-file {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  background: rgba(255,87,51,0.08);
  border: 1px solid rgba(255,87,51,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.6rem;
  color: var(--muted);
  flex-shrink: 0;
}

.attach-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  background: rgba(0,0,0,0.75);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.6rem;
  color: #fff;
  border: none;
}

/* Voice bar */
.audio-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: rgba(239,68,68,0.08);
  border-radius: 10px;
  border: 1px solid rgba(239,68,68,0.2);
}
.audio-bar.active { display: flex; }

.audio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239,68,68,0.7);
  animation: pulse-record 1s infinite;
  flex-shrink: 0;
}

@keyframes pulse-record {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.audio-timer {
  font-size: 0.75rem;
  font-weight: 600;
  color: #ef4444;
}

.audio-wave {
  flex: 1;
  height: 22px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.audio-wave span {
  display: inline-block;
  width: 3px;
  background: rgba(239,68,68,0.5);
  border-radius: 3px;
  animation: wave-anim 0.8s ease-in-out infinite;
  height: 6px;
}
.audio-wave span:nth-child(2) { animation-delay: 0.1s; }
.audio-wave span:nth-child(3) { animation-delay: 0.2s; }
.audio-wave span:nth-child(4) { animation-delay: 0.3s; }
.audio-wave span:nth-child(5) { animation-delay: 0.2s; }
.audio-wave span:nth-child(6) { animation-delay: 0.1s; }
.audio-wave span:nth-child(7) { animation-delay: 0.0s; }

@keyframes wave-anim {
  0%, 100% { height: 5px; }
  50% { height: 18px; }
}

.audio-cancel {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(239,68,68,0.7);
  cursor: pointer;
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  transition: color 0.2s;
}
.audio-cancel:hover { color: #ef4444; }

/* Input row */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--white);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  resize: none;
  min-height: 26px;
  max-height: 180px;
  line-height: 1.55;
  padding: 5px 0;
}
textarea::placeholder { color: var(--muted2); }

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.action-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, color 0.18s;
  flex-shrink: 0;
}
.action-btn:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.action-btn.recording {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #d94520);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.18s, transform 0.1s, box-shadow 0.18s;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(255,87,51,0.35);
}
.send-btn:hover { opacity: 0.88; box-shadow: 0 4px 20px rgba(255,87,51,0.45); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { background: rgba(255,87,51,0.25); box-shadow: none; cursor: not-allowed; }

.input-hint {
  font-size: 0.66rem;
  color: var(--muted2);
  text-align: center;
  padding-top: 8px;
  max-width: 780px;
  margin: 0 auto;
  letter-spacing: 0.01em;
}

.input-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  font-size: 0.64rem;
  color: rgba(255,255,255,0.4);
}

/* ── Copy button ── */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.7rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.copy-btn:hover { background: rgba(255,255,255,0.08); color: var(--white); border-color: rgba(255,255,255,0.18); }
.copy-btn.copied { color: #22c55e; border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.05); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .header { padding: 12px 16px; }
  .header-subtitle, .header-clear-btn span { display: none; }
  .chat-area { padding: 20px 12px; }
  .input-area { padding: 10px 12px 16px; }
  .bubble { font-size: 0.84rem; }
}
