:root {
  --main-color-hover: #2f6044;
  --main-color-light: #eaf2ee;
  --main-color-dark: #2f6044;
  --main-color-shadow: rgba(58, 117, 85, 0.45);

body {
  font-family: "Inter", sans-serif;
  background-color: var(--main-color); /* MODIFICADO */
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}
.main-color-text {
  color: var(--main-color);
} /* MODIFICADO */
.main-color-bg {
  background-color: var(--main-color);
} /* MODIFICADO */
.main-color-bg-hover:hover {
  background-color: var(--main-color-hover);
} /* MODIFICADO */
.main-color-focus-ring:focus {
  ring-color: var(--main-color);
} /* MODIFICADO */
.main-color-radio {
  color: var(--main-color);
  accent-color: var(--main-color);
} /* MODIFICADO */
.main-color-border-hover:hover {
  border-color: var(--main-color);
} /* MODIFICADO */
.main-color-border-active {
  border-color: var(--main-color);
  color: var(--main-color);
} /* MODIFICADO */
.non-standard-checkbox {
  color: #d97706;
  accent-color: #d97706;
}
.non-standard-focus-ring:focus {
  ring-color: #d97706;
}
.filter-group {
  background-color: #fff;
  padding: 0.75rem;
  border-radius: 0.375rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  margin-bottom: 0.75rem;
  border: 1px solid #e5e7eb;
}
.filter-group legend {
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
.tri-state-label {
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  font-size: 0.875rem;
  color: #374151;
}
.tri-state-text {
  margin-left: 0.5rem;
}
.tri-state-label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: 2px solid #94a3b8;
  background-color: white;
  border-radius: 0.25rem;
  transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}
.tri-state-label::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s ease-in-out, color 0.15s ease-in-out;
  font-weight: bold;
  line-height: 1;
  color: white;
}
.tri-state-label.state-neutral::before {
  border-color: #94a3b8;
  background-color: white;
}
.tri-state-label.state-neutral::after {
  transform: translate(-50%, -50%) scale(0);
}
.tri-state-label.state-include::before {
  background-color: var(--main-color);
  border-color: var(--main-color);
} /* MODIFICADO */
.tri-state-label.state-include::after {
  content: "✓";
  font-size: 14px;
  transform: translate(-50%, -50%) scale(1);
}
.tri-state-label.state-exclude::before {
  background-color: #ef4444;
  border-color: #ef4444;
}
.tri-state-label.state-exclude::after {
  content: "✕";
  font-size: 13px;
  transform: translate(-50%, -50%) scale(1);
}
.trait-card {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}
.results-card {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  width: 100%;
}
.tab-button {
  transition: color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
.tab-pane {
  animation: fadeIn 0.5s;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lang-button svg {
  width: 36px;
  height: 24px;
  display: block;
  border-radius: 4px;
}
.lang-button {
  border: 2px solid transparent;
  transition: all 0.2s;
  cursor: pointer;
  background: none;
  padding: 2px;
  border-radius: 6px;
}
.lang-button:hover {
  transform: scale(1.1);
}
.lang-button.active {
  border-color: var(--main-color); /* MODIFICADO */
  box-shadow: 0 0 5px var(--main-color-shadow); /* MODIFICADO */
}

.bold-italic {
  font-weight: bold;
  font-style: italic;
}

.bold {
  font-weight: bold;
}

.italic {
  font-style: italic;
}

.inline-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;

  /* Garante que o ícone não seja preenchido com cor */
  fill: none;

  /* A cor do contorno será herdada da cor do texto pai */
  stroke: currentColor;

  /* Define uma espessura de contorno consistente para todos os ícones */
  stroke-width: 1.5;
}

@media print {
  body {
    background-color: #fff !important;
    color: #000 !important;
    font-size: 10pt;
    -webkit-print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  #sorterView,
  #backToSorterButton,
  footer,
  #app > header > p,
  #unclassifiedWarning,
  #advancedFilters .filter-group:nth-child(1),
  #advancedFilters .filter-group:nth-child(2),
  #langSelector {
    display: none !important;
  }
  #app > header > h1 {
    color: #000 !important;
    font-size: 18pt;
    text-align: left;
    margin-bottom: 0.5in;
  }
  #app {
    max-width: 100% !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 1cm 1cm 10cm 1cm !important;
  }
  #resultsView {
    display: block !important;
  }
  #resultsContainer {
    column-count: 1;
    gap: 0;
  }
  .results-card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    padding: 0.5rem !important;
    margin-bottom: 0.75rem !important;
    page-break-inside: avoid !important;
  }
  #resultsTitle {
    font-size: 16pt !important;
    color: #000 !important;
    margin-bottom: 0.75rem !important;
    border-bottom: 1px solid #999 !important;
    padding-bottom: 0.25rem !important;
    text-align: left;
  }
  #resultsContainer > div > h2 {
    font-size: 14pt !important;
    color: #000 !important;
    margin-top: 1rem !important;
    margin-bottom: 0.5rem !important;
    border-bottom: 1px solid #bbb !important;
    padding-bottom: 0.2rem !important;
  }
  .results-card > h3 {
    font-size: 12pt !important;
    color: #000 !important;
    border-bottom-color: #ccc !important;
  }
  .main-color-text {
    color: #000 !important;
  }
  ul {
    padding-left: 1.25rem !important;
    list-style: disc !important;
  }
  li {
    margin-bottom: 0.2rem !important;
    color: #000 !important;
  }
  .text-xs {
    font-size: 9pt !important;
  }
  .italic {
    font-style: italic !important;
  }
  .ml-4 {
    margin-left: 1rem !important;
  }
  .pl-2 {
    padding-left: 0.5rem !important;
  }
  .border-l-2 {
    border-left-width: 2px !important;
  }
  .border-gray-200,
  .border-gray-300 {
    border-color: #ccc !important;
  }
  .text-yellow-600 {
    color: #555 !important;
  }
  .text-gray-500,
  .text-gray-600,
  .text-gray-700 {
    color: #000 !important;
  }
  * {
    background-color: transparent !important;
    border-color: #000 !important;
    box-shadow: none !important;
  }
  .results-card {
    border: 1px solid #ddd !important;
  }
  #resultsTitle,
  #resultsContainer > div > h2,
  .results-card > h3 {
    border-bottom-color: #999 !important;
  }
  .tri-state-label::before {
    border-color: #666 !important;
    background-color: white !important;
  }
  .tri-state-label.state-include::before {
    background-color: #ccc !important;
    border-color: #666 !important;
  }
  .tri-state-label.state-exclude::before {
    background-color: #ccc !important;
    border-color: #666 !important;
  }
  .tri-state-label::after {
    color: black !important;
  }
}

.maugrim {
  display: inline-block;
  background-color: #272727;
  -webkit-mask-image: url("../img/maugrim.svg");
  mask-image: url("../img/maugrim.svg");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  margin: 1em;
}

#resultsView {
  background-color: #f8fafc;
  padding: 1rem;
}

#resultsTitle,
#resultsContainer > div > h2 {
  color: #333;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 3px solid var(--main-color); /* MODIFICADO */
  font-weight: 700;
}

#resultsContainer {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  #resultsContainer {
    grid-template-columns: repeat(2, 1fr);
  }
}

.results-card {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  break-inside: avoid;
  padding: 0;
}

.results-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.07),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.results-card > h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #fff;
  border: none;
}

.results-card > ul {
  padding: 1rem 1.25rem 1.25rem 2.5rem;
  margin: 0;
}

.results-card li {
  padding-bottom: 0.3rem;
  margin-bottom: 0.3rem;
}

.results-card .text-xs.text-gray-500.italic {
  border-left: 3px solid #e2e8f0;
  padding-left: 0.75rem;
  margin-top: 0.25rem;
  color: #4b5563;
}

.results-card.required > h3 {
  background-color: #2563eb;
}
.results-card.recommended > h3 {
  background-color: #576574;
}
.results-card.allowed > h3 {
  background-color: #059669;
}
.results-card.not_recommended > h3 {
  background-color: #f59e0b;
}
.results-card.forbidden > h3 {
  background-color: #dc2626;
}

.results-card > h3::after {
  content: "";
  display: inline-block;
  width: 24px;
  height: 24px;
  background-color: white;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.results-card.required > h3::after {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>');
}
.results-card.recommended > h3::after {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"></path></svg>');
}
.results-card.allowed > h3::after {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"></path></svg>');
}
.results-card.not_recommended > h3::after {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>');
}
.results-card.forbidden > h3::after {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>');
}

html {
  scroll-behavior: smooth;
}

#bookContent h2,
#bookContent h3 {
  scroll-margin-top: 1rem;
}

#tocList a {
  text-decoration: none;
  color: #4a5568;
  transition: color 0.2s;
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
}
#tocList a:hover {
  color: var(--main-color); /* MODIFICADO */
  background-color: #f7fafc;
}
.highlight-section {
  animation: highlight 1.5s ease-out;
}

@keyframes highlight {
  from {
    background-color: #fefcbf;
  }
  to {
    background-color: transparent;
  }
}

#tocList a.active-toc-link {
  background-color: var(--main-color-light); /* MODIFICADO */
  color: var(--main-color-dark); /* MODIFICADO */
  font-weight: 600;
}
#chapterNav button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chapterNav button#nextChapterBtn {
  background-color: var(--main-color); /* ADICIONADO para consistência */
}

#chapterNav button#nextChapterBtn:hover {
  background-color: var(--main-color-hover); /* ADICIONADO para consistência */
}

.results-card > ul {
  padding: 1rem 1.25rem 1.25rem 4rem;
  margin: 0;
}

#tocList {
  overflow-y: auto;
  /* A altura é calculada para preencher o espaço vertical disponível na tela */
  max-height: calc(100vh - 18rem);
  padding-right: 0.5rem; /* Espaço para a barra de rolagem não cobrir o texto */
}

#tocList .toc-sublist {
  display: none;
  padding-left: 1rem;
  margin-left: 0.75rem; /* Ajuste para alinhar com o ícone de expandir */
  border-left: 1px solid #e2e8f0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}
#tocList .toc-chapter.expanded > .toc-sublist {
  display: block;
  max-height: 1000px; /* Um valor alto para permitir a expansão */
}
#tocList .toc-toggle {
  display: inline-block;
  width: 1.5rem;
  text-align: center;
  cursor: pointer;
  font-family: monospace;
  font-size: 1rem;
  font-weight: bold;
  color: var(--main-color);
  flex-shrink: 0;
}
#tocList .toc-chapter-header {
  display: flex;
  align-items: center;
  cursor: pointer;
}
#tocList .toc-chapter-header > a {
  flex-grow: 1;
}

#tocList .toc-sublist a {
  font-weight: 500; /* Peso médio para subtítulos H2 */
}
#tocList .toc-sublist a.pl-4 {
  /* Estilo específico para os H3, que já têm a classe de padding */
  font-weight: 400; /* Peso normal */
  color: #4a5568; /* Cor um pouco mais clara */
  padding-left: 1rem;
}

#mobileTocButton {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background-color: var(--main-color);
  color: white;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transition: transform 0.2s ease-in-out;
}
#mobileTocButton:hover {
  transform: scale(1.1);
  background-color: var(--main-color-hover);
}

#tocOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1040; /* Menor que o z-index do sidebar */
}

@media (max-width: 767px) {
  #readerSidebar {
    position: fixed;
    top: 0;
    left: -90%; /* Começa fora da tela */
    width: 90%;
    max-width: 350px;
    height: 100%;
    z-index: 1050;
    transition: left 0.3s ease-in-out;
    overflow-y: auto;
  }

  #readerSidebar.toc-mobile-visible {
    left: 0; /* Entra na tela */
  }

  #backToSorterFromReader {
    width: auto; /* Ou 'fit-content' */
  }
}
