/*
 * Estilos CSS para a interface de chatbot
 */

:root {
  --bg-primario: #19171d;
  --bg-secundario: #0e0d0f;
  --texto-primario: #e0e0e0;
  --texto-secundario: #a0a0a0;
  --cor-borda: #333344;
  --cor-acento: #7b68ee;
  --cor-hover: #35364a;
  --trilho-slider: #3f4156;
  --polegar-slider: #ffffff;
  --cor-erro: #ff6b6b;
  --cor-sucesso: #51cf66;
  --message-bg-user: #7b68ee;
  --message-bg-assistant: #2a2b3c;
}
:root.light {
  --bg-primario: #f5f5f7;
  --bg-secundario: #ffffff;
  --texto-primario: #222222;
  --texto-secundario: #666666;
  --cor-borda: #dddddd;
  --cor-acento: #5a46e6;
  --cor-hover: #f0f0f0;
  --trilho-slider: #dddddd;
  --polegar-slider: #5a46e6;
  --cor-erro: #e03131;
  --cor-sucesso: #2f9e44;
  --message-bg-user: #5a46e6;
  --message-bg-assistant: #ffffff;
}

/* --- Layout Principal --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
  background-color: var(--bg-primario);
  color: var(--texto-primario);
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}

a {
  color: inherit;
  color: var(--texto-primario);
}

/* Skip link para acessibilidade */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--cor-acento);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
  font-weight: bold;
}
.skip-link:focus {
  top: 6px;
}

/* --- Markdown Styles --- */
.markdown-content {
  line-height: 1.6;
  font-size: 0.95rem;
}
.markdown-content pre {
  background-color: #111;
  padding: 1rem;
  border-radius: 0.375rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  color: #f0f0f0;
  max-width: 100%;  /* Garante que não exceda a largura do container */
  overflow-wrap: break-word;  /* Quebra palavras longas para evitar overflow */
  word-break: break-word;
}
:root.light .markdown-content pre {
  background-color: #2d2d2d;
}
.markdown-content code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
}
.markdown-content p { margin-bottom: 0.75rem; }
.markdown-content p:last-child { margin-bottom: 0; }
.markdown-content ul, .markdown-content ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
.markdown-content a { color: #64b5f6; text-decoration: underline; }
.message.user .markdown-content a { color: #fff; }
.markdown-content h1, .markdown-content h2, .markdown-content h3 { margin-top: 1rem; margin-bottom: 0.5rem; font-weight: 600; }

/* --- Layout Principal --- */
.sidebar {
  width: 18rem;
  background-color: var(--bg-primario);
  border-right: 0.0625rem solid var(--cor-borda);
  display: flex;
  flex-direction: column;
  transition: width 0.3s, transform 0.3s;
  height: 100vh;
  position: fixed;
  z-index: 20;
  overflow-y: auto;
}
.sidebar.collapsed {
  width: 0;
  transform: translateX(-100%);
  overflow: hidden;
}
.sidebar .logo {
  padding: 1rem;
}
.sidebar .logo h1 {
  font-size: 1.5rem;
}
.sidebar .logo img {
  width: 80%;
  max-width: 21rem;
}

.sidebar-header-mobile {
  display: none;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem;
  position: relative;
}
.close-sidebar-mobile {
  background: none;
  border: none;
  color: var(--texto-primario);
  cursor: pointer;
  display: flex;
  padding: 0.25rem;
  border-radius: 0.25rem;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}
.close-sidebar-mobile:hover { background-color: var(--cor-hover); }

.new-chat {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  gap: 0.5rem;
  margin: 0.5rem;
  border: 0.0625rem solid var(--cor-borda);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background 0.2s;
}
.new-chat:hover { background-color: var(--cor-hover); }
.new-chat-icon { width: 1rem; height: 1rem; }

.search-container { padding: 0.5rem 0.75rem; margin-bottom: 0.25rem; }
.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-primario);
  border: 0.0625rem solid var(--cor-borda);
  border-radius: 0.375rem;
  color: var(--texto-primario);
}
.search-input:focus { outline: none; border-color: var(--cor-acento); }

.conversation-list { flex: 1; overflow-y: auto; padding-top: 0.5rem; }

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  gap: 0.5rem;
  cursor: pointer;
  border-radius: 0.375rem;
  margin: 0 0.5rem 0.25rem 0.5rem;
  position: relative;
  transition: background 0.2s;
}
.conversation-item:hover { background-color: var(--cor-hover); }
.conversation-item.active { background-color: var(--cor-hover); border: 0.0625rem solid var(--cor-borda); }

.chat-info { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; }
.conversation-icon { width: 1rem; height: 1rem; color: var(--texto-secundario); flex-shrink: 0; }
.conversation-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.875rem;
  font-weight: 500;
}
.chat-options-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  flex-shrink: 0;
  color: var(--texto-secundario);
  border-radius: 0.25rem;
  opacity: 0.7;
}
.chat-options-btn:hover { background-color: rgba(255, 255, 255, 0.1); color: var(--texto-primario); opacity: 1; }

.bottom-actions { padding: 0.75rem; border-top: 0.0625rem solid var(--cor-borda); position: relative; }
.settings-button {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 0.375rem;
  background: var(--bg-primario);
  color: var(--texto-primario);
}
.settings-button:hover { background-color: var(--cor-hover); }
.settings-dropdown {
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 0.5rem;
  background-color: var(--bg-primario);
  border: 0.0625rem solid var(--cor-borda);
  border-radius: 0.375rem;
  z-index: 15;
  min-width: 12rem;
  box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.2);
}
.settings-dropdown.active { display: flex; }
.settings-dropdown .dropdown-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--texto-primario);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.settings-dropdown .dropdown-item:hover { background-color: var(--cor-hover); }

/* --- Main Content --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secundario);
  margin-left: 18rem;
  transition: margin-left 0.3s;
  height: 100vh;
  position: relative;
}
.main-content.expanded { margin-left: 0; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 0.0625rem solid var(--cor-borda);
  background-color: var(--bg-primario);
}
.header-controls { display: flex; gap: 0.75rem; align-items: center; }
.toggle-sidebar, .toggle-fullscreen, .theme-toggle {
  background: none;
  border: none;
  color: var(--texto-primario);
  cursor: pointer;
  display: flex;
  padding: 0.25rem;
  border-radius: 0.25rem;
}
.toggle-sidebar:hover, .toggle-fullscreen:hover, .theme-toggle:hover { background-color: var(--cor-hover); }

/* --- Chat Area --- */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}
.messages-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 2rem;
}
.message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.message-wrapper.user { align-self: flex-end; align-items: flex-end; }
.message-wrapper.assistant { align-self: flex-start; align-items: flex-start; }
.message-wrapper.system { align-self: center; max-width: 90%; }

.message {
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  position: relative;
  box-shadow: 0 0.0625rem 0.125rem rgba(0,0,0,0.1);
}
.message.user {
  background-color: var(--message-bg-user);
  color: white;
  border-bottom-right-radius: 0.1rem;
}
.message.assistant {
  background-color: var(--message-bg-assistant);
  border: 0.0625rem solid var(--cor-borda);
  border-bottom-left-radius: 0.1rem;
}
.message.system {
  background-color: transparent;
  color: var(--texto-secundario);
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
  box-shadow: none;
  border: 0.0625rem dashed var(--cor-borda);
}
.message-role {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Message Actions --- */
.message-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.message-wrapper:hover .message-actions { opacity: 1; }
.message-wrapper.user .message-actions { justify-content: flex-end; }
.action-btn {
  background-color: var(--bg-primario);
  border: 0.0625rem solid var(--cor-borda);
  color: var(--texto-secundario);
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.action-btn:hover {
  background-color: var(--cor-hover);
  color: var(--texto-primario);
  border-color: var(--cor-acento);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--texto-secundario);
  margin-top: 2rem;
}

/* --- Input Area --- */
.input-wrapper {
    width: 100%;
    background-color: var(--bg-primario);
    border-top: 0.0625rem solid var(--cor-borda);
    padding: 1rem;
    display: flex;
    justify-content: center;
    box-sizing: border-box; 
}

.input-container {
  width: 100%;
  position: relative;
  display: flex; 
  flex-direction: column;
}

input[type='file'] {
  display: none !important;
}

.message-input {
  width: 100%;
  padding: 0.875rem 3.5rem 0.875rem 3rem; 
  background-color: var(--bg-secundario);
  border: 0.0625rem solid var(--cor-borda);
  border-radius: 0.75rem;
  color: var(--texto-primario);
  resize: none;
  min-height: 3.5rem;
  max-height: 15rem;
  overflow-y: auto;
  font-size: 1rem;
  line-height: 1.5;
  box-shadow: 0 0.125rem 0.375rem rgba(0,0,0,0.05);
  display: block;
}
.message-input:focus {
  outline: none;
  border-color: var(--cor-acento);
  box-shadow: 0 0 0 0.125rem rgba(123, 104, 238, 0.2);
}

.send-button {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  background: var(--cor-acento);
  border: none;
  color: white;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  z-index: 10;
}
.send-button:hover { transform: scale(1.05); }
.send-button:active { transform: scale(0.95); }
.send-icon { width: 1rem; height: 1rem; }

.attach-button {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  background: none;
  border: none;
  color: var(--texto-secundario);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 50%;
  z-index: 10;
}
.attach-button:hover { color: var(--cor-acento); background-color: var(--cor-hover); }
.attach-icon { width: 1.5rem; height: 1.5rem; }

.footer {
  padding: 0.5rem;
  font-size: 0.7rem;
  color: var(--texto-secundario);
  text-align: center;
  background-color: var(--bg-primario);
}

/* --- Modais --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  justify-content: center;
  align-items: center;
  z-index: 100;
  overflow-y: auto;
  backdrop-filter: blur(0.1875rem);
}
.modal-content {
  background-color: var(--bg-secundario);
  padding: 2rem;
  border-radius: 0.75rem;
  width: 90%;
  max-width: 38rem;
  color: var(--texto-primario);
  max-height: 90vh;
  overflow-y: auto;
  margin: 2rem auto;
  border: 0.0625rem solid var(--cor-borda);
  box-shadow: 0 0.625rem 1.5625rem rgba(0,0,0,0.3);
}
.modal-content h2 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  border-bottom: 0.0625rem solid var(--cor-borda);
  padding-bottom: 0.75rem;
}

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--texto-secundario);
}

/* Input com botão toggle */
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 2.5rem; }
.toggle-password-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--texto-secundario);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toggle-password-btn:hover { color: var(--texto-primario); }

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 0.0625rem solid var(--cor-borda);
  border-radius: 0.5rem;
  font-size: 0.95rem;
  background-color: var(--bg-primario);
  color: var(--texto-primario);
  transition: border-color 0.2s;
}
.form-group textarea {
  min-height: 6rem;
  resize: vertical;
  font-family: monospace;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--cor-acento);
  box-shadow: 0 0 0 0.125rem rgba(123, 104, 238, 0.1);
}

/* Details & Summary */
details {
  background-color: var(--bg-primario);
  border: 0.0625rem solid var(--cor-borda);
  border-radius: 0.5rem;
  padding: 0.5rem;
  margin-top: 1rem;
}
summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--texto-secundario);
  padding: 0.25rem;
  user-select: none;
}
summary:hover { color: var(--cor-acento); }
details[open] summary {
  border-bottom: 0.0625rem solid var(--cor-borda);
  margin-bottom: 1rem;
}
details[open] .form-group:last-child { margin-bottom: 0.5rem; }

.slider-container { width: 100%; padding: 0 0.25rem; }
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.3rem;
  background-color: var(--trilho-slider);
  border-radius: 0.25rem;
  outline: none;
  margin: 0.5rem 0;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.2rem;
  height: 1.2rem;
  background-color: var(--polegar-slider);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0.0625rem 0.1875rem rgba(0,0,0,0.3);
}
.temperature-value { float: right; font-weight: bold; color: var(--cor-acento); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 0.0625rem solid var(--cor-borda);
}
.modal-actions-left { margin-right: auto; display: flex; gap: 0.5rem; }
.modal-actions button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}
.btn-cancel {
  background-color: transparent;
  border: 0.0625rem solid var(--cor-borda) !important;
  color: var(--texto-primario);
}
.btn-cancel:hover { background-color: var(--cor-hover); }
.btn-primary { background-color: var(--cor-acento); color: #fff; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-0.0625rem); }
.btn-danger {
  background-color: transparent;
  color: var(--cor-erro);
  border: 0.0625rem solid var(--cor-erro) !important;
}
.btn-danger:hover { background-color: var(--cor-erro); color: white; }

.info-text {
  padding: 2rem 0;
  font-size: .8rem;
}

/* Loading Animation */
.typing-indicator { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.25rem 0.5rem; }
.typing-dot {
  width: 0.375rem;
  height: 0.375rem;
  background-color: var(--texto-secundario);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* --- Media Queries para Mobile --- */
@media (max-width: 768px) {
  .sidebar {
    width: 15rem; /* Largura reduzida para mobile */
  }
  .main-content {
    margin-left: 0; /* Sem margem para permitir sobreposição */
  }
  .main-content.expanded {
    margin-left: 0; /* Manter sem margem */
  }
  .sidebar-header-mobile {
    display: flex;
  }
}
