body.chat-page {
  font-family: 'Roboto', sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  height: 100vh;
  height: 100dvh; /* Dynamic viewport para acompanhar o teclado no celular */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Mobile responsive adjustments --- */
@media (max-width: 868px) {
  /* Header full width */
  .app-header {
    width: 100vw !important;
    left: 0;
  }

  .header-content {
    position: relative;
    justify-content: flex-start;
    gap: 4px;
  }

  /* Ocultar barra de rolagem no celular */
  #chat-container::-webkit-scrollbar,
  #chat-history::-webkit-scrollbar,
  .textarea-container textarea::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
  }
  #chat-container,
  #chat-history,
  .textarea-container textarea {
    -ms-overflow-style: none !important;  /* IE and Edge */
    scrollbar-width: none !important;  /* Firefox */
  }

  /* Mobile-only helpers */
  .mobile-only {
    display: inline-flex !important;
  }

  /* Theme-based logo visibility on mobile */
  .header-logo.dark-theme-logo {
    display: inline-block !important;
  }
  .header-logo.light-theme-logo {
    display: none !important;
  }
  .light-theme .header-logo.dark-theme-logo,
  [data-theme="light"] .header-logo.dark-theme-logo {
    display: none !important;
  }
  .light-theme .header-logo.light-theme-logo,
  [data-theme="light"] .header-logo.light-theme-logo {
    display: inline-block !important;
  }

  .header-logo {
    position: absolute;
    right: 1rem;
    left: auto;
    transform: none;
    height: 36px;
    pointer-events: auto;
    cursor: pointer;
  }

  #mobile-menu-toggle {
    margin-right: 0;
    width: 44px;
    height: 44px;
    font-size: 20px;
    flex-shrink: 0;
  }

  /* Model selector stays in header on mobile — ghost/text style like reasoning-vol-btn */
  .app-header .model-select-container {
    display: block;
  }

  /* Show action-buttons model-select-container as none — it stays in header only */
  .action-buttons .model-select-container {
    display: none !important;
  }

  /* Stack model + reasoning vertically in header */
  .header-controls-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  /* Ghost style for model-header-btn on mobile (matches reasoning-vol-btn) */
  .app-header .model-header-btn {
    background: none !important;
    border: none !important;
    outline: none !important;
    color: var(--color-text-secondary);
    padding: 4px 6px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.2s ease;
    height: auto;
    width: auto;
  }

  .app-header .model-header-btn:hover,
  .app-header .model-header-btn.active {
    color: var(--color-accent-primary);
  }

  .app-header .model-header-btn i {
    font-size: 10px;
    transition: transform 0.2s ease;
  }

  .app-header .model-header-btn.active i {
    transform: rotate(180deg);
  }

  /* Model dropdown — opens downward from header, fixed width */
  .app-header .model-dropdown {
    position: fixed !important;
    top: auto !important;
    left: 1rem !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: calc(100vw - 2rem) !important;
    max-width: 360px !important;
    z-index: 10001 !important;
    background-color: var(--color-surface) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 24px 64px rgba(0,0,0,0.55) !important;
    border-radius: 16px !important;
    max-height: 60vh;
    overflow-y: auto;
  }

  .app-header .model-dropdown.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Sidebar hidden by default on mobile (unless overlay open) */
  #sidebar-container:not(.mobile-open) {
    display: none !important;
  }

  /* When opened as overlay */
  #sidebar-container.mobile-open {
    display: block;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Acompanha a altura real da viewport no mobile */
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    overflow-y: auto;
  }

  /* Garante que o card de perfil não fique atrás do home indicator/gestos do sistema */
  #sidebar-container.mobile-open .sidebar-footer {
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  #sidebar-container.mobile-open #conversation-history-sidebar {
    width: 100%;
    height: 100%;
    box-shadow: none;
    background-color: var(--color-bg-secondary);
  }

  /* Ensure toggle button visible as close button on overlay */
  #sidebar-container.mobile-open #toggle-sidebar {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 1001;
  }

  /* Hide collapsed-specific elements in overlay if any leftover */
  #sidebar-container.mobile-open .collapsed-logo,
  #sidebar-container.mobile-open #reopen-sidebar {
    display: none !important;
  }

  /* Remove sidebar margins on mobile */
  #chat-container,
  .app-container.sidebar-collapsed #chat-container {
    margin-left: 0 !important;
    padding-left: var(--spacing-md) !important;
    padding-right: var(--spacing-md) !important;
  }
}

/* --- <=1024px: Shrink collapsed sidebar --- */
@media (max-width: 1024px) {
  /* Override variable so all dependent layouts follow */
  :root { --sidebar-collapsed-width: 2rem; }

  /* Ensure min-width doesn't block shrinking */
  #sidebar-container.collapsed {
    width: var(--sidebar-collapsed-width) !important;
    min-width: var(--sidebar-collapsed-width) !important;
  }

  /* Reduce logo size in collapsed state */
  #sidebar-container.collapsed .collapsed-logo {
    height: 2.7rem;
    width: 2.7rem;
    top: 0.5rem;
  }

  /* Reduce profile picture size */
  #sidebar-container.collapsed .sidebar-profile {
    width: 24px;
    height: 24px;
    bottom: 10px;
  }

  /* Dependent layout areas already use the variable; keep consistent */
  .app-container.sidebar-collapsed #chat-container {
    margin-left: var(--sidebar-collapsed-width);
  }

  .app-container.sidebar-collapsed .app-header {
    width: calc(100% - var(--sidebar-collapsed-width));
  }
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Container da Sidebar */
#sidebar-container {
  width: var(--sidebar-width);
  height: 100vh;
  flex-shrink: 0;
  background-color: var(--color-bg-secondary);
  transition: width var(--transition-speed) var(--transition-function);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 150;
  box-shadow: 6px 0 30px rgba(0,0,0,0.5);
}

/* Light mode: no shadow, no border — background matches header seamlessly */
.light-theme #sidebar-container {
  box-shadow: none;
}

/* Estado colapsado da Sidebar (merge de regras duplicadas) */
#sidebar-container.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: 5rem;
  background-color: var(--color-bg-secondary);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: fixed;
  box-shadow: none;
}

/* Ocultar conte├║dos internos quando a sidebar est├í colapsada */
#sidebar-container.collapsed #conversation-history-sidebar,
#sidebar-container.collapsed .sidebar-header,
#sidebar-container.collapsed .conversation-list,
#sidebar-container.collapsed .new-chat-button,
#sidebar-container.collapsed #sapiens-logo,
#sidebar-container.collapsed .sidebar-content,
#sidebar-container.collapsed .sidebar-footer span,
#sidebar-container.collapsed .sidebar-header h3 {
  display: none;
}

/* Ajuste espec├¡fico para o hist├│rico de conversas quando colapsado */
#sidebar-container.collapsed #conversation-history-sidebar {
  visibility: hidden;
  width: 0;
}

/* Toggle button: posi├º├úo diferenciada para estados colapsado e expandido */
#toggle-sidebar {
  background-color: transparent;
  border: 1px solid transparent;
  color: var(--color-text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  margin-right: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
  z-index: 5;
  width: 32px;
  height: 32px;
  align-self: center;
  order: 2;
}

#toggle-sidebar img {
  width: 2rem;
  height: 2rem;
  border: none;
  filter: invert(80%) sepia(12%) saturate(236%) hue-rotate(179deg) brightness(97%) contrast(92%);
}

#sidebar-container.collapsed #toggle-sidebar {
  position: absolute;
  left: 10px;
  top: 10px;
  margin: 0;
  z-index: 26 !important;
  display: flex !important;
  justify-content: center;
  align-items: center;
  width: 100%;
}

#sidebar-container:not(.collapsed) #toggle-sidebar {
  position: relative;
  display: flex;
}

#toggle-sidebar:hover {
  background-color: rgba(255,255,255,0.07);
  border-color: var(--glass-border);
  color: var(--color-accent-primary);
}

/* Logo no sidebar  */
.collapsed-logo {
  display: none;
  height: 4.6rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  filter: brightness(0.9);

}

/* Logo no sidebar colapsado  */
#sidebar-container.collapsed .collapsed-logo {
  display: block;
  height: 4.6rem;
  position: absolute;
  top: 2rem; 
  left: 50%;
  transform: translateX(-50%);
  object-fit: scale-down;
  z-index: 1000;
}

/* Foto de perfil no rodap├® - Escondida por padr├úo */
.sidebar-profile {
  display: none;
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  z-index: 22;
  cursor: pointer;
}

/* Ajustar imagem de perfil para caber no c├¡rculo */
.sidebar-profile .profile-picture {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Foto de perfil vis├¡vel apenas quando o sidebar est├í colapsado */
#sidebar-container.collapsed .sidebar-profile {
  display: block;
}

/* ├ìcone padr├úo para usu├írio sem foto */
.default-profile-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-tertiary);
}

.default-profile-icon i {
  font-size: 1.5rem;
  color: var(--color-text-secondary);
}

/* Ajustar posi├º├úo do bot├úo de toggle */
#sidebar-container.collapsed #toggle-sidebar {
  top: 20px;
}

/* Bot├úo para reabrir a sidebar  */
#reopen-sidebar {
  position: absolute;
  top: 8rem;
  z-index: 27;
  background-color: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  padding: 0; 
}

#reopen-sidebar img {
  height: 2.4rem;
  filter: invert(79%) sepia(12%) saturate(236%) hue-rotate(179deg) brightness(100%) contrast(92%);
  position: relative;
  background-color: transparent;
}

/* Reduce reopen icon size on smaller screens (<1024px) */
@media (max-width: 1024px) {
  #reopen-sidebar img {
    height: 1.6rem;
  }
}

/* Regra expl├¡cita para mostrar o bot├úo quando collapsed */
#sidebar-container.collapsed #reopen-sidebar {
  opacity: 1 !important;
  visibility: visible !important;
}

#conversation-history-sidebar {
  width: 300px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  background-color: var(--color-bg-secondary);
  padding: 0;
  z-index: 21;
}

#conversation-history-sidebar.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  visibility: hidden;
  margin-left: -300px;
  overflow: hidden;
  border-right: none;
  transition: all 0.3s ease;
}

/* Cabe├ºalho da Sidebar */
.sidebar-header {
  padding: 0.9rem;
  background-color: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-separator);
  position: sticky;
  top: 0;
  z-index: 6;
}

.sidebar-header h3 {
  margin: 0;
  margin-bottom: 16px;
  color: var(--color-accent-primary);
}

/* Cont├¬iner para controles do header - modificado para justificar entre os elementos */
.header-controls {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  justify-content: space-between; /* Alterado para espa├ºar o logo e bot├úo */
  position: relative;
  width: 100%; /* Garantir que ocupe toda a largura */
}

.header-controls #sapiens-logo {
  height: 3.5rem;
  margin-left: 0; /* Removido o margin-left */
  order: 1; /* Define a ordem para ser o primeiro elemento */
}

/* Lista de conversas e itens */
.conversation-list {
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden; 
  flex-grow: 1;
  width: 100%; 
  box-sizing: border-box;
}

/* Ajuste nos itens de conversa no sidebar */
.conversation-item {
  margin-bottom: 4px;
  border-radius: 10px;
  background-color: transparent;
  border: 1px solid transparent;
  overflow: hidden;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.conversation-item:hover {
  background-color: rgba(255,255,255,0.05);
  border-color: var(--glass-border);
}

.conversation-item.active {
  background-color: rgba(0,141,163,0.12);
  border-color: rgba(0,141,163,0.3);
}

/* Redu├º├úo do tamanho da fonte e ajustes no espa├ºamento */
.conversation-title-area a {
  flex: 1;
  text-decoration: none;
  color: var(--color-text-primary);
  padding: 10px; 
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem; 
}

/* Ocultar bot├úo de menu por padr├úo */
.conversation-menu-button {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 8px;
  font-size: 14px;
  margin-right: 8px;
  display: flex;
  align-items: center;
  opacity: 0; 
  transition: opacity 0.2s, color 0.2s;
}

/* Mostrar bot├úo de menu apenas no hover */
.conversation-item:hover .conversation-menu-button {
  opacity: 1;
}

.conversation-menu-button:hover {
  color: var(--color-accent-primary);
}

/* ├ürea do t├¡tulo e bot├úo de menu dentro de cada conversa */
.conversation-title-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.conversation-title-area a {
  flex: 1;
  text-decoration: none;
  color: var(--color-text-primary);
  padding: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Bot├úo do menu (tr├¬s pontinhos) e dropdown */
.conversation-menu-button {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 8px;
  font-size: 14px;
  margin-right: 8px;
  display: flex;
  align-items: center;
}

.conversation-menu-button:hover {
  color: var(--color-accent-primary);
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 45;
  min-width: 160px;
  background-color: var(--color-surface);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  display: none;
}

.dropdown-menu.show {
  display: block;
}

/* Force our design on all dropdown-menu contexts — defeat Bootstrap overrides */
.dropdown-menu,
[data-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .dropdown-menu,
body.dark-mode .dropdown-menu,
html[data-theme="dark"] .dropdown-menu {
  background-color: var(--color-surface) !important;
  border: 1px solid var(--glass-border) !important;
  color: var(--color-text-primary) !important;
}

.dropdown-item,
[data-theme="dark"] .dropdown-item,
[data-bs-theme="dark"] .dropdown-item,
body.dark-mode .dropdown-item,
html[data-theme="dark"] .dropdown-item {
  color: var(--color-text-primary) !important;
  background-color: transparent !important;
}

.dropdown-item:hover,
[data-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:hover,
body.dark-mode .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:hover {
  background-color: rgba(255,255,255,0.06) !important;
  color: var(--color-accent-primary) !important;
}

.dropdown-item {
  color: var(--color-text-primary);
  padding: 8px 12px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  transition: background-color 0.2s;
}

.dropdown-item:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-accent-primary);
}

.dropdown-item i {
  width: 16px;
  text-align: center;
}

/* Bot├úo para nova conversa */
#new-conversation-button {
  display: flex;
  align-items: center;
  width: calc(100% - 20px);
  margin: 4px 10px 10px;
  padding: 9px 14px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background-color: rgba(0,141,163,0.1);
  color: var(--color-accent-primary);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
  box-sizing: border-box;
}

#new-conversation-button i {
  margin-right: 9px;
  color: var(--color-accent-primary);
  font-size: 14px;
}

#new-conversation-button:hover {
  background-color: rgba(0,141,163,0.2);
  color: var(--color-accent-primary);
}

/* Agrupamento de conversas por data */
.conversation-group {
  margin-bottom: 20px;
}

.conversation-group-header {
  padding: 5px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.conversation-group-header h4 {
  margin: 0;
  font-size: 0.9em;
  color: var(--color-accent-primary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 0;
}

.conversation-group .conversation-item {
  margin-bottom: 5px;
}

/* Separador visual */
.visual-separator {
  width: 1px;
  height: 100%;
  background-color: var(--color-border);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

/* Container principal do Chat */
#chat-container {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-width: 0; /* Suporte para encolhimento com artefatos */
  background-color: var(--color-bg-primary);
  transition: all var(--transition-speed) ease-in-out;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 0 var(--spacing-md);
  position: relative;
}

/* Ajustes do chat quando o sidebar estiver recolhido */
.app-container.sidebar-collapsed {
  padding-left: 0 !important;
  margin-left: 0 !important;
  transition: all 0.3s ease;
}

.app-container.sidebar-collapsed #chat-container {
  margin-left: var(--sidebar-collapsed-width);
  padding: 0 var(--spacing-lg);
}

.app-container.sidebar-collapsed.full-width #chat-container {
  width: 100%;
  margin-left: 0;
}

/* ├ürea do Chat */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none; 
  margin: 0;
  position: relative;
  background-color: var(--color-bg-primary);
  border-left: 1px solid transparent;
  overflow: hidden;
  transition: all 0.3s ease;
  padding-bottom: 3rem;
}

#chat-area.full-width {
  width: 100%;
  margin-left: 0;
  border-left: none;
}

#chat-area::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background-color: var(--color-border);
  opacity: 100;
  transition: opacity 0.3s ease;
}

#chat-area.full-width::before {
  opacity: 1;
  width: 3px;
}

/* Chat header */
.chat-header {
  padding: 16px;
  border-bottom: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  background-color: var(--color-bg-tertiary);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  justify-content: center;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  opacity: 1; /* Tornar o cabe├ºalho vis├¡vel */
  box-sizing: border-box;
}

.chat-header h2 {
  margin: 0;
  flex: 1;
}

/* A├º├Áes do chat */
.chat-actions {
  display: flex;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  font-size: 16px;
  margin-left: 15px;
  padding: 5px;
}

.btn-icon:hover {
  color: var(--color-accent-primary);
}

/* Hist├│rico do chat */
#chat-history {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding-top: 76px;
  padding-bottom: 100px;
  padding-left: max(16px, calc(50% - 400px));
  padding-right: max(16px, calc(50% - 400px));
  transition: all var(--transition-speed) ease-in-out;
  scrollbar-width: thin; /* Para Firefox */
  scrollbar-color: var(--color-bg-tertiary) var(--color-bg-primary); /* Para Firefox */
}

/* Quando o chat est├í vazio, esconder o hist├│rico */
#chat-history.empty {
  opacity: 0;
}

/* Classe para esconder o hist├│rico quando vazio */
#chat-history.empty {
  display: none !important;
}

/* Adicionar espa├ºo para evitar que as mensagens fiquem por tr├ís do formul├írio fixo */
#chat-history:not(.empty) {
  padding-bottom: 120px;
}

/* Centralizar chat-history - sem deslocamento adicional pois já está dentro de #chat-container */
/* O deslocamento é feito pelo margin-left do #chat-container */
/* left é sempre 0 em ambos os estados (sidebar aberta/colapsada) — não há
   transição aqui de propósito, pois animar "left" sem nunca mudar seu valor
   só causava um deslize visual indevido a cada reflow (mensagem enviada,
   recarregamento de página, etc.), sem nenhum benefício. */
#chat-history {
  position: relative;
  left: 0;
}

.chat-message {
  margin-bottom: 16px;
  max-width: 80%;
}

.user-message {
  margin-left: auto;

}

.llm-message {
  margin-right: 0;
  max-width: 100%;
  width: 100%;
}

.message-content {
  padding: 12px;
}

.message-feedback {
  padding: 8px;
  justify-content: flex-end;
}

.feedback-button {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  margin-left: 10px;
}

.feedback-button:hover {
  color: var(--color-accent-primary);
}

/* Formul├írio de mensagem */
.message-form {
  padding: 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  box-sizing: border-box;
  border-radius: var(--border-radius-md);
}

.message-form textarea {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  outline: none;
}

.message-form button {
  background-color: var(--color-accent-primary);
  border: none;
  border-radius: 5px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mensagem de boas-vindas - ajustada para centralizar rigidamente acima do form */
.welcome-message {
  position: absolute;
  bottom: 55%;
  left: 0;
  right: 0;
  margin: 0 auto;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 1.5em;
  width: 100%;
  max-width: 800px;
  z-index: 10;
  transition: all 0.3s ease;
}

/* Indicador de carregamento */
.loading-icon {
  margin-left: 5px;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-loading {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.footer {
  background-color: var(--color-bg-primary);
  color: var(--color-text-secondary);
  opacity: 0.5;
  text-align: center;
  padding: 1rem;
  font-size: 0.7rem;
  height: 1rem;
  margin-top: auto;
  z-index: 99; 
  position: fixed; 
  bottom: 60px; 
  right: 0;
  transition: all var(--transition-speed) ease-in-out;
  width: calc(100% - var(--sidebar-width));
  margin-left: var(--sidebar-width);
}

/* Footer quando a sidebar est├í recolhida */
.app-container.sidebar-collapsed ~ .footer {
  width: calc(100% - var(--sidebar-collapsed-width));
  margin-left: var(--sidebar-collapsed-width);
}

/* Garantir que em dispositivos m├│veis o footer se comporte corretamente */
@media (max-width: 768px) {
  .footer {
    width: 100%;
    margin-left: 0;
  }
}

/* Estilos para o header da aplica├º├úo */
.app-header {
  height: 56px;
  background-color: var(--color-bg-secondary);
  position: fixed;
  top: 0;
  right: 0;
  width: calc(100% - var(--sidebar-width));
  z-index: 15;
  display: flex;
  align-items: center;
  overflow: visible;
  transition: width var(--transition-speed) var(--transition-function);
}

.app-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 64px;
  background: linear-gradient(to bottom, var(--color-bg-primary) 0%, transparent 100%);
  pointer-events: none;
}

/* Ajustar o header quando a sidebar estiver recolhida */
.app-container.sidebar-collapsed .app-header {
  width: calc(100% - var(--sidebar-collapsed-width));
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 20px;
}

.header-actions, .header-user-menu {
  display: flex;
}

.header-title {
  display: flex;
  align-items: center;
}

.header-title h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-text-primary);
}

.header-button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.header-button:hover {
  background-color: rgba(255,255,255,0.07);
  border-color: var(--glass-border);
  color: var(--color-accent-primary);
}

.user-button {
  border: 1px solid var(--color-border);
}

/* Seletor de modelo no header */
.model-select-container {
  position: relative;
}

.model-header-btn {
  background-color: rgba(255,255,255,0.04);
  color: var(--color-text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.model-header-btn:hover {
  background-color: rgba(255,255,255,0.08);
  border-color: var(--glass-border-active);
  color: var(--color-text-primary);
}

.model-header-btn i {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.model-header-btn.active i {
  transform: rotate(180deg);
}

.model-dropdown {
  position: absolute;
  top: 52px;
  left: 0;
  width: 300px;
  background-color: var(--color-surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
  z-index: 50;
  display: none;
  overflow: hidden;
}

.model-dropdown.show {
  display: block;
  animation: fadeInMenu 0.15s ease;
}

.model-dropdown-header {
  padding: 14px 16px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  border-bottom: none;
}

.model-list-container {
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 6px 6px;
}

.model-option {
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: none;
  border-radius: 10px;
  margin-bottom: 2px;
}

.model-option:hover {
  background-color: rgba(255,255,255,0.06);
}

.model-option.selected {
  background-color: rgba(0,141,163,0.14);
}

.model-option.selected .model-name {
  color: var(--color-accent-primary);
}

.model-option.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.model-name {
  font-weight: 500;
  font-size: 14px;
}

.model-plan {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background-color: transparent;
  letter-spacing: 0.02em;
}

.model-plan.pro {
  color: #f5c842;
  background-color: rgba(245,200,66,0.1);
}

.model-plan i {
  margin-right: 4px;
}

.pro-models-info {
  padding: 12px 12px;
  background-color: rgba(245,200,66,0.05);
  border-top: 1px solid rgba(245,200,66,0.12);
  margin: 0 6px 6px;
  border-radius: 10px;
}

.pro-upsell {
  text-align: center;
}

.pro-upsell h4 {
  margin-top: 0;
  margin-bottom: 8px;
  color: gold;
}

.pro-upsell p {
  margin-bottom: 15px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.upgrade-btn {
  display: inline-block;
  padding: 8px 20px;
  background-color: gold;
  color: #000;
  border-radius: var(--border-radius-md);
  font-weight: bold;
  text-decoration: none;
  transition: all 0.2s;
}

.upgrade-btn:hover {
  background-color: #f0c419;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(240, 196, 25, 0.2);
}

/* Header promocional para usu├írios n├úo PRO */
.pro-upsell-header {
  background-color: rgba(0, 0, 0, 0.2);
  padding: 10px 16px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

body.user-pro .pro-upsell-header {
  display: none; /* Esconder para usu├írios PRO */
}

.pro-upsell-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pro-upsell-content i.fa-crown {
  color: gold;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.pro-upsell-text {
  flex: 1;
}

.pro-upsell-text p {
  margin: 0 0 5px 0;
  font-size: 0.85rem;
  color: var(--color-text-primary);
}

.pro-upsell-btn {
  display: inline-block;
  padding: 4px 10px;
  background: linear-gradient(135deg, gold, #e6c200);
  color: #000;
  border-radius: var(--border-radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: bold;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pro-upsell-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

/* Esconder header promocional quando o sidebar estiver colapsado */
#sidebar-container.collapsed .pro-upsell-header {
  display: none;
}

/* Footer do sidebar com chamada promocional */
.sidebar-footer {
  background-color: var(--color-bg-secondary);
  padding: 6px 16px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Efeito de esmaecer no topo do footer para a lista de conversas */
.sidebar-footer::before {
  content: "";
  position: absolute;
  top: -45px;
  left: 0;
  right: 0;
  height: 45px;
  background: linear-gradient(to top, var(--color-bg-secondary) 15%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

body.user-pro .sidebar-footer .pro-upsell-content {
  display: none;
}

/* Centralizando o conte├║do do footer */
.pro-upsell-content {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Estilo do bot├úo PRO com ├¡cone */
.pro-upsell-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: linear-gradient(135deg, gold, #e6c200);
  color: #000;
  border-radius: var(--border-radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: bold;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pro-upsell-btn i.fa-crown {
  color: #000;
  font-size: 1rem;
}

.pro-upsell-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

/* Esconder footer promocional quando o sidebar estiver colapsado */
#sidebar-container.collapsed .sidebar-footer {
  display: none;
}

/* Estilos para o bot├úo de comando */
.command-button {
  background: none;
  color: var(--color-text-secondary);
}

.command-button:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-accent-primary);
}

/* Estilos para o bot├úo de alternar tema */
.theme-toggle-button {
  background: none;
  color: var(--color-text-secondary);
  transition: all 0.2s ease;
}

.theme-toggle-button:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-accent-primary);
}

/* Quando no tema claro, mostramos o ├¡cone do sol */
.light-theme .theme-toggle-button i.fa-moon {
  display: none;
}

.light-theme .theme-toggle-button i.fa-sun {
  display: inline-block;
}

/* Por padr├úo (tema escuro), mostramos o ├¡cone da lua */
.theme-toggle-button i.fa-sun {
  display: none;
}

.theme-toggle-button i.fa-moon {
  display: inline-block;
}

/* Ajustes espec├¡ficos para o tema claro */
.light-theme #sapiens-logo {
  content: url('/static/chat/images/SapiensChat_Logo_Color.png');
  height: 2.5rem; 
}

.light-theme #toggle-sidebar img {
  filter: none;
  opacity: 0.7;
}

.light-theme #reopen-sidebar img {
  filter: invert(15%) sepia(25%) saturate(70%) hue-rotate(170deg) brightness(95%) contrast(95%);
  opacity: 1;
}

/* Substituir o logo colapsado no tema claro */
.light-theme #sidebar-container.collapsed .collapsed-logo {
  content: url('/static/chat/images/SapiensChat_Logo_Color.svg');
  filter: none; 
  height: 3.2rem;
  top: 3rem;
}

/* Estilo para o menu de perfil dropdown */
.profile-dropdown {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  width: 160px;
  z-index: 48;
  border: 1px solid var(--glass-border);
  display: none;
  overflow: hidden;
}

.profile-dropdown.show {
  display: block;
}

/* Ajustes do dropdown de perfil com sidebar aberto */
#sidebar-container:not(.collapsed) .profile-dropdown {
  left: 16px;
  right: 16px;
  width: auto;
  transform: none;
}

/* Se não for PRO (tem o botão Become PRO embaixo) */
body:not(.user-pro) #sidebar-container:not(.collapsed) .profile-dropdown {
  bottom: 135px;
}

/* Se for PRO */
body.user-pro #sidebar-container:not(.collapsed) .profile-dropdown {
  bottom: 90px;
}

/* Estilos para o card/banner de perfil no sidebar aberto */
.sidebar-profile-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
  background-color: rgba(255, 255, 255, 0.02);
  width: 100%;
  box-sizing: border-box;
}

.sidebar-profile-open:hover {
  background-color: var(--color-bg-hover);
}

.profile-info-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.profile-picture-open {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--color-accent-primary);
}

.default-profile-icon-open {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 2px solid var(--color-accent-primary);
}

.profile-text-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
}

.profile-username {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-status {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  margin-top: 2px;
}

.badge-pro-footer {
  background: linear-gradient(135deg, gold, #d4af37);
  color: #000;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.profile-menu-chevron {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding-left: 8px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.sidebar-profile-open:hover .profile-menu-chevron {
  color: var(--color-text-primary);
}

.profile-dropdown-item {
  padding: 10px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: background-color 0.2s;
}

.profile-dropdown-item:hover {
  background-color: var(--color-accent-primary) !important;
  color: #ffffff !important;
}

.profile-dropdown-item i {
  width: 16px;
  text-align: center;
}

/* Light mode collapsed: solid bg matching header — no see-through overlay */
.light-theme #sidebar-container.collapsed {
  background-color: var(--color-bg-secondary);
}

/* Estilos para mudar a cor de fundo do conversation-title-area e o texto para branco no tema claro */
.light-theme .conversation-item .conversation-title-area {
  background-color: #0a8093;
  color: white;
}

.light-theme .conversation-item .conversation-title-area a {
  color: white;
}

.light-theme .conversation-item .conversation-menu-button {
  color: rgba(255, 255, 255, 0.8);
}

.light-theme .conversation-item .conversation-menu-button:hover {
  color: white;
}

/* Manter o destaque para o item ativo da conversa */
.light-theme .conversation-item.active .conversation-title-area {
  background-color: #0a8093;
}

/* ===== HEADER CONTROLS STACK ===== */

/* Desktop: stack is just inline, wrapping the model-select-container normally */
.header-controls-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  margin-right: auto;
}

/* --- MODEL DROPDOWN NESTED REASONING VOLUME --- */

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.slider-wrapper input[type="range"] {
  flex-grow: 1;
  accent-color: var(--color-accent-primary);
  height: 4px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.slider-limit {
  font-size: 11px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  user-select: none;
}

.slider-subtitle {
  font-size: 12px;
  color: var(--color-text-secondary);
  text-align: center;
  display: block;
  font-weight: 500;
  margin-top: 4px;
}
