/* 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;
  min-height: 100vh;
  background: #ffffff;
}

@supports (height: 100dvh) {
  .chat-layout {
    height: 100dvh;
    min-height: 100dvh;
  }
}

/* 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;
  min-height: 0;
}

/* 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;
  min-height: 0;
  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;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: 2px solid #edf0ff;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(10px);
  position: sticky;
  bottom: 0;
  z-index: 8;
}

.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;
    height: 100dvh;
    min-height: 100dvh;
  }
  
  .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;
    min-height: 0;
  }
  
  .mobile-menu-btn {
    display: flex;
  }
  
  .sidebar-toggle {
    display: flex;
  }
  
  .messages {
    padding: 0 16px;
  }
  
  .input-container {
    padding: 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  
  .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;
  line-clamp: 2;
  -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; }

/* ===== Prof IA Design System 2026 ===== */
:root {
  --prof-bg: #07103f;
  --prof-surface: rgba(12, 22, 82, 0.72);
  --prof-surface-solid: #0d1a64;
  --prof-surface-light: #f4f5fb;
  --prof-surface-card: rgba(255, 255, 255, 0.82);
  --prof-surface-card-strong: rgba(255, 255, 255, 0.94);
  --prof-border: rgba(85, 223, 247, 0.16);
  --prof-border-strong: rgba(29, 95, 255, 0.22);
  --prof-text: #10204e;
  --prof-text-soft: #5b6994;
  --prof-text-inverse: #f4f5fb;
  --prof-primary: #08145f;
  --prof-primary-2: #1d5fff;
  --prof-accent: #55dff7;
  --prof-violet: #6a1bff;
  --prof-success: #1fa971;
  --prof-danger: #d94e67;
  --prof-warning: #ff9f43;
  --prof-shadow-sm: 0 18px 42px rgba(8, 20, 95, 0.08);
  --prof-shadow-md: 0 22px 60px rgba(8, 20, 95, 0.14);
  --prof-shadow-lg: 0 26px 72px rgba(8, 20, 95, 0.18);
  --prof-glow: 0 0 0 1px rgba(85, 223, 247, 0.08), 0 16px 50px rgba(29, 95, 255, 0.16);
  --prof-radius-sm: 14px;
  --prof-radius-md: 22px;
  --prof-radius-lg: 30px;
  --prof-gradient-main: linear-gradient(135deg, #08145f 0%, #1d5fff 52%, #55dff7 100%);
  --prof-gradient-panel: linear-gradient(145deg, rgba(10, 20, 82, 0.94) 0%, rgba(19, 38, 120, 0.92) 48%, rgba(34, 82, 191, 0.78) 100%);
  --prof-gradient-soft: radial-gradient(circle at top left, rgba(85, 223, 247, 0.28), transparent 38%), radial-gradient(circle at top right, rgba(106, 27, 255, 0.22), transparent 34%), linear-gradient(180deg, #f8fbff 0%, #f4f5fb 100%);
  --font-heading: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

html {
  color-scheme: light;
}

body {
  font-family: var(--font-body);
  color: var(--prof-text);
  background: var(--prof-gradient-soft);
}

h1, h2, h3, h4, h5, h6,
.chat-title h1,
.dashboard-title h1,
.math-title {
  font-family: var(--font-heading);
  letter-spacing: -0.03em;
}

.ui-icon {
  width: 1.05em;
  height: 1.05em;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-label,
.title-with-icon,
.btn-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-shell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 96px;
  padding: 16px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(244,245,251,0.78));
  box-shadow: var(--prof-glow);
  border: 1px solid rgba(255,255,255,0.72);
}

.auth-badge,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(8, 20, 95, 0.08);
  color: var(--prof-primary);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(29, 95, 255, 0.12);
}

.bg-dark,
.bg-gradient {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(85, 223, 247, 0.20), transparent 30%),
    radial-gradient(circle at top right, rgba(106, 27, 255, 0.18), transparent 30%),
    radial-gradient(circle at bottom center, rgba(29, 95, 255, 0.12), transparent 36%),
    linear-gradient(180deg, #eef3ff 0%, #f4f5fb 45%, #eef2ff 100%);
}

.chat-layout {
  background:
    radial-gradient(circle at top left, rgba(85, 223, 247, 0.15), transparent 24%),
    radial-gradient(circle at top right, rgba(106, 27, 255, 0.14), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, #f4f5fb 100%);
}

.glass {
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: var(--prof-shadow-lg);
  border-radius: var(--prof-radius-lg);
}

.card {
  padding: 36px;
  max-width: 520px;
  margin: 24px auto;
}

.auth-wrapper {
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before,
.auth-wrapper::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  filter: blur(18px);
  opacity: 0.44;
  pointer-events: none;
  z-index: 0;
}

.auth-wrapper::before {
  top: -80px;
  left: -80px;
  background: radial-gradient(circle, rgba(85, 223, 247, 0.45) 0%, rgba(85, 223, 247, 0) 70%);
}

.auth-wrapper::after {
  bottom: -120px;
  right: -70px;
  background: radial-gradient(circle, rgba(106, 27, 255, 0.34) 0%, rgba(106, 27, 255, 0) 72%);
}

.auth-wrapper > * {
  position: relative;
  z-index: 1;
}

.sub,
.muted,
.chat-title p,
.sidebar-subtitle,
.stat-description {
  color: var(--prof-text-soft);
}

.form,
.settings-form {
  gap: 18px;
}

.input-group span,
.form-group label {
  color: var(--prof-primary);
  font-weight: 700;
  font-size: 0.92rem;
}

.input-group input,
.input-group select,
.form-group input,
.form-group select,
.search-box,
.chat-form textarea {
  font-family: var(--font-body);
}

.input-group input,
.input-group select,
.form-group input,
.form-group select,
.search-box {
  border: 1px solid rgba(8, 20, 95, 0.08);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}

.input-group input:focus,
.input-group select:focus,
.form-group input:focus,
.form-group select:focus,
.search-box:focus {
  border-color: rgba(29, 95, 255, 0.48);
  box-shadow: 0 0 0 5px rgba(29, 95, 255, 0.12), 0 10px 28px rgba(8, 20, 95, 0.08);
  transform: translateY(-1px);
}

.btn {
  border-radius: 18px;
  padding: 14px 22px;
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: var(--prof-shadow-sm);
}

.btn.primary,
.new-chat-btn,
.btn-primary,
.send-btn,
.continue-btn {
  background: var(--prof-gradient-main);
  color: #fff;
  box-shadow: 0 14px 34px rgba(29, 95, 255, 0.24);
}

.btn.secondary,
.settings-btn,
.logout-btn,
.dashboard-btn,
.action-btn,
.mobile-menu-btn,
.mic-btn,
.attach-btn,
.modal-close,
.sidebar-toggle {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(8, 20, 95, 0.08);
  color: var(--prof-primary);
}

.btn:hover,
.new-chat-btn:hover,
.send-btn:hover,
.continue-btn:hover,
.action-btn:hover,
.mic-btn:hover,
.attach-btn:hover,
.settings-btn:hover,
.logout-btn:hover,
.dashboard-btn:hover,
.mobile-menu-btn:hover,
.sidebar-toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--prof-shadow-md);
}

.btn-danger {
  background: linear-gradient(135deg, #c83d5b, #f06b7f) !important;
}

.btn-success {
  background: linear-gradient(135deg, #0c8a72, #1fa971) !important;
}

.btn-warning {
  background: linear-gradient(135deg, #ff9f43, #ffbe63) !important;
}

.sidebar {
  background: var(--prof-gradient-panel);
  border-right: 1px solid rgba(85, 223, 247, 0.12);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.04), 12px 0 34px rgba(6, 10, 34, 0.28);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), transparent 30%);
  pointer-events: none;
}

.sidebar-header,
.sidebar-footer {
  border-color: rgba(255,255,255,0.08);
  background: transparent;
}

.logo-container {
  width: 100%;
}

.logo-container .logo {
  max-width: 132px;
}

.new-chat-btn {
  width: 100%;
  justify-content: flex-start;
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,0.08);
}

.chat-item,
.chat-group-card {
  border-radius: 18px;
  border: 1px solid rgba(85, 223, 247, 0.12);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  box-shadow: none;
}

.chat-item:hover,
.chat-group-card:hover,
.chat-group-card.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(85, 223, 247, 0.22);
  box-shadow: 0 12px 28px rgba(8, 20, 95, 0.16);
}

.chat-title,
.chat-group-header,
.sidebar-section h3,
.sidebar-section h4,
.user-details span {
  color: var(--prof-text-inverse);
}

.chat-meta,
.chat-group-preview,
.chat-group-time,
.sidebar-subtitle,
.user-details small {
  color: rgba(244, 245, 251, 0.74);
}

.chat-header {
  background: rgba(244, 245, 251, 0.68);
  border-bottom: 1px solid rgba(8, 20, 95, 0.08);
  backdrop-filter: blur(20px);
}

.chat-title h1 {
  font-size: 1.28rem;
  color: var(--prof-primary);
}

.main-content,
.messages-container {
  background: transparent;
}

.messages {
  max-width: 960px;
  gap: 18px;
}

.avatar {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(8, 20, 95, 0.08);
  background: linear-gradient(145deg, rgba(8,20,95,0.12), rgba(85,223,247,0.18));
  color: var(--prof-primary);
}

.bubble {
  max-width: min(76%, 720px);
  padding: 16px 18px;
  border-radius: 22px;
  box-shadow: var(--prof-shadow-sm);
}

.bubble.assistant {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(244,245,251,0.92));
  border: 1px solid rgba(29, 95, 255, 0.12);
  color: var(--prof-text);
}

.bubble.user {
  background: linear-gradient(135deg, #0d1a64 0%, #1d5fff 58%, #55dff7 120%);
  border: 1px solid rgba(85, 223, 247, 0.28);
  color: #fff;
}

.input-container {
  background: rgba(244, 245, 251, 0.72);
  border-top: 1px solid rgba(8, 20, 95, 0.08);
  backdrop-filter: blur(20px);
}

.input-wrapper {
  gap: 14px;
  padding: 14px 16px;
  border-radius: 24px;
  border: 1px solid rgba(8, 20, 95, 0.08);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--prof-shadow-md);
}

.input-wrapper:focus-within {
  border-color: rgba(29, 95, 255, 0.36);
  box-shadow: 0 0 0 5px rgba(29, 95, 255, 0.10), 0 24px 50px rgba(8, 20, 95, 0.12);
}

.chat-form textarea {
  font-size: 0.97rem;
  color: var(--prof-text);
}

.messages-container::before {
  opacity: 0.035;
}

.modal-overlay,
.modal,
.history-modal,
.modal-overlay-login {
  background: rgba(6, 10, 34, 0.46);
  backdrop-filter: blur(12px);
}

.modal-content,
.history-modal-content,
.modal-card-login {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.76);
  box-shadow: var(--prof-shadow-lg);
  border-radius: 26px;
}

.modal-header,
.history-modal-header,
.modal-head-login {
  background: transparent;
  border-bottom: 1px solid rgba(8, 20, 95, 0.08);
}

.modal-header h2,
.modal-header h3,
.history-modal-header h2,
.modal-head-login h2 {
  color: var(--prof-primary);
}

.tab-btn {
  border-radius: 14px;
  color: var(--prof-text-soft);
}

.tab-btn.active {
  background: rgba(8, 20, 95, 0.08);
  color: var(--prof-primary);
  border-color: rgba(29, 95, 255, 0.18);
}

.header,
.actions-bar,
.users-table,
.dashboard-header,
.stat-card,
.children-table-section,
.add-child-section,
.table-header {
  background: rgba(255, 255, 255, 0.78) !important;
  backdrop-filter: blur(22px) !important;
  border: 1px solid rgba(255, 255, 255, 0.72) !important;
  box-shadow: var(--prof-shadow-md) !important;
}

.dashboard-header,
.header {
  border-radius: 28px !important;
}

.stat-card,
.children-table-section,
.add-child-section,
.users-table,
.actions-bar {
  border-radius: 24px !important;
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--prof-gradient-main);
}

.stat-number,
.stat-value {
  font-family: var(--font-heading);
  color: var(--prof-primary) !important;
  letter-spacing: -0.05em;
}

.status-badge,
.nivel-badge {
  border: 1px solid transparent;
}

.status-ativo,
.status-active {
  background: rgba(31, 169, 113, 0.12);
  color: #0b7c58;
}

.status-inativo,
.status-inactive {
  background: rgba(217, 78, 103, 0.12);
  color: #b53d5d;
}

.search-box {
  min-height: 48px;
  border-radius: 16px;
}

.children-table th,
table th {
  background: rgba(8, 20, 95, 0.04) !important;
  color: var(--prof-primary) !important;
}

.children-table tr:hover,
table tr:hover {
  background: rgba(29, 95, 255, 0.03) !important;
}

.loading,
.loading-modal,
.no-chats,
.no-children {
  color: var(--prof-text-soft);
}

.error-message,
.error-message-modal {
  background: rgba(217, 78, 103, 0.10);
  color: #b53d5d;
  border-color: rgba(217, 78, 103, 0.16);
}

.success-message {
  background: rgba(31, 169, 113, 0.12);
  color: #0b7c58;
  border-color: rgba(31, 169, 113, 0.16);
}

.quiz-timer,
.quiz-explanation,
.score-circle,
.alternative-btn,
.progress-bar,
.question-text {
  border-radius: 18px;
}

.progress-bar {
  background: rgba(8, 20, 95, 0.08);
}

.progress-fill {
  background: linear-gradient(90deg, #1d5fff, #55dff7);
}

.alternative-btn {
  border: 1px solid rgba(8, 20, 95, 0.08);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--prof-shadow-sm);
}

.alternative-btn:hover:not(:disabled) {
  border-color: rgba(29, 95, 255, 0.26);
  background: rgba(244, 245, 251, 0.96);
}

.score-circle {
  background: linear-gradient(135deg, #08145f, #6a1bff 70%, #55dff7 120%);
}

@media (max-width: 768px) {
  .card {
    padding: 24px;
  }

  .brand-logo-shell {
    min-width: 82px;
    min-height: 82px;
  }

  .bubble {
    max-width: 90%;
  }

  .header,
  .dashboard-header,
  .actions-bar,
  .stat-card,
  .children-table-section,
  .add-child-section {
    border-radius: 22px !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; }

/* ========================================================================================
                    MOBILE-FIRST RESPONSIVENESS SYSTEM v2.0
   Includes: table→cards, safe-areas, 320-1024px breakpoints, accessible buttons
======================================================================================== */

/* SAFE-AREA IMPLEMENTATION */
.dashboard-container,
.card,
.auth-wrapper,
.chat-layout {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
}

.input-container {
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* Notch/Dynamic Island Support */
@supports (padding-left: max(0px)) {
  .sidebar-header,
  .chat-header,
  .header,
  .dashboard-header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* BUTTON ACCESSIBILITY - Min 44px touch target */
.btn,
.new-chat-btn,
.send-btn,
.mic-btn,
.attach-btn,
.action-btn,
.settings-btn,
.logout-btn,
.dashboard-btn,
.mobile-menu-btn,
.sidebar-toggle,
.btn-small,
.modal-close,
.tab-btn,
.alternative-btn,
.forgot-btn,
.modal-close-login {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* FORM ELEMENTS ACCESSIBILITY - 16px font to prevent zoom on iOS */
.input-group input,
.input-group select,
.form-group input,
.form-group select,
.chat-form textarea,
.search-box {
  min-height: 44px;
  font-size: 16px; /* Prevents auto-zoom on iOS */
  padding: 12px 16px;
}

/* TOUCH FRIENDLY SPACING */
.action-buttons {
  gap: 8px;
  flex-wrap: wrap;
  max-width: 100%;
}

.action-buttons .btn-small {
  min-width: auto;
  margin: 0;
  max-width: 100%;
}

/* TABLE TO CARD TRANSFORMATION - Mobile First */
@media (max-width: 767px) {
  /* Hide table headers on mobile */
  table thead {
    display: none;
  }
  
  /* Transform each row into a card */
  table,
  table tbody,
  table tr {
    display: block;
    width: 100%;
  }
  
  table tbody {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  table tr {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(8, 20, 95, 0.08) !important;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin: 0 !important;
  }
  
  table td {
    display: grid;
    grid-template-columns: clamp(84px, 28vw, 110px) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0;
    border: none !important;
    background: transparent !important;
  }

  table td > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  
  /* Add labels before each td using data-label attribute */
  table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--prof-primary, #08145f);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    word-break: break-word;
  }
  
  /* Action buttons in card layout */
  table td:last-child {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    min-width: 0;
  }
  
  table td:last-child::before {
    content: none;
  }
  
  table .action-buttons {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    gap: 8px;
    flex-direction: column;
    flex-wrap: nowrap;
  }
  
  table .action-buttons .btn,
  table .action-buttons .btn-small {
    width: 100%;
    max-width: 100%;
    flex: none;
    min-width: 0;
    margin: 0 !important;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  table .action-buttons .btn-label {
    white-space: normal;
    width: 100%;
    justify-content: center;
  }
}

/* Extra small phones (320px - 480px) */
@media (max-width: 480px) {
  /* Typography adjustments */
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
  h4, h5, h6 { font-size: 1rem; }
  
  p, span, body { font-size: 15px; line-height: 1.5; }
  
  /* Container padding */
  .dashboard-container,
  .card,
  .chat-layout {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  
  /* Header adjustments */
  .header,
  .dashboard-header,
  .chat-header {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    border-radius: 20px !important;
  }
  
  .header > div:last-child,
  .dashboard-header > div:last-child {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  
  .header h1,
  .dashboard-header h1 {
    font-size: 1.4rem;
    margin: 0;
  }
  
  .header p,
  .dashboard-header p {
    font-size: 0.9rem;
    margin: 0;
  }
  
  /* Grid adjustments */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
    text-align: center;
  }
  
  .stat-value {
    font-size: 1.8rem;
  }
  
  .stat-card h3 {
    font-size: 0.8rem;
  }
  
  /* Button grid */
  .action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  
  .btn-small {
    width: 100%;
  }
  
  /* Modal adjustments */
  .modal-content,
  .history-modal-content {
    width: 95% !important;
    max-height: 90vh;
    margin: 10% auto;
    border-radius: 20px;
  }
  
  /* Form grid */
  .form-row {
    grid-template-columns: 1fr;
  }
  
  /* Search box */
  .search-box {
    width: 100%;
    font-size: 16px;
  }
  
  /* Message bubbles */
  .messages {
    padding: 0 8px;
    gap: 12px;
  }
  
  .bubble {
    max-width: 100%;
    padding: 12px 14px;
    font-size: 14px;
  }
  
  /* Input area */
  .input-container {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  
  .input-wrapper {
    min-height: 48px;
    gap: 10px;
  }
  
  .chat-form textarea {
    font-size: 16px;
    min-height: 36px;
    max-height: 100px;
  }
  
  /* Table card style */
  table tr {
    padding: 16px;
    gap: 10px;
  }
  
  table td {
    grid-template-columns: 100px 1fr;
    gap: 8px;
    font-size: 14px;
  }
  
  table td::before {
    font-size: 0.75rem;
  }
  
  /* Sidebar */
  .sidebar {
    width: 75vw;
    max-width: 280px;
  }
  
  .sidebar-header {
    padding: 12px 16px;
  }
  
  .logo {
    max-width: 100px;
  }
  
  /* Quiz adjustments */
  .quiz-timer {
    font-size: 14px;
    padding: 10px 12px;
  }
  
  .alternative-btn {
    padding: 14px 12px;
    font-size: 15px;
  }
}

/* Small phones (480px - 640px) */
@media (max-width: 640px) {
  .dashboard-container {
    padding: 14px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-card {
    padding: 18px;
  }
  
  .stat-value {
    font-size: 2rem;
  }
  
  .card {
    padding: 24px;
    max-width: 95%;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .action-buttons {
    flex-wrap: wrap;
  }
  
  table tr {
    padding: 18px;
  }
  
  table td::before {
    font-size: 0.8rem;
  }
}

/* Medium screens (640px - 768px) */
@media (max-width: 768px) and (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .action-buttons {
    flex-wrap: wrap;
  }
  
  .modal-content {
    width: 90%;
    max-width: 600px;
  }
}

/* Mobile improvements (max 768px) - Enhanced */
@media (max-width: 768px) {
  /* Window/viewport height for mobile browsers */
  @supports (height: 100dvh) {
    .chat-layout {
      height: 100dvh;
    }
  }
  
  /* Chat improvements */
  .chat-header {
    padding: 12px 16px;
    gap: 8px;
  }
  
  .chat-title h1 {
    font-size: 1.1rem;
  }
  
  .chat-title p {
    font-size: 0.85rem;
  }
  
  /* Message area */
  .messages-container {
    -webkit-overflow-scrolling: touch;
  }
  
  .messages {
    padding: 12px 12px;
    max-width: 100%;
    gap: 14px;
  }
  
  .msg-row {
    align-items: flex-end;
  }
  
  .bubble {
    max-width: 88%;
    padding: 11px 15px;
    font-size: 15px;
    line-height: 1.5;
    border-radius: 20px;
  }
  
  /* Input improvements */
  .input-container {
    padding: 14px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }
  
  .input-wrapper {
    min-height: 46px;
    padding: 12px 14px;
    gap: 10px;
    border-radius: 22px;
  }
  
  .chat-form textarea {
    min-height: 40px;
    font-size: 16px;
    padding: 6px 0;
  }
  
  .send-btn,
  .mic-btn,
  .attach-btn {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  /* Continue button */
  .continue-btn {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    padding: 10px 16px;
    font-size: 14px;
  }
  
  /* Modals */
  .modal-content,
  .history-modal-content,
  .modal-card-login {
    width: 95%;
    margin: 20% auto;
    border-radius: 22px;
    max-width: 95%;
  }
  
  .modal-header,
  .history-modal-header {
    padding: 18px 20px 14px;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .modal-header h2,
  .modal-header h3,
  .history-modal-header h2 {
    font-size: 1.2rem;
    margin: 0;
  }
  
  .modal-close,
  .history-modal-close,
  .modal-close-login {
    position: absolute;
    top: 16px;
    right: 16px;
    min-width: 40px;
    min-height: 40px;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  /* Formulários */
  .form-group label {
    font-size: 15px;
  }
  
  .input-group span,
  .form-group label {
    font-size: 15px;
  }
  
  .form-group input,
  .form-group select,
  .input-group input,
  .input-group select {
    font-size: 16px;
    min-height: 44px;
  }
  
  /* Actions bar */
  .actions-bar {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }
  
  .search-box {
    width: 100%;
    max-width: 100%;
  }
  
  /* Dashboard cards */
  .stat-card {
    min-height: 140px;
  }
  
  /* Children/Users table */
  .children-table tr,
  table tr {
    margin-bottom: 12px;
  }
  
  /* Sidebar */
  .sidebar {
    left: -100%;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar.sidebar-open {
    left: 0;
  }
}

/* Large screens (1024px+) - Ensure desktop experience */
@media (min-width: 1024px) {
  .dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
  }
  
  table thead {
    display: table-header-group;
  }
  
  table tbody,
  table tr {
    display: table-row;
  }
  
  table tbody {
    gap: 0;
  }
  
  table td {
    display: table-cell;
    padding: 15px 20px;
    border-bottom: 1px solid #edf0ff;
  }
  
  table td::before {
    content: none;
  }
  
  table tr:hover {
    background: #fafbff;
  }
  
  .modal-content {
    width: auto;
    max-width: 600px;
  }
}

/* Landscape orientation improvements */
@media (max-height: 500px) and (orientation: landscape) {
  .header,
  .dashboard-header {
    padding: 12px 16px;
  }
  
  .header h1,
  .dashboard-header h1 {
    font-size: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
  }
  
  .stat-card {
    padding: 12px;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .input-container {
    padding: 10px 14px;
  }
}

/* Pref
ers reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High DPI/Retina screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .btn,
  .bubble,
  .stat-card,
  .modal-content {
    border-width: 1px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }
}

/* Touch device specific */
@media (hover: none) and (pointer: coarse) {
  .action-btn:active,
  .btn:active,
  button:active {
    transform: scale(0.98);
  }
  
  .bubble:active,
  .chat-item:active,
  .modal-content:active {
    opacity: 0.95;
  }
}
.continuacao { font-style: italic; color: #555; margin: 6px 0; }
