/* ==========================================================================
   1. SISTEMA DE TEMAS E VARIÁVEIS (Light / Dark Mode)
   ========================================================================== */
:root {
  /* Cores de Fundo e Superfície */
  --bg-color: #FAFAFA;
  --surface-color: #FFFFFF;
  
  /* Cores de Texto */
  --text-primary: #2D3748;
  --text-secondary: #718096;
  
  /* Bordas e Destaques */
  --border-color: #E2E8F0;
  --accent-color: #1B5F8C; /* Azul principal do App */
  
  /* Cores de Grifo (Modo Claro) */
  --hl-yellow: rgba(253, 224, 71, 0.6);
  --hl-green: rgba(134, 239, 172, 0.6);
  --hl-blue: rgba(147, 197, 253, 0.6);
  --hl-pink: rgba(249, 168, 212, 0.6);
  
  /* Callouts (Caixas de Observação) */
  --callout-bg: #EBF8FF;
  --callout-border: #3182CE;
}

[data-theme="dark"] {
  --bg-color: #121212;
  --surface-color: #1E1E1E;
  
  --text-primary: #E2E8F0;
  --text-secondary: #A0AEC0;
  
  --border-color: #2D3748;
  --accent-color: #63B3ED;
  
  /* Cores de Grifo (Modo Escuro - Menos opacidade para não ofuscar) */
  --hl-yellow: rgba(253, 224, 71, 0.25);
  --hl-green: rgba(134, 239, 172, 0.25);
  --hl-blue: rgba(147, 197, 253, 0.25);
  --hl-pink: rgba(249, 168, 212, 0.25);
  
  /* Callouts */
  --callout-bg: #2A4365;
  --callout-border: #63B3ED;
}

/* ==========================================================================
   2. RESET E BASE
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Noto Serif', serif; /* Fonte perfeita para leitura de livros */
  line-height: 1.8;
  font-size: 1.15rem;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Tipografia de UI (Interface) usa Inter, não a fonte de leitura */
.reader-header, 
.reader-footer, 
.selection-toolbar, 
.notes-sidebar, 
.callout {
  font-family: 'Inter', sans-serif;
}

/* ==========================================================================
   3. CABEÇALHO E PROGRESSO (Header)
   ========================================================================== */
.reader-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.reader-actions {
  display: flex;
  gap: 8px;
}

/* Barra de Progresso de Leitura */
.reader-progress-container {
  flex-grow: 1;
  max-width: 400px;
  height: 6px;
  background: var(--border-color);
  border-radius: 4px;
  margin: 0 24px;
  overflow: hidden;
}

.reader-progress-bar {
  height: 100%;
  background: var(--accent-color);
  width: 0%;
  transition: width 0.1s ease-out;
}

/* ==========================================================================
   4. BOTÕES DA INTERFACE (UI Buttons)
   ========================================================================== */
/* Botões redondos do Header (Estilo Apple) */
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer; 
  width: 44px; 
  height: 44px;
  border-radius: 50%;
  display: flex; 
  align-items: center; 
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.icon-btn:hover {
  background: rgba(160, 174, 192, 0.15);
  color: var(--accent-color);
}

.icon-btn:active {
  transform: scale(0.9);
}

/* Botões limpos (usados dentro da Sidebar) */
.icon-btn-clean {
  background: transparent; 
  border: none; 
  cursor: pointer; 
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.icon-btn-clean:hover {
  color: var(--accent-color);
}

/* Botão Primário (Concluir Módulo) */
.btn.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background-color: var(--accent-color); /* Usa o azul que definimos */
  color: #FFFFFF !important;
  text-decoration: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn.primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.btn.primary .material-symbols-sharp {
  font-size: 22px;
}

.btn-primary:active {
  transform: translateY(0);
}

/* Botão Secundário (Salvar Nota) */
.btn-secondary {
  background: var(--accent-color);
  color: #FFFFFF;
  padding: 12px; 
  border-radius: 8px; 
  border: none; 
  font-weight: 600;
  cursor: pointer; 
  width: 100%; 
  margin-top: 15px;
  transition: opacity 0.2s ease;
}

.btn-secondary:hover {
  opacity: 0.9;
}

/* ==========================================================================
   5. ÁREA DE LEITURA (Content)
   ========================================================================== */
.reader-content {
  max-width: 700px; /* Largura ideal para leitura (aprox. 65-75 caracteres por linha) */
  margin: 100px auto 60px;
  padding: 0 24px;
}

.reader-content h1, 
.reader-content h2, 
.reader-content h3 {
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  margin-top: 2em; 
  margin-bottom: 0.5em;
  line-height: 1.3;
}

.reader-content p {
  margin-bottom: 1.5em;
}

/* Palavras em Grego Koinê */
.grk {
  font-size: 1.25em; 
  font-weight: 700; 
  color: var(--accent-color);
  letter-spacing: 0.5px;
}

/* Caixa de Callout (Observações, Dicas) */
.callout {
  padding: 20px; 
  border-radius: 8px;
  border-left: 5px solid var(--callout-border);
  background-color: var(--callout-bg);
  margin: 2em 0; 
  font-size: 1rem;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.callout-title {
  font-weight: 700; 
  margin-bottom: 8px; 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  color: var(--callout-border);
}

/* Container do Iframe (Exercícios) */
.iframe-container {
  width: 100%; 
  height: 75vh; /* Altura responsiva baseada na tela do usuário */
  min-height: 600px;
  border: 2px solid var(--border-color);
  border-radius: 12px; 
  overflow: hidden; 
  margin: 3em 0;
  background: var(--surface-color);
  box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

.iframe-container iframe {
  width: 100%; 
  height: 100%; 
  border: none;
}

/* Rodapé do Leitor (Aparece no fim) */
.reader-footer {
  display: flex;
  justify-content: center;
  padding: 40px 24px 80px;
}

/* ==========================================================================
   6. SELEÇÃO DE TEXTO E MENU FLUTUANTE (Kindle Style)
   ========================================================================== */
::selection {
  background: var(--hl-yellow);
}

/* O Menu Flutuante */
.selection-toolbar {
  position: absolute;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border-radius: 12px;
  display: flex; 
  align-items: center; 
  gap: 12px;
  padding: 10px 16px;
  z-index: 200;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  transform: translateY(-10px) translateX(-50%);
}

.selection-toolbar.hidden {
  opacity: 0; 
  pointer-events: none;
  transform: translateY(0px) translateX(-50%);
}

/* Botões de Cor no Menu */
.color-btn {
  width: 26px; 
  height: 26px; 
  border-radius: 50%; 
  border: 2px solid rgba(0,0,0,0.1); 
  cursor: pointer; 
  transition: transform 0.15s ease;
}

.color-btn:hover {
  transform: scale(1.2); 
  border-color: var(--text-primary);
}

.toolbar-divider {
  width: 1px; 
  height: 24px; 
  background: var(--border-color);
}

.action-btn {
  background: none; 
  border: none; 
  color: var(--text-secondary); 
  cursor: pointer; 
  display: flex; 
  transition: color 0.2s ease;
}

.action-btn:hover {
  color: var(--accent-color);
}

/* Cores de Grifo (Mark) */
mark {
  padding: 2px 4px; 
  border-radius: 4px; 
  color: inherit; 
  transition: opacity 0.2s ease;
}

.hl-yellow { background: var(--hl-yellow) !important; }
.hl-green  { background: var(--hl-green) !important; }
.hl-blue   { background: var(--hl-blue) !important; }
.hl-pink   { background: var(--hl-pink) !important; }

/* Grifo que contém uma Anotação do usuário */
mark.has-note {
  border-bottom: 2px dashed var(--accent-color);
  cursor: pointer;
}

mark.has-note:hover {
  opacity: 0.8;
}

/* ==========================================================================
   7. BARRA LATERAL DE ANOTAÇÕES (Sidebar)
   ========================================================================== */
.notes-sidebar {
  position: fixed; 
  top: 60px; /* Começa logo abaixo do header */
  right: -100%; /* Escondida por padrão */
  width: 350px; 
  max-width: 100%; /* Previne que quebre em telas mobile menores que 350px */
  height: calc(100vh - 60px);
  background: var(--surface-color);
  border-left: 1px solid var(--border-color);
  box-shadow: -5px 0 25px rgba(0,0,0,0.05);
  transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 90; /* Fica abaixo do header, mas acima do conteúdo */
  display: flex; 
  flex-direction: column;
}

.notes-sidebar.open {
  right: 0;
}

.sidebar-view {
  display: flex; 
  flex-direction: column; 
  height: 100%;
}

.sidebar-view.hidden {
  display: none;
}

.notes-header {
  padding: 16px 24px; 
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.notes-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.notes-list-content, 
.note-editor-content {
  padding: 24px; 
  overflow-y: auto; 
  flex-grow: 1;
}

/* Lista Vazia */
.empty-notes {
  color: var(--text-secondary); 
  text-align: center; 
  font-size: 0.95rem; 
  margin-top: 40px;
}

/* Editor de Nota Única */
.note-quote {
  font-family: 'Noto Serif', serif;
  font-style: italic;
  color: var(--text-secondary);
  border-left: 4px solid var(--accent-color);
  padding-left: 16px;
  margin-bottom: 24px;
  font-size: 1rem;
  line-height: 1.6;
}

#activeNoteText {
  width: 100%; 
  height: 250px;
  background: var(--bg-color); 
  color: var(--text-primary);
  font-family: 'Inter', sans-serif; 
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none; 
  outline: none;
  border: 1px solid var(--border-color); 
  border-radius: 8px; 
  padding: 16px;
  transition: border-color 0.2s ease, background-color 0.3s ease;
}

#activeNoteText:focus {
  border-color: var(--accent-color);
}

/* ==========================================================================
   8. UTILITÁRIOS
   ========================================================================== */
.hidden {
  display: none !important;
}

/* --- TOOLTIP / TOAST NOTIFICATION --- */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg-color);
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 500;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 1000;
}
.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Tabelas Modernas */
.table-container {
  overflow-x: auto;
  margin: 2em 0;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-color);
}

th {
  background: var(--accent-color);
  color: white;
  padding: 12px;
  text-align: left;
  font-family: 'Inter', sans-serif;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 1rem;
}

tr:last-child td { border-bottom: none; }
tr:nth-child(even) { background: rgba(0,0,0,0.02); }

/* Vocabulário em Grid */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin: 2em 0;
}

.vocab-card {
  background: var(--surface-color);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
  transition: transform 0.2s;
}

.vocab-card:hover { transform: translateY(-3px); border-color: var(--accent-color); }
.vocab-sep { color: var(--text-light); font-size: 0.8rem; margin: 5px 0; }
.meaning { font-weight: 600; font-size: 0.95rem; }

.vocabulary-section {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  padding: 25px;
  border-radius: 16px;
  margin: 2em 0;
}

/* ==========================================================================
   CORREÇÃO DO CUSTOM TOAST (ITEM 9) — OCULTO POR PADRÃO E ANIMADO NO .show
   ========================================================================== */
#customToast,
.custom-toast {
    position: fixed !important;
    bottom: 24px !important;
    left: 50% !important;
    transform: translate(-50%, 140%) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    background: #0f172a !important;
    color: #f8fafc !important;
    padding: 12px 22px !important;
    border-radius: 30px !important;
    border: 1px solid #14b8a6 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    font-size: 0.92rem !important;
    font-weight: 600 !important;
    z-index: 10050 !important;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease, visibility 0.35s !important;
    max-width: calc(100vw - 32px) !important;
}

#customToast.show,
.custom-toast.show {
    transform: translate(-50%, 0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

#customToast #toastIcon {
    color: #14b8a6;
    font-size: 1.25rem;
}
/* ==========================================================================
   CONTAINERS DE IFRAME E EXERCÍCIOS INTERATIVOS NO READER
   ========================================================================== */
.iframe-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 78vh;
    min-height: 580px;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    margin: 2.5em 0;
    background: var(--surface-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.iframe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(13, 148, 136, 0.08);
    border-bottom: 1px solid var(--border-color);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-open-external {
    font-size: 0.8rem;
    color: #0d9488;
    text-decoration: none;
    font-weight: 700;
}

.iframe-container iframe.lab-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
}

.exercises-grammar-box {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 22px;
    margin: 2.5em 0;
    font-family: 'Inter', sans-serif;
}

.exercises-header h3 {
    margin-top: 0 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #0d9488;
}

.exercises-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem !important;
}

.exercise-item {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.exercise-item:hover {
    border-color: #0d9488;
}

.exercise-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ex-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(13, 148, 136, 0.12);
    color: #0d9488;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ex-verse {
    flex: 1;
}

.ex-toggle-btn {
    font-size: 0.78rem;
    font-weight: 700;
    color: #0d9488;
    white-space: nowrap;
}

.exercise-answer {
    display: none;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
    font-size: 0.95rem;
    color: var(--text-primary);
}

.exercise-item.open .exercise-answer {
    display: block;
}

.vocab-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 1rem;
    font-family: 'Inter', sans-serif;
}

.vocab-header-row h3 {
    margin-top: 0 !important;
    display: flex;
    align-items: center;
    gap: 6px;
}
/* ==========================================================================
   RODAPÉ DE AULA MODERNO (ITEM 4) & BOTÃO DE VOCABULÁRIO INLINE (ITEM 5)
   ========================================================================== */
.lesson-footer-modern {
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 2px dashed var(--border-color, #e2e8f0);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.btn-complete-modern {
    width: 100%;
    padding: 16px 24px;
    border-radius: 14px;
    border: 2px solid #0d9488;
    background: var(--bg-secondary, #ffffff);
    color: #0d9488;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.1);
}

.btn-complete-modern:hover {
    background: rgba(13, 148, 136, 0.08);
    transform: translateY(-2px);
}

.btn-complete-modern.completed {
    background: linear-gradient(135deg, #0d9488, #0f766e);
    border-color: #0d9488;
    color: #ffffff;
    box-shadow: 0 8px 25px rgba(13, 148, 136, 0.28);
}

.lesson-nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.btn-lesson-step {
    padding: 12px 18px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #cbd5e1);
    background: var(--bg-secondary, #ffffff);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    transition: all 0.2s;
}

.btn-lesson-step.primary-step {
    background: rgba(13, 148, 136, 0.12);
    color: #0d9488;
    border-color: #0d9488;
}

.btn-save-vocab-inline {
    padding: 12px 18px;
    border-radius: 10px;
    border: none;
    background: #0d9488;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-save-vocab-inline.saved {
    background: #10b981;
}

.vocab-quick-links {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.btn-quick-link {
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(13, 148, 136, 0.12);
    color: #0d9488;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
}

/* ==========================================================================
   CORREÇÃO DE ESCALA E TAMANHO DE FONTE NO MOBILE (ITEM 10)
   Impede que tabelas largas encolham a tela e garante leitura confortável!
   ========================================================================== */
html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    -webkit-text-size-adjust: 100% !important;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.2rem 0;
}

@media (max-width: 768px) {
    #moduleTitle {
        font-size: 1.75rem !important;
        line-height: 1.25 !important;
    }
    #moduleContent p,
    #moduleContent li,
    .lesson-paragraph {
        font-size: 1.12rem !important;
        line-height: 1.75 !important;
    }
    #moduleContent .grk {
        font-size: 1.22rem !important;
    }
    .skill-nodes-grid {
        grid-template-columns: 1fr !important;
    }
    .skill-node {
        padding: 1.35rem !important;
    }
    .skill-title {
        font-size: 1.45rem !important;
    }
    .skill-desc {
        font-size: 0.98rem !important;
    }
    .vocab-cards-grid {
        grid-template-columns: 1fr !important;
    }
    .lesson-nav-buttons {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
}