/* Removido @import de Google Fonts para respeitar CSP */

/* Reset suave */
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{ margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; color:#1f2233; }
/* Ícones usando emojis e símbolos Unicode */
.icon {
  font-size: 18px;
  margin-right: 8px;
  vertical-align: middle;
}

.icon-large {
  font-size: 24px;
  margin-right: 10px;
}

/* Títulos com fallback caso Chewy não esteja disponível */
h1, h2, h3, h4, h5, h6,
.chat-title h1,
.dashboard-title h1,
.math-title {
  font-family: cursive, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  letter-spacing: 0.3px;
}

/* Fundos */
.bg-gradient{
  min-height:100%;
  background: radial-gradient(1200px 600px at 20% 0%, #e3f2ff 0%, transparent 60%),
              radial-gradient(1000px 600px at 100% 100%, #f1e9ff 0%, transparent 60%),
              linear-gradient(180deg, #f8fbff, #ffffff);
}

/* Layout do Chat (estilo ChatGPT) */
.chat-layout {
  display: flex;
  height: 100vh;
  background: #ffffff;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #f8f9ff 0%, #ffffff 100%);
  border-right: 2px solid #edf0ff;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0,0,0,.05);
  position: relative;
  z-index: 1000;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 2px solid #edf0ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  position: relative;
}

.logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.logo {
  max-width: 120px;
  height: auto;
  background: transparent;
}

.sidebar-toggle {
  display: none;
  width: 32px;
  height: 32px;
  background: #f8f9ff;
  border: 2px solid #edf0ff;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all .3s ease;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 20px;
  right: 20px;
}

.sidebar-toggle:hover {
  background: #edf0ff;
  transform: translateY(-1px);
}

.new-chat-btn {
  width: 100%;
  padding: 12px 20px;
  background: linear-gradient(135deg, #7c8cff, #9ba3ff);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all .3s ease;
  box-shadow: 0 2px 8px rgba(124,140,255,0.3);
}

.new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(124,140,255,.3);
}

.sidebar-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 700;
  color: #38405a;
}

.sidebar-section h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #5b6280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-subtitle {
  margin: 0;
  font-size: 13px;
  color: #6a708c;
  line-height: 1.4;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 2px solid #edf0ff;
  background: rgba(255,255,255,.8);
}

.user-info {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.user-details {
  flex: 1;
  text-align: center;
}

.user-details span {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: #38405a;
}

.user-details small {
  color: #51cf66;
  font-size: 12px;
  font-weight: 500;
}

.settings-btn, .logout-btn, .dashboard-btn {
  width: 100%;
  padding: 8px 12px;
  background: #f8f9ff;
  border: 2px solid #edf0ff;
  border-radius: 8px;
  color: #5b6280;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .3s ease;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.settings-btn:hover, .logout-btn:hover, .dashboard-btn:hover {
  background: #edf0ff;
  color: #38405a;
  transform: translateY(-1px);
}

.dashboard-btn {
  background: linear-gradient(135deg, #17a2b8, #20c997);
  color: white;
  border-color: #17a2b8;
}

.dashboard-btn:hover {
  background: linear-gradient(135deg, #138496, #1ea085);
  color: white;
  box-shadow: 0 4px 15px rgba(23,162,184,0.3);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

/* Chat Header */
.chat-header {
  padding: 16px 24px;
  border-bottom: 2px solid #edf0ff;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  background: #f8f9ff;
  border: 2px solid #edf0ff;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all .3s ease;
  align-items: center;
  justify-content: center;
}

.mobile-menu-btn:hover {
  background: #edf0ff;
  transform: translateY(-1px);
}

.chat-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #38405a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-title p {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: #6a708c;
}

/* Ícone inline da IA, herdando a cor do texto */
.logo-ia-icon{
  display:inline-block;
  width:200px; /* 10x o tamanho original (20px) */
  height:200px;
  margin-right:16px;
  background-color: currentColor;
  -webkit-mask: url('../../img/logo_ia.png') no-repeat center / contain;
  mask: url('../../img/logo_ia.png') no-repeat center / contain;
}

/* Versão para header dos chats: tamanho original visual (40px) e cor do texto */
.logo-ia-icon--header{
  width:40px;
  height:40px;
  margin-right:8px;
  vertical-align:-6px;
}

/* Versão com <img> real para o header */
.logo-ia-img{
  width:24px;
  height:24px;
  object-fit: contain;
  margin-right:8px;
  vertical-align:middle;
}
/* Variante branca para usar sobre header escuro dos chats */
.logo-ia-img--white{
  filter: brightness(0) saturate(100%) invert(1);
}
/* Overlay/"textura" branca acima da logo (chats) */
.logo-ia-wrap{
  display:inline-block;
  position:relative;
  line-height:0;
}
.logo-ia-wrap::after{
  content:"";
  position:absolute;
  inset:0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.92) 0 2px, rgba(255,255,255,.85) 2px 4px);
  mix-blend-mode: screen;
  pointer-events:none;
  border-radius:2px;
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  width: 36px;
  height: 36px;
  background: #f8f9ff;
  border: 2px solid #edf0ff;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all .3s ease;
}

.action-btn:hover {
  background: #edf0ff;
  transform: translateY(-1px);
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
}

.messages{ 
  display:flex; 
  flex-direction:column; 
  gap:16px; 
  padding:0 24px; 
  max-width: 800px;
  margin: 0 auto;
}

/* Message bubbles */
.msg-row{ display:flex; gap:12px; align-items: flex-end; }
.msg-row.user{ justify-content:flex-end; }

.avatar{ 
  width:32px; 
  height:32px; 
  border-radius:50%; 
  background:linear-gradient(135deg, #dfe3ff, #f0f2ff); 
  display:flex; 
  align-items:center; 
  justify-content:center; 
  font-weight:800; 
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  border: 2px solid rgba(255,255,255,.8);
  flex-shrink: 0;
}

.avatar img{
  width:32px;
  height:32px;
  border-radius:50%;
  object-fit: cover;
  display:block;
}

.bubble{ 
  max-width:70%; 
  padding:12px 16px; 
  border-radius:18px; 
  line-height:1.5; 
  font-size: 15px;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.bubble.assistant{ 
  background:linear-gradient(135deg, #f8f9ff, #ffffff); 
  border:2px solid #edf0ff; 
  color: #38405a;
}

.bubble.user{ 
  background:linear-gradient(135deg, #7c8cff, #9ba3ff); 
  border:2px solid #7c8cff; 
  color: white;
}

/* Formatação melhorada para respostas da IA */
.bubble.assistant p {
  margin: 0 0 12px 0;
  line-height: 1.6;
}

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

.bubble.assistant br {
  line-height: 1.8;
}

/* Estilo para listas na resposta da IA */
.bubble.assistant ul, .bubble.assistant ol {
  margin: 8px 0;
  padding-left: 20px;
}

.bubble.assistant li {
  margin: 4px 0;
  line-height: 1.5;
}

/* Espaçamento para bullets e hífens */
.bubble.assistant br + .bullet,
.bubble.assistant br + .dash {
  margin-left: 8px;
}

/* Destaque para emojis */
.bubble.assistant .emoji {
  font-size: 1.2em;
  margin: 0 2px;
}

/* Melhorar espaçamento geral das respostas da IA */
.bubble.assistant {
  line-height: 1.6;
  word-spacing: 0.5px;
  letter-spacing: 0.2px;
}

/* Destaque para títulos em negrito */
.bubble.assistant strong {
  color: #2c3e50;
  font-weight: 700;
}

/* Espaçamento para listas */
.bubble.assistant br + .bullet,
.bubble.assistant br + .dash {
  display: inline-block;
  margin-left: 8px;
}

/* Melhorar legibilidade de textos longos */
.bubble.assistant p {
  text-align: justify;
  hyphens: auto;
}

/* ===== FORMATAÇÃO MATEMÁTICA ===== */

/* Container para fórmulas matemáticas */
.math-container {
  background: linear-gradient(135deg, #f8f9ff, #ffffff);
  border: 2px solid #edf0ff;
  border-radius: 16px;
  padding: 20px;
  margin: 16px 0;
  box-shadow: 0 4px 15px rgba(124, 140, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.math-container::before {
  content: "🧮";
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 20px;
  opacity: 0.6;
}

/* Título da fórmula */
.math-title {
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 16px;
  text-align: center;
  border-bottom: 2px solid #edf0ff;
  padding-bottom: 12px;
}

/* Estilos antigos removidos - usando apenas KaTeX */

/* Explicação da fórmula */
.math-explanation {
  background: #f8f9ff;
  border-left: 4px solid #cfd6e6;
  padding: 16px;
  margin: 16px 0;
  border-radius: 0 12px 12px 0;
}

.math-explanation h4 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 700;
  color: #2c3e50;
}

.math-explanation p {
  margin: 8px 0;
  line-height: 1.6;
  color: #38405a;
}

/* Lista de componentes */
.math-components {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.math-component {
  background: white;
  border: 2px solid #edf0ff;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

/* KaTeX funciona sem CSS específico - estilos removidos para evitar interferência */

/* Correção específica para problema da raiz quadrada que se estende infinitamente */
.katex .sqrt {
  max-width: 100% !important;
  overflow: hidden !important;
}

.katex .sqrt .vlist-t {
  max-width: 100% !important;
  overflow: hidden !important;
}

.katex .sqrt .vlist-r {
  max-width: 100% !important;
  overflow: hidden !important;
}

/* Estilos de fallback removidos - usando apenas KaTeX */

/* Destaque para discriminante */
.discriminant {
  background: linear-gradient(135deg, #fff3cd, #ffeaa7);
  border: 2px solid #fdcb6e;
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  text-align: center;
  font-weight: 600;
  color: #856404;
}

/* Emoji decorativo */
.math-emoji {
  font-size: 1.2em;
  margin: 0 4px;
  vertical-align: middle;
}

/* Matemática inline */
.inline-math {
  font-family: 'Times New Roman', serif;
  font-weight: inherit;
  color: inherit;
  background: transparent;
  padding: 0;
  border-radius: 0;
  border: none;
}

/* Melhorar formatação de listas com hífens */
.bubble.assistant p:contains('-') {
  margin-left: 8px;
}

/* Destaque para termos matemáticos */
/* Removido destaque automático de letras (a,b,c,x) */

/* Responsivo para fórmulas - apenas para KaTeX */
@media (max-width: 768px) {
  .math-components {
    grid-template-columns: 1fr;
  }
}

/* Input Container */
.input-container {
  padding: 20px 24px;
  border-top: 2px solid #edf0ff;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(10px);
}

.chat-form{
  max-width: 800px;
  margin: 0 auto;
}

.input-wrapper{ 
  display:flex; 
  gap:12px; 
  align-items:flex-end; 
  padding:12px 16px; 
  border-radius:24px; 
  border:2px solid #edf0ff; 
  background:#f8f9ff;
  box-shadow: 0 4px 15px rgba(0,0,0,.05);
  transition: all .3s ease;
}

.input-wrapper:focus-within{
  border-color: #7c8cff;
  box-shadow: 0 8px 25px rgba(124,140,255,.15);
  background: #ffffff;
}

.attach-btn, .send-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .3s ease;
  flex-shrink: 0;
}

.attach-btn:hover, .send-btn:hover {
  background: rgba(124,140,255,.1);
  transform: scale(1.1);
}

.chat-form textarea{
  flex:1; 
  resize:none; 
  border:none; 
  outline:none; 
  padding:8px 0; 
  font-size:15px; 
  max-height:120px;
  font-family: inherit;
  background: transparent;
  line-height: 1.4;
}

.chat-form textarea:focus{ outline:none; }

.continue-btn {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 10;
  padding: 12px 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ff9a8b, #ff6b6b);
  color: white;
  border: none;
  box-shadow: 0 6px 20px rgba(255,107,107,.3);
  font-weight: 600;
  transition: all .3s ease;
}

.continue-btn:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255,107,107,.4);
}

/* Loader (bolinhas dançantes) */
.loader{ display:inline-flex; gap:6px; padding:8px 12px; }
.loader span{ width:8px; height:8px; background:linear-gradient(135deg, #7c8cff, #9ba3ff); border-radius:50%; display:inline-block; animation:up 1.2s infinite ease-in-out; }
.loader span:nth-child(2){ animation-delay:.2s; }
.loader span:nth-child(3){ animation-delay:.4s; }
@keyframes up{ 0%,80%,100%{ transform:translateY(0);} 40%{ transform:translateY(-8px);} }

/* Message animations */
.msg-row{
  animation: slideIn 0.3s ease-out;
}

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

/* Scrollbar personalizada */
.messages::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track,
.sidebar-content::-webkit-scrollbar-track {
  background: rgba(0,0,0,.05);
  border-radius: 10px;
}

.messages::-webkit-scrollbar-thumb,
.sidebar-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #7c8cff, #9ba3ff);
  border-radius: 10px;
}

.messages::-webkit-scrollbar-thumb:hover,
.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #6b7bff, #8a92ff);
}

/* Responsive */
@media (max-width:768px){ 
  .chat-layout {
    position: relative;
  }
  
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    width: 280px;
    transition: left 0.3s ease;
    z-index: 1000;
  }
  
  .sidebar.sidebar-open {
    left: 0;
  }
  
  .main-content {
    width: 100%;
    margin-left: 0;
  }
  
  .mobile-menu-btn {
    display: flex;
  }
  
  .sidebar-toggle {
    display: flex;
  }
  
  .messages {
    padding: 0 16px;
  }
  
  .input-container {
    padding: 16px;
  }
  
  .chat-header {
    padding: 12px 16px;
  }
  
  .bubble{ 
    max-width: 85%; 
    padding: 10px 14px; 
  }
  
  .continue-btn{ 
    right: 16px; 
    bottom: 90px; 
  }
  
  /* Overlay para quando o sidebar estiver aberto */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  
  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

/* Glass cards (para login/registro) */
.glass{ background: rgba(255,255,255,0.8); backdrop-filter: blur(15px); border:2px solid rgba(255,255,255,0.8); box-shadow: 0 15px 35px rgba(38,38,80,0.1); border-radius:28px; }
.card{ padding:32px; max-width:480px; margin:24px auto; }
.auth-wrapper{ display:grid; place-items:center; min-height:100vh; padding:16px; }
.sub{ margin-top:-6px; color:#5b6280; font-size:18px; }

/* Form */
.form{ display:grid; gap:18px; }
.input-group{ display:grid; gap:10px; }
.input-group span{ font-weight:600; color:#38405a; font-size:16px; }
.input-group input, .input-group select{
  width:100%; padding:16px 18px; border:2px solid #e6e8f0; border-radius:18px; background:#fff;
  font-size:16px; outline:none; transition: all .3s ease; font-family: inherit;
}
.input-group input:focus, .input-group select:focus{ border-color:#7c8cff; box-shadow:0 0 0 6px rgba(124,140,255,.15); transform: translateY(-2px); }
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:16px; }

/* Buttons */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:10px; cursor:pointer;
  border-radius:20px; padding:16px 24px; border:2px solid transparent; font-weight:700; font-size:16px; transition:all .3s ease; font-family: inherit;
}
.btn:active{ transform: translateY(2px); }
.btn.primary{ background:linear-gradient(135deg, #7c8cff, #9ba3ff); color:#fff; box-shadow:0 8px 25px rgba(124,140,255,.3); }
.btn.primary:hover{ filter:brightness(1.1); transform: translateY(-2px); box-shadow:0 12px 35px rgba(124,140,255,.4); }
.btn.secondary{ background:linear-gradient(135deg, #f8f9ff, #ffffff); border-color:#e6e8f0; color:#38405a; box-shadow:0 4px 15px rgba(0,0,0,.1); }
.btn.secondary:hover{ background:linear-gradient(135deg, #f0f2ff, #f8f9ff); transform: translateY(-2px); }
.btn.ghost{ background:#fff; border-color:#e6e8f0; color:#38405a; }
.hidden{ display:none !important; }
.muted{ color:#6a708c; font-size:16px; }
.link{ color:#5b67ff; text-decoration:none; font-weight:600; }
.link:hover{ text-decoration:underline; }

.time{ font-size:12px; color:#7a80a0; margin-top:6px; }

/* Responsive para login/registro */
@media (max-width:640px){ 
  .grid-2{ grid-template-columns:1fr; } 
}

/* Chat List Items */
.chat-item {
  background: #f8f9ff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid #edf0ff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chat-item:hover {
  background: #edf0ff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124, 140, 255, 0.15);
  border-color: #7c8cff;
}

.chat-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  line-height: 1.4;
  color: #38405a;
  display: block;
}

.chat-meta {
  font-size: 12px;
  color: #6a708c;
  font-weight: 500;
  display: block;
}

.no-chats {
  text-align: center;
  color: #6a708c;
  font-style: italic;
  padding: 20px;
  font-size: 14px;
  background: #f8f9ff;
  border-radius: 12px;
  border: 2px dashed #edf0ff;
}

/* Chat Group Cards */
.chat-group-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid #edf0ff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.chat-group-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(124, 140, 255, 0.15);
  border-color: #7c8cff;
}

.chat-group-card.active {
  border-color: #7c8cff;
  background: linear-gradient(135deg, #f8f9ff, #ffffff);
  box-shadow: 0 8px 25px rgba(124, 140, 255, 0.2);
}

.chat-group-header {
  font-size: 14px;
  font-weight: 700;
  color: #38405a;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-group-header .date {
  font-size: 12px;
  color: #6a708c;
  font-weight: 500;
}

.chat-group-count {
  background: #7c8cff;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
}

.chat-group-preview {
  font-size: 12px;
  color: #6a708c;
  line-height: 1.4;
  margin-top: 8px;
  max-height: 40px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chat-group-time {
  font-size: 11px;
  color: #8b9dc3;
  margin-top: 8px;
  font-weight: 500;
}

/* Modal de Configurações */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: white;
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 24px 24px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #edf0ff;
  padding-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #38405a;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: #f8f9ff;
  border: 2px solid #edf0ff;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #edf0ff;
  transform: scale(1.1);
}

.modal-body {
  padding: 24px;
}

/* Abas */
.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid #edf0ff;
  padding-bottom: 16px;
}

.tab-btn {
  padding: 12px 20px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #6a708c;
}

.tab-btn:hover {
  background: #f8f9ff;
  color: #38405a;
}

.tab-btn.active {
  background: linear-gradient(135deg, #7c8cff, #9ba3ff);
  color: white;
  border-color: #7c8cff;
}

/* Conteúdo das abas */
.tab-content {
  position: relative;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: block;
}

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

/* Formulários */
.settings-form {
  display: grid;
  gap: 20px;
}

.form-group {
  display: grid;
  gap: 8px;
}

.form-group label {
  font-weight: 600;
  color: #38405a;
  font-size: 14px;
}

.form-group input,
.form-group select {
  padding: 12px 16px;
  border: 2px solid #edf0ff;
  border-radius: 12px;
  font-size: 14px;
  transition: all 0.3s ease;
  background: #f8f9ff;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #7c8cff;
  background: white;
  box-shadow: 0 0 0 4px rgba(124, 140, 255, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Responsivo para o modal */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 20px;
  }
  
  .modal-header {
    padding: 20px 20px 0 20px;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Formatação para Questões de Múltipla Escolha */
.question-header {
  font-size: 18px;
  font-weight: 700;
  color: #38405a;
  margin: 30px 0 15px 0;
  padding: 8px 0;
  border-bottom: 2px solid #edf0ff;
}

.question-text {
  font-size: 16px;
  color: #1f2233;
  margin: 15px 0;
  line-height: 1.5;
}

.question-options {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin: 15px 0;
  align-items: center;
}

.option-letter {
  display: inline-block;
  color: #38405a !important;
  font-weight: 600;
  margin-right: 4px;
  font-size: 14px;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

.correct-answer {
  margin-top: 15px;
  padding: 10px 15px;
  background: rgba(76, 175, 80, 0.1);
  border: 2px solid rgba(76, 175, 80, 0.2);
  border-radius: 8px;
  font-weight: 600;
  color: #2e7d32;
}

.correct-answer .option-letter {
  color: #2e7d32 !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

/* Responsivo para questões */
@media (max-width: 768px) {
  .question-options {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .question-header {
    font-size: 16px;
  }
  
  .question-text {
    font-size: 15px;
  }
}

/* ===== Tema: Sidebar/Header mais escuros e corpo/chats mais claros ===== */
/* Sidebar mais escuro */
.sidebar {
  background: linear-gradient(180deg, #1f2a44 0%, #1a2238 100%);
  border-right: 2px solid rgba(0,0,0,0.25);
  box-shadow: 2px 0 12px rgba(0,0,0,.25);
}

.sidebar-header {
  border-bottom: 2px solid rgba(255,255,255,0.08);
}

.sidebar-section h3 { color: #e6ebff; }
.sidebar-section h4 { color: #c5cff5; }
.sidebar-subtitle { color: #aeb7da; }
.user-details span { color: #e6ebff; }
.user-details small { color: #51cf66; }

.sidebar .sidebar-toggle {
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  color: #e6ebff;
}
.sidebar .sidebar-toggle:hover {
  background: rgba(255,255,255,0.12);
}

.sidebar .settings-btn,
.sidebar .logout-btn {
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  color: #dbe4ff;
}
.sidebar .settings-btn:hover,
.sidebar .logout-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
}

.sidebar .dashboard-btn {
  background: linear-gradient(135deg, #0ea5a5, #14b8a6);
  border-color: rgba(255,255,255,0.12);
  color: #ffffff;
}

.sidebar-footer {
  background: rgba(0,0,0,0.20);
  border-top: 2px solid rgba(255,255,255,0.08);
}

/* Header mais escuro */
.chat-header {
  background: linear-gradient(180deg, #243453, #1f2a44);
  border-bottom: 2px solid rgba(0,0,0,0.30);
  color: #e6ebff;
}

.chat-header .chat-title h1 { color: #e6ebff; }
.chat-header .chat-title p { color: #c5cff5; }

.chat-header .action-btn,
.chat-header .mobile-menu-btn {
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  color: #e6ebff;
}
.chat-header .action-btn:hover,
.chat-header .mobile-menu-btn:hover {
  background: rgba(255,255,255,0.12);
}

/* Corpo e área de chat mais claros */
.main-content {
  background: linear-gradient(180deg, #fcfdff, #ffffff);
}

.messages-container {
  background: linear-gradient(180deg, #fcfeff, #ffffff);
}

/* Dashboards: header escuro global (professor/pais) */
.dashboard-header {
  background: linear-gradient(180deg, #243453, #1f2a44) !important;
  border-bottom: 2px solid rgba(0,0,0,0.30) !important;
  color: #e6ebff !important;
}

.dashboard-header .dashboard-title h1,
.dashboard-header h1 { color: #e6ebff !important; }
.dashboard-header .dashboard-title p,
.dashboard-header p { color: #c5cff5 !important; }

/* Admin: header escuro global */
.header {
  background: linear-gradient(180deg, #243453, #1f2a44) !important;
  color: #e6ebff !important;
}

.header h1 { color: #e6ebff !important; }
.header p { color: #c5cff5 !important; }

/* Fundo escuro para páginas específicas (ex.: dashboards) */
.bg-dark {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(71, 85, 105, 0.25) 0%, transparent 60%),
    radial-gradient(1000px 600px at 100% 100%, rgba(30, 41, 59, 0.25) 0%, transparent 60%),
    linear-gradient(180deg, #1f2a44, #1a2238);
}

/* ===== Conteúdo: Parágrafos e Cálculos ===== */
.bubble.assistant p { margin: 8px 0; font-size: 1.05em; }
.calc { background: #f9f9ff; padding: 12px; border-radius: 10px; margin: 12px 0; border: 2px solid #edf0ff; }
.calc h4 { margin: 0 0 8px; font-family: 'Chewy', cursive; }
.calc ol { margin: 0 0 8px 20px; }
.calc pre { background: #ffffff; padding: 8px; border-radius: 8px; border: 1px solid #edf0ff; overflow: auto; }
.resultado { font-weight: 800; color: #2e7d32; }
.continuacao { font-style: italic; color: #555; margin: 6px 0; }
