/* ============================================
   EstudaPlus - Banco de Questões Interativo
   EntroPlataforma
   ============================================ */

/* ---- Layout Principal ---- */
.estudaplus-layout {
  display: flex;
  min-height: 100vh;
  padding-top: 70px;
}

.estudaplus-sidebar {
  width: 280px;
  min-width: 280px;
  background: linear-gradient(180deg, #ffffff 0%, var(--green-50) 100%);
  border-right: 1px solid rgba(16, 185, 129, 0.12);
  padding: 24px 20px;
  position: fixed;
  top: 70px;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 50;
  transition: transform 0.3s ease;
}

.estudaplus-main {
  flex: 1;
  margin-left: 280px;
  padding: 28px 32px;
  max-width: 900px;
}

/* ---- Sidebar: Filtros ---- */
.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title i {
  color: var(--primary);
  font-size: 20px;
}

.filtro-grupo {
  margin-bottom: 18px;
}

.filtro-grupo label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.filtro-grupo select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-xs);
  background: white;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-dark);
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23047857' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.filtro-grupo select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.filtro-btn-aplicar {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 6px;
}

.filtro-btn-aplicar:hover {
  background: var(--primary-dark);
}

.filtro-btn-limpar {
  width: 100%;
  padding: 9px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}

.filtro-btn-limpar:hover {
  background: var(--green-50);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Mini Stats */
.sidebar-stats {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(16, 185, 129, 0.12);
}

.sidebar-stats-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
}

.stat-row .stat-label {
  color: #64748b;
}

.stat-row .stat-value {
  font-weight: 700;
  color: var(--text-dark);
}

.stat-row .stat-value.acertos {
  color: var(--status-success);
}

.stat-row .stat-value.erros {
  color: var(--status-danger);
}

/* Sidebar mobile toggle */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 60;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  transition: transform 0.2s;
}

.sidebar-mobile-toggle:active {
  transform: scale(0.92);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 49;
}

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

/* ---- Barra de Navegação de Questões ---- */
.questao-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.questao-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: white;
  border: 1.5px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s;
}

.questao-nav-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--green-50);
  color: var(--primary-dark);
}

.questao-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.questao-nav-info {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---- Card de Questão ---- */
.questao-card {
  background: white;
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: 0 2px 16px rgba(5, 150, 105, 0.08);
  margin-bottom: 20px;
}

.questao-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.questao-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-materia {
  color: white;
}

.badge-fonte {
  background: var(--green-50);
  color: var(--primary-dark);
}

.badge-ano {
  background: #f1f5f9;
  color: #475569;
}

.badge-dificuldade {
  background: #fef3c7;
  color: #92400e;
}

.badge-dificuldade.facil {
  background: #d1fae5;
  color: #065f46;
}

.badge-dificuldade.dificil {
  background: #fee2e2;
  color: #991b1b;
}

/* Cores por matéria */
.badge-portugues { background: #ef4444; }
.badge-matematica { background: #3b82f6; }
.badge-historia { background: #f59e0b; }
.badge-geografia { background: #22c55e; }
.badge-biologia { background: #10b981; }
.badge-fisica { background: #6366f1; }
.badge-quimica { background: #ec4899; }
.badge-filosofia { background: #8b5cf6; }
.badge-sociologia { background: #14b8a6; }
.badge-ingles { background: #f97316; }
.badge-redacao { background: #64748b; }

/* Texto-base */
.questao-texto-base {
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  padding: 18px 20px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: #334155;
}

.questao-texto-base .bloco-imagem {
  text-align: center;
  margin: 12px 0;
}

.questao-texto-base .bloco-imagem img {
  max-width: 100%;
  border-radius: var(--radius-xs);
}

/* Enunciado */
.questao-enunciado {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-dark);
  margin-bottom: 24px;
}

/* Blocos de conteúdo renderizados */
.bloco-texto {
  margin-bottom: 10px;
}

.bloco-formula {
  margin: 12px 0;
  text-align: center;
  overflow-x: auto;
}

.bloco-imagem {
  text-align: center;
  margin: 14px 0;
}

.bloco-imagem img {
  max-width: 100%;
  border-radius: var(--radius-xs);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bloco-tabela {
  margin: 14px 0;
  overflow-x: auto;
}

.bloco-tabela table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bloco-tabela th,
.bloco-tabela td {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.bloco-tabela th {
  background: var(--green-50);
  font-weight: 600;
  color: var(--text-dark);
}

.bloco-tabela tr:nth-child(even) td {
  background: #f8fafc;
}

/* ---- Alternativas ---- */
.alternativas-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alternativa-btn {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-family: inherit;
  width: 100%;
}

.alternativa-btn:hover:not(.disabled) {
  border-color: var(--primary);
  background: var(--green-50);
}

.alternativa-letra {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  background: #f1f5f9;
  font-size: 14px;
  font-weight: 700;
  color: #475569;
  transition: all 0.2s;
}

.alternativa-btn:hover:not(.disabled) .alternativa-letra {
  background: var(--primary);
  color: white;
}

.alternativa-texto {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dark);
  padding-top: 5px;
}

/* Estado: Correta */
.alternativa-btn.correta {
  border-color: var(--status-success);
  background: rgba(34, 197, 94, 0.06);
}

.alternativa-btn.correta .alternativa-letra {
  background: var(--status-success);
  color: white;
}

.alternativa-btn.correta::after {
  content: '\F26B';
  font-family: 'bootstrap-icons';
  margin-left: auto;
  font-size: 18px;
  color: var(--status-success);
  align-self: center;
}

/* Estado: Incorreta (escolhida pelo aluno) */
.alternativa-btn.incorreta {
  border-color: var(--status-danger);
  background: rgba(239, 68, 68, 0.06);
}

.alternativa-btn.incorreta .alternativa-letra {
  background: var(--status-danger);
  color: white;
}

.alternativa-btn.incorreta::after {
  content: '\F62A';
  font-family: 'bootstrap-icons';
  margin-left: auto;
  font-size: 18px;
  color: var(--status-danger);
  align-self: center;
}

/* Estado: Desabilitada (após responder) */
.alternativa-btn.disabled {
  pointer-events: none;
  opacity: 0.7;
}

.alternativa-btn.correta.disabled,
.alternativa-btn.incorreta.disabled {
  opacity: 1;
}

/* ---- Feedback ---- */
.feedback-box {
  margin-top: 24px;
  border-radius: 14px;
  padding: 22px 24px;
  animation: slideUp 0.35s ease-out;
}

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

.feedback-box.acertou {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 1.5px solid rgba(34, 197, 94, 0.25);
}

.feedback-box.errou {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.04) 100%);
  border: 1.5px solid rgba(239, 68, 68, 0.25);
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.feedback-header i {
  font-size: 22px;
}

.feedback-box.acertou .feedback-header i {
  color: var(--status-success);
}

.feedback-box.errou .feedback-header i {
  color: var(--status-danger);
}

.feedback-header span {
  font-size: 16px;
  font-weight: 700;
}

.feedback-box.acertou .feedback-header span {
  color: #065f46;
}

.feedback-box.errou .feedback-header span {
  color: #991b1b;
}

.feedback-gabarito {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.feedback-resolucao {
  font-size: 14px;
  line-height: 1.75;
  color: #334155;
}

.feedback-resolucao p {
  margin-bottom: 8px;
}

/* Botão Tirar Dúvida */
.btn-tirar-duvida {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-tirar-duvida:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

/* ---- Alternativa selecionada (antes de confirmar) ---- */
.alternativa-btn.selecionada {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.06);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

/* ---- Botão Confirmar Resposta ---- */
.btn-confirmar-resposta {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 20px auto 0;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--primary) 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
}

.btn-confirmar-resposta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-confirmar-resposta:active {
  transform: translateY(0);
}

/* ---- Painel IA (Drawer Lateral) ---- */
.ia-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 999;
}

.ia-overlay.active {
  display: block;
}

.ia-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100%;
  background: white;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
}

.ia-panel.open {
  right: 0;
}

.ia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, var(--green-50) 0%, white 100%);
}

.ia-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
}

.ia-header-title i {
  font-size: 20px;
  color: var(--primary);
}

.ia-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ia-close-btn:hover {
  background: #e2e8f0;
  color: var(--text-dark);
}

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

.ia-reset-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ia-reset-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.ia-limit-msg {
  text-align: center;
  padding: 12px 16px;
  color: #92400e;
  background: #fef3c7;
  border-radius: 8px;
  margin: 8px 16px;
  font-size: 13px;
}

.ia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ia-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
}

.ia-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.ia-msg.assistant {
  align-self: flex-start;
  background: #f1f5f9;
  color: var(--text-dark);
  border-bottom-left-radius: 4px;
}

.ia-msg.assistant p {
  margin-bottom: 6px;
}

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

.ia-msg.assistant code {
  background: rgba(16, 185, 129, 0.1);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 13px;
}

.ia-msg.typing {
  align-self: flex-start;
  background: #f1f5f9;
  color: #94a3b8;
  font-style: italic;
}

.ia-input-area {
  padding: 14px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 10px;
  background: #fafafa;
}

.ia-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  min-height: 42px;
  max-height: 100px;
  overflow-y: auto;
}

.ia-input:focus {
  outline: none;
  border-color: var(--primary);
}

.ia-send-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ia-send-btn:hover {
  background: var(--primary-dark);
}

.ia-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Welcome message in IA panel */
.ia-welcome {
  text-align: center;
  padding: 30px 20px;
  color: #94a3b8;
}

.ia-welcome i {
  font-size: 36px;
  color: var(--primary);
  margin-bottom: 12px;
  display: block;
}

.ia-welcome h4 {
  color: var(--text-dark);
  margin-bottom: 6px;
  font-size: 15px;
}

.ia-welcome p {
  font-size: 13px;
  line-height: 1.5;
}

/* ---- Loading States ---- */
.questao-loading {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}

.questao-loading i {
  font-size: 36px;
  color: var(--primary);
  animation: spin 1s linear infinite;
  display: block;
  margin-bottom: 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.questao-loading p {
  font-size: 14px;
}

.questao-empty {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}

.questao-empty i {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
  color: #cbd5e1;
}

.questao-empty p {
  font-size: 14px;
}

/* ---- Responsivo ---- */
@media (max-width: 1100px) {
  .estudaplus-main {
    padding: 24px 20px;
  }
}

@media (max-width: 768px) {
  .estudaplus-sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: 100;
  }

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

  .estudaplus-main {
    margin-left: 0;
    padding: 20px 14px;
  }

  .sidebar-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .questao-card {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .questao-nav-btn span.nav-btn-text {
    display: none;
  }

  .alternativa-btn {
    padding: 12px 14px;
    gap: 10px;
  }

  .alternativa-letra {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 13px;
  }

  .alternativa-texto {
    font-size: 13px;
  }

  .feedback-box {
    padding: 18px 16px;
  }

  /* Painel IA fullscreen no mobile */
  .ia-panel {
    width: 100%;
    right: -100%;
  }

  .ia-panel.open {
    right: 0;
  }
}

@media (max-width: 480px) {
  .questao-meta {
    gap: 6px;
  }

  .questao-badge {
    font-size: 10px;
    padding: 3px 8px;
  }

  .questao-enunciado {
    font-size: 14px;
  }

  .questao-texto-base {
    padding: 14px 16px;
    font-size: 13px;
  }
}

/* ---- Toggle Respondidas / Não Respondidas ---- */
.questao-mode-toggle {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px;
  justify-content: center;
  margin-bottom: 16px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.mode-btn.active {
  background: white;
  color: var(--primary-dark, #065f46);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.mode-btn:hover:not(.active) {
  color: var(--text-dark, #1e293b);
}

.mode-btn i {
  font-size: 14px;
}

.mode-count {
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary-dark, #065f46);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

/* ---- FAB Tutor IA ---- */
.ia-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--primary, #10b981) 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
  transition: all 0.3s ease;
}

.ia-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5);
}

.ia-fab:active {
  transform: scale(0.96);
}

.ia-fab i {
  font-size: 20px;
}

.ia-fab.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* ---- Mobile: Toggle e FAB ---- */
@media (max-width: 768px) {
  .mode-btn-text {
    display: none;
  }
  .mode-btn {
    padding: 7px 10px;
    gap: 4px;
  }
  .ia-fab {
    bottom: 20px;
    right: 20px;
  }
  .ia-fab-label {
    display: none;
  }
  .ia-fab {
    width: 52px;
    height: 52px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
}
