/* ==========================================================
   NEXYRA AI - TEMA ESCURO ROXO (DARK PURPLE AESTHETIC)
   ========================================================== */

:root {
  /* Paleta de Cores Roxo Escuro */
  --bg-app: #090611;
  --bg-sidebar: #0f0b1c;
  --bg-surface: #150f28;
  --bg-surface-elevated: #1d1637;
  --bg-card: #20183e;
  --bg-input: #17112d;

  /* Bordas e Divisões */
  --border-subtle: rgba(168, 85, 247, 0.12);
  --border-medium: rgba(168, 85, 247, 0.25);
  --border-focus: rgba(192, 132, 252, 0.6);

  /* Acentos de Roxo */
  --purple-glow: rgba(168, 85, 247, 0.28);
  --purple-accent: #a855f7;
  --purple-vibrant: #c084fc;
  --purple-deep: #7e22ce;
  --purple-dark: #581c87;
  
  /* Gradientes */
  --gradient-purple: linear-gradient(135deg, #7e22ce 0%, #9333ea 50%, #c084fc 100%);
  --gradient-bubble-user: linear-gradient(135deg, #6b21a8 0%, #7e22ce 50%, #9333ea 100%);
  --gradient-glow: radial-gradient(circle, rgba(168, 85, 247, 0.25) 0%, rgba(9, 6, 17, 0) 70%);

  /* Textos */
  --text-primary: #f5f3ff;
  --text-secondary: #d8b4fe;
  --text-muted: #8e7ea5;
  --text-inverted: #090611;

  /* Status */
  --status-green: #10b981;
  --status-warning: #f59e0b;
  --status-danger: #ef4444;

  /* Tipografia */
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transições e Sombras */
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 0 15px rgba(147, 51, 234, 0.1);
  --shadow-glow: 0 0 25px rgba(168, 85, 247, 0.35);
  --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(168, 85, 247, 0.2);
}

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

html {
  height: 100%;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars estilizadas */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.25);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.45);
}

/* Layout Geral */
.app-layout {
  display: flex;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  background-color: var(--bg-app);
  position: relative;
  overflow: hidden;
}

/* ==========================================================
   SIDEBAR
   ========================================================== */

.sidebar {
  width: 290px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: var(--transition);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gradient-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

.avatar-glow {
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: var(--gradient-purple);
  opacity: 0.6;
  filter: blur(6px);
  z-index: -1;
  animation: pulse-glow 3s ease-in-out infinite alternate;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #e9d5ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.sidebar-actions {
  padding: 0 18px 14px;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.25) 0%, rgba(168, 85, 247, 0.15) 100%);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.new-chat-btn:hover {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.45) 0%, rgba(168, 85, 247, 0.25) 100%);
  border-color: var(--purple-accent);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.25);
  transform: translateY(-1px);
}

.conversations-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}

.conversations-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-muted);
}

.clear-all-chats-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}

.clear-all-chats-btn:hover {
  color: var(--status-danger);
  background: rgba(239, 68, 68, 0.1);
}

.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chat-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  overflow: hidden;
  position: relative;
}

.chat-history-item:hover {
  background: rgba(168, 85, 247, 0.08);
  color: var(--text-primary);
}

.chat-history-item.active {
  background: rgba(168, 85, 247, 0.16);
  border-color: var(--border-medium);
  color: #fff;
  font-weight: 600;
}

.chat-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-item-delete {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}

.chat-history-item:hover .chat-item-delete {
  opacity: 1;
}

.chat-item-delete:hover {
  color: var(--status-danger);
}

.empty-history-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 30px;
  padding: 0 10px;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 11, 28, 0.6);
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--purple-vibrant);
  max-width: 190px;
}

.model-badge span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================
   ÁREA PRINCIPAL DO CHAT
   ========================================================== */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  position: relative;
  background: radial-gradient(ellipse at top right, rgba(126, 34, 206, 0.08) 0%, rgba(9, 6, 17, 1) 60%);
  overflow: hidden;
}

/* Cabeçalho */
.chat-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(9, 6, 17, 0.75);
  backdrop-filter: blur(14px);
  z-index: 10;
}

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

.chat-meta {
  display: flex;
  flex-direction: column;
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-green);
  box-shadow: 0 0 10px var(--status-green);
  animation: pulse-dot 2.5s infinite;
}

.chat-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-model-indicator {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

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

/* Botões de Ação */
.icon-btn, .action-btn {
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-family: inherit;
}

.icon-btn {
  width: 36px;
  height: 36px;
}

.action-btn {
  padding: 7px 14px;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}

.icon-btn:hover, .action-btn:hover {
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--purple-accent);
  color: #fff;
}

.toggle-sidebar-btn {
  display: none;
}

.close-sidebar-btn {
  display: none;
}

/* Banner de Alerta de API Key */
.api-alert-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, rgba(147, 51, 234, 0.15) 100%);
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.alert-content {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fde68a;
  font-size: 0.86rem;
}

.alert-icon {
  color: var(--status-warning);
  flex-shrink: 0;
}

.alert-action-btn {
  background: rgba(245, 158, 11, 0.25);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.alert-action-btn:hover {
  background: rgba(245, 158, 11, 0.4);
}

/* ==========================================================
   CONTAINER DE MENSAGENS
   ========================================================== */

.messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 20px 10px;
  display: flex;
  flex-direction: column;
  position: relative;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Tela de Boas-Vindas */
.welcome-screen {
  max-width: 780px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 10px;
  animation: fadeIn 0.4s ease-out;
}

.welcome-avatar-wrapper {
  position: relative;
  margin-bottom: 24px;
}

.welcome-glow {
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  background: var(--gradient-purple);
  filter: blur(25px);
  opacity: 0.45;
  animation: pulse-glow 3s infinite alternate;
}

.welcome-avatar {
  width: 74px;
  height: 74px;
  border-radius: 22px;
  background: var(--gradient-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
  box-shadow: 0 8px 30px rgba(126, 34, 206, 0.4);
}

.welcome-avatar svg {
  width: 38px;
  height: 38px;
}

.welcome-title {
  font-size: 2.1rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.gradient-text {
  background: linear-gradient(135deg, #c084fc 0%, #a855f7 50%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 580px;
  margin-bottom: 36px;
  line-height: 1.6;
}

/* Cards de Sugestões de Prompt */
.prompt-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
}

.suggestion-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  color: var(--text-primary);
}

.suggestion-card:hover {
  background: var(--bg-card);
  border-color: var(--purple-accent);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
  transform: translateY(-2px);
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--purple-vibrant);
  flex-shrink: 0;
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-content strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
}

.card-content span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================
   LISTA DE MENSAGENS DO CHAT
   ========================================================== */

.messages-list {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.message-row {
  display: flex;
  gap: 16px;
  animation: messageSlideIn 0.25s ease-out;
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.user-avatar {
  background: #3b2d54;
  color: #e9d5ff;
  border: 1px solid var(--border-medium);
}

.nexyra-avatar {
  background: var(--gradient-purple);
  color: #fff;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.4);
}

.message-bubble-wrapper {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-row.user-message-row .message-bubble-wrapper {
  align-items: flex-end;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.96rem;
  word-break: break-word;
  position: relative;
  line-height: 1.65;
}

/* Balão do Usuário */
.user-bubble {
  background: var(--gradient-bubble-user);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(126, 34, 206, 0.25);
}

/* Balão da Nexyra */
.nexyra-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

/* Ações da Mensagem */
.message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: var(--transition);
  margin-top: 4px;
}

.message-row:hover .message-actions {
  opacity: 1;
}

.msg-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.msg-action-btn:hover {
  color: var(--purple-vibrant);
  background: rgba(168, 85, 247, 0.12);
}

/* ==========================================================
   FORMATAÇÃO MARKDOWN NO BALÃO DA NEXYRA
   ========================================================== */

.nexyra-bubble p {
  margin-bottom: 12px;
}

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

.nexyra-bubble h1, 
.nexyra-bubble h2, 
.nexyra-bubble h3, 
.nexyra-bubble h4 {
  color: #fff;
  margin-top: 18px;
  margin-bottom: 10px;
  font-weight: 700;
  line-height: 1.3;
}

.nexyra-bubble h1 { font-size: 1.45rem; color: #e9d5ff; border-bottom: 1px solid var(--border-subtle); padding-bottom: 6px; }
.nexyra-bubble h2 { font-size: 1.25rem; color: #d8b4fe; }
.nexyra-bubble h3 { font-size: 1.1rem; color: #c084fc; }

.nexyra-bubble ul, 
.nexyra-bubble ol {
  margin-left: 20px;
  margin-bottom: 14px;
}

.nexyra-bubble li {
  margin-bottom: 6px;
}

.nexyra-bubble strong {
  color: #fff;
  font-weight: 700;
}

.nexyra-bubble a {
  color: var(--purple-vibrant);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.nexyra-bubble a:hover {
  color: #e9d5ff;
}

.nexyra-bubble blockquote {
  border-left: 3px solid var(--purple-accent);
  padding-left: 14px;
  margin: 12px 0;
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(168, 85, 247, 0.05);
  border-radius: 0 8px 8px 0;
  padding: 8px 14px;
}

.nexyra-bubble code:not(pre code) {
  background: rgba(168, 85, 247, 0.16);
  color: #e9d5ff;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.nexyra-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

.nexyra-bubble th, 
.nexyra-bubble td {
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  text-align: left;
}

.nexyra-bubble th {
  background: rgba(168, 85, 247, 0.12);
  color: #fff;
  font-weight: 600;
}

/* Blocos de Código Pré-formatados */
.code-block-wrapper {
  margin: 16px 0;
  border-radius: 12px;
  background: #0d0818;
  border: 1px solid var(--border-medium);
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(23, 17, 45, 0.9);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.copy-code-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-family: var(--font-main);
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.copy-code-btn:hover {
  color: #fff;
  background: rgba(168, 85, 247, 0.2);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.55;
  background: transparent !important;
}

/* Indicador de Digitação (Streaming / Pensando) */
.typing-indicator {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: 16px;
  align-items: center;
}

.typing-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 12px 18px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.typing-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 6px;
}

/* Cursor de streaming */
.streaming-cursor::after {
  content: '▋';
  display: inline-block;
  margin-left: 2px;
  color: var(--purple-vibrant);
  animation: cursorBlink 0.8s infinite;
}

/* ==========================================================
   BOTÃO DE ROLAGEM FLUTUANTE
   ========================================================== */

.scroll-bottom-btn {
  position: absolute;
  bottom: 120px;
  right: 28px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--purple-vibrant);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 10px rgba(168, 85, 247, 0.2);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 15;
  transition: var(--transition);
}

.scroll-bottom-btn:hover {
  background: var(--purple-accent);
  color: #fff;
  transform: translateY(-2px);
}

/* ==========================================================
   RODAPÉ E CAMPO DE ENTRADA (INPUT)
   ========================================================== */

.chat-input-area {
  padding: 12px 24px 18px;
  background: linear-gradient(180deg, rgba(9, 6, 17, 0) 0%, rgba(9, 6, 17, 0.92) 35%, rgba(9, 6, 17, 1) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
  width: 100%;
  box-sizing: border-box;
}

.input-box-wrapper {
  max-width: 860px;
  width: 100%;
  background: rgba(23, 17, 45, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(168, 85, 247, 0.22);
  border-radius: 28px;
  padding: 8px 10px 8px 18px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 15px rgba(168, 85, 247, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.input-box-wrapper:focus-within {
  border-color: rgba(192, 132, 252, 0.65);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 25px rgba(168, 85, 247, 0.22);
}

#chatInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.96rem;
  line-height: 1.45;
  resize: none;
  max-height: 180px;
  min-height: 24px;
  padding: 7px 0;
  margin: 0;
  box-sizing: border-box;
}

#chatInput::placeholder {
  color: var(--text-muted);
}

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

.stop-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  border-radius: 20px;
  height: 38px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  box-sizing: border-box;
}

.stop-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gradient-purple);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 2px 10px rgba(147, 51, 234, 0.4);
  flex-shrink: 0;
}

.send-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.3;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 4px 18px rgba(168, 85, 247, 0.6);
}

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

.chat-footer-info {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================
   MODAL DE CONFIGURAÇÕES
   ========================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 2, 8, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--purple-vibrant);
}

.modal-title h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.api-status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}

.api-status-card.configured .status-icon {
  color: var(--status-green);
}

.api-status-card.not-configured .status-icon {
  color: var(--status-warning);
}

.status-details {
  display: flex;
  flex-direction: column;
}

.status-details strong {
  font-size: 0.9rem;
}

.status-details small {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.settings-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.settings-select:focus {
  border-color: var(--purple-accent);
}

.settings-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.settings-hint code {
  color: var(--purple-vibrant);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-val {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--purple-vibrant);
  font-weight: 700;
}

.settings-slider {
  accent-color: var(--purple-accent);
  width: 100%;
  cursor: pointer;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.setup-guide-box {
  background: rgba(168, 85, 247, 0.06);
  border: 1px dashed var(--border-medium);
  border-radius: 12px;
  padding: 14px 16px;
}

.setup-guide-box h4 {
  font-size: 0.88rem;
  color: var(--purple-vibrant);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-guide-box ol {
  margin-left: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.setup-guide-box a {
  color: var(--purple-vibrant);
  text-decoration: underline;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--gradient-purple);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(147, 51, 234, 0.4);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
}

/* ==========================================================
   ANIMAÇÕES
   ========================================================== */

@keyframes pulse-glow {
  0% { transform: scale(0.96); opacity: 0.4; }
  100% { transform: scale(1.04); opacity: 0.8; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

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

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

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================
   RESPONSIVIDADE
   ========================================================== */

@media (max-width: 768px) {
  /* Layout e Viewport */
  .app-layout {
    height: 100dvh;
    width: 100%;
    overflow: hidden;
  }

  .chat-main {
    height: 100dvh;
    width: 100%;
    min-height: 0;
    overflow: hidden;
  }

  /* Sidebar Mobile */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 290px;
    max-width: 85vw;
    transform: translateX(-100%);
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.9);
    z-index: 60;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 55;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .toggle-sidebar-btn {
    display: inline-flex;
  }

  .close-sidebar-btn {
    display: inline-flex;
  }

  /* Cabeçalho Compacto Mobile */
  .chat-header {
    height: 54px;
    min-height: 54px;
    padding: 0 12px;
  }

  .header-left {
    gap: 10px;
    min-width: 0;
    flex: 1;
  }

  .chat-meta {
    min-width: 0;
  }

  .chat-title {
    font-size: 0.9rem;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-model-indicator {
    font-size: 0.65rem;
  }

  .header-actions {
    gap: 6px;
  }

  .action-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
    justify-content: center;
    gap: 0;
  }

  .btn-text {
    display: none;
  }

  .action-btn svg,
  .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Container e Balões de Mensagem */
  .messages-container {
    flex: 1;
    min-height: 0;
    padding: 12px 10px 6px;
    -webkit-overflow-scrolling: touch;
  }

  .messages-list {
    gap: 14px;
    width: 100%;
  }

  .message-row {
    gap: 8px;
    width: 100%;
  }

  .nexyra-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 0.75rem;
  }

  .nexyra-avatar svg {
    width: 15px;
    height: 15px;
  }

  /* Oculta o avatar do usuário no mobile para dar largura total ao balão */
  .user-message-row .user-avatar {
    display: none !important;
  }

  .message-bubble-wrapper {
    max-width: calc(100% - 36px);
  }

  .message-row.user-message-row .message-bubble-wrapper {
    max-width: 88%;
    margin-left: auto;
  }

  .message-bubble {
    padding: 10px 14px;
    font-size: 0.91rem;
    line-height: 1.55;
    border-radius: 14px;
  }

  .message-actions {
    opacity: 1;
    margin-top: 2px;
  }

  .msg-action-btn {
    padding: 3px 6px;
    font-size: 0.72rem;
  }

  .markdown-body pre {
    padding: 10px 12px;
    font-size: 0.8rem;
    border-radius: 10px;
    margin: 8px 0;
  }

  /* Tela de Boas-Vindas Mobile */
  .welcome-screen {
    padding: 12px 6px;
  }

  .welcome-avatar-wrapper {
    margin-bottom: 12px;
  }

  .welcome-avatar {
    width: 52px;
    height: 52px;
    border-radius: 16px;
  }

  .welcome-avatar svg {
    width: 26px;
    height: 26px;
  }

  .welcome-title {
    font-size: 1.35rem;
    margin-bottom: 6px;
  }

  .welcome-desc {
    font-size: 0.82rem;
    line-height: 1.45;
    margin-bottom: 16px;
    padding: 0 4px;
  }

  .prompt-suggestions {
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
  }

  .suggestion-card {
    padding: 10px 12px;
    gap: 10px;
    border-radius: 12px;
  }

  .card-icon {
    width: 32px;
    height: 32px;
  }

  .card-icon svg {
    width: 16px;
    height: 16px;
  }

  .card-content strong {
    font-size: 0.84rem;
  }

  .card-content span {
    font-size: 0.72rem;
  }

  /* Campo de Digitação Mobile */
  .chat-input-area {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
    background: rgba(9, 6, 17, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0;
    gap: 6px;
  }

  .input-box-wrapper {
    border-radius: 24px;
    padding: 6px 8px 6px 14px;
    gap: 8px;
    background: rgba(23, 17, 45, 0.9);
  }

  #chatInput {
    /* 16px impede o zoom automático do iOS Safari e Android ao focar o campo */
    font-size: 16px !important;
    padding: 6px 0;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.4;
  }

  .send-btn {
    width: 36px;
    height: 36px;
  }

  .send-btn svg {
    width: 16px;
    height: 16px;
  }

  .stop-btn {
    height: 36px;
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .chat-footer-info {
    font-size: 0.66rem;
    opacity: 0.7;
  }

  .scroll-bottom-btn {
    bottom: 78px;
    right: 14px;
    width: 34px;
    height: 34px;
  }

  .modal-card {
    max-width: 94%;
    max-height: 90vh;
    padding: 18px 16px;
  }
}

@media (max-width: 480px) {
  .chat-title {
    max-width: 110px;
  }

  .chat-footer-info {
    display: none;
  }
}
