/* ============================================
   Study Enhancements — Dark Mode Overrides
   ============================================ */

:root[data-theme="dark"] .header-glass {
  background: rgba(15, 23, 42, 0.92);
  border-bottom-color: rgba(255,255,255,0.06);
}

:root[data-theme="dark"] .card {
  background: var(--card-bg);
  border-color: var(--border);
}

:root[data-theme="dark"] .study-content blockquote {
  background: var(--teal-tint);
  color: var(--text-muted);
  border-left-color: var(--primary);
}

:root[data-theme="dark"] .study-content h2 {
  border-bottom-color: rgba(255,255,255,0.08);
}

:root[data-theme="dark"] .study-content th {
  background: var(--teal-tint);
}

:root[data-theme="dark"] .study-content td,
:root[data-theme="dark"] .study-content th {
  border-color: rgba(255,255,255,0.08);
}

:root[data-theme="dark"] .study-content img {
  border-color: rgba(255,255,255,0.1);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: var(--card-bg);
  color: var(--text-main);
  border-color: var(--border);
}

:root[data-theme="dark"] #user-dropdown {
  background: var(--card-bg);
  border-color: var(--border);
}

:root[data-theme="dark"] .sidebar-drawer {
  background: var(--card-bg);
}

:root[data-theme="dark"] .bottom-nav {
  background: rgba(15, 23, 42, 0.95);
  border-top-color: var(--border);
}

:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #475569;
}

/* Dark mode toggle button */
.dark-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: background 0.15s;
}
.dark-mode-toggle:hover {
  background: rgba(255,255,255,0.2);
}
.dark-mode-toggle svg { width: 18px; height: 18px; }

/* ============================================
   Study Enhancer — F2: Pontos-Chave Card
   ============================================ */

.pontos-chave-card {
  background: linear-gradient(135deg, var(--teal-tint) 0%, rgba(58,153,176,0.08) 100%);
  border: 1px solid rgba(58,153,176,0.2);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.pontos-chave-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
}

.pontos-chave-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}

.pontos-chave-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pontos-chave-card li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(58,153,176,0.12);
}

.pontos-chave-card li:last-child {
  border-bottom: none;
}

/* ============================================
   Study Enhancer — F2: Pearls Card
   ============================================ */

.pearls-card {
  background: linear-gradient(135deg, var(--rosa-tint) 0%, rgba(228,52,112,0.08) 100%);
  border: 1px solid rgba(228,52,112,0.2);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.pearls-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 14px;
}

.pearls-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}

.pearls-card ol {
  padding-left: 20px;
  margin: 0;
}

.pearls-card li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(228,52,112,0.12);
}

.pearls-card li:last-child {
  border-bottom: none;
}

/* ============================================
   Study Enhancer — F3: Image Captions
   ============================================ */

.study-figure {
  text-align: center;
  margin: 20px 0;
}

.study-figure img {
  max-width: 100%;
  border-radius: 8px;
}

.study-figcaption {
  font-size: 13px;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ============================================
   Study Enhancer — F6: Section Cards
   ============================================ */

.section-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  position: relative;
}

.section-card h2 {
  margin-top: 0;
}

/* ============================================
   Study Enhancer — F7: Table Overflow
   ============================================ */

.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 16px 0;
}

.table-scroll-wrapper table {
  margin: 0;
  border: none;
}

/* ============================================
   Study Enhancer — F10: Bookmarks
   ============================================ */

.bookmark-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  z-index: 2;
}

.bookmark-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--accent);
}

.bookmark-btn.active {
  color: var(--accent);
}

.bookmark-btn.active svg {
  fill: var(--accent);
}

:root[data-theme="dark"] .bookmark-btn:hover {
  background: rgba(255,255,255,0.08);
}

/* ============================================
   Study Enhancer — F10: Annotations
   ============================================ */

.annotation-wrapper {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.annotation-add-btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px dashed var(--text-muted);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.annotation-add-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.annotation-display {
  background: rgba(255, 243, 205, 0.6);
  border: 1px solid rgba(255, 213, 79, 0.4);
  border-radius: 8px;
  padding: 12px 14px;
  position: relative;
}

:root[data-theme="dark"] .annotation-display {
  background: rgba(255, 243, 205, 0.08);
  border-color: rgba(255, 213, 79, 0.2);
}

.annotation-badge {
  font-size: 11px;
  font-weight: 600;
  color: #b8860b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

:root[data-theme="dark"] .annotation-badge {
  color: #ffd54f;
}

.annotation-text {
  margin: 6px 0 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
  white-space: pre-wrap;
}

.annotation-edit-btn {
  font-size: 12px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.annotation-edit-btn:hover {
  color: var(--accent);
}

.annotation-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.annotation-textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text-main);
}

.annotation-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(58,153,176,0.15);
}

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

.annotation-save-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.annotation-save-btn:hover {
  filter: brightness(1.1);
}

.annotation-cancel-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s;
}

.annotation-cancel-btn:hover {
  color: var(--text-main);
}

.annotation-delete-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #ef4444;
  font-size: 13px;
  cursor: pointer;
  margin-left: auto;
}

.annotation-delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ============================================
   F1: TOC — Desktop Sidebar
   ============================================ */
.study-layout {
  display: flex;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
}
.study-toc-sidebar {
  width: 220px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 16px 12px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.study-main { flex: 1; min-width: 0; }
.toc-title {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}
.toc-link {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.3;
}
.toc-link:hover { background: var(--teal-tint); color: var(--primary); }
.toc-link.active {
  background: var(--teal-tint);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

@media (max-width: 1023px) {
  .study-toc-sidebar { display: none; }
}
@media (min-width: 1024px) {
  .toc-fab { display: none; }
}

/* F1: TOC — Mobile FAB + Drawer */
.toc-fab {
  position: fixed;
  bottom: 84px;
  left: 16px;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(58,153,176,0.35);
  z-index: 40;
  transition: transform 0.15s;
}
.toc-fab:active { transform: scale(0.92); }
.toc-fab svg { width: 20px; height: 20px; }

.toc-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toc-drawer-overlay.open { opacity: 1; pointer-events: auto; }

.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--card-bg);
  z-index: 81;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  padding: 20px 16px;
  overflow-y: auto;
}
.toc-drawer.open { transform: translateX(0); }
.toc-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.toc-drawer-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}
.toc-drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(0,0,0,0.04);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
:root[data-theme="dark"] .toc-drawer-close { background: rgba(255,255,255,0.06); }

/* ============================================
   F8: Reading Progress Bar
   ============================================ */
.reading-progress-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.reading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 0 2px 2px 0;
  transition: width 0.1s linear;
}

/* ============================================
   F5: Search Modal
   ============================================ */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.search-modal.open { opacity: 1; pointer-events: auto; }
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.search-modal-content {
  position: relative;
  width: 90%;
  max-width: 560px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
  border: 1px solid var(--border);
}
.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-icon { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.search-input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.9375rem;
  font-family: inherit;
  background: transparent;
  color: var(--text-main);
}
.search-kbd {
  font-size: 0.6875rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--text-muted);
  font-family: inherit;
}
.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}
.search-hint {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.search-result {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-main);
  transition: background 0.1s;
}
.search-result:hover { background: var(--teal-tint); }
.search-result-title { font-weight: 600; font-size: 0.875rem; }
.search-result-meta {
  font-size: 0.75rem;
  color: var(--primary);
  text-transform: capitalize;
  margin-top: 2px;
}
.search-result-snippet {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}
.search-result-snippet mark {
  background: rgba(58,153,176,0.2);
  color: var(--text-main);
  padding: 0 2px;
  border-radius: 2px;
}

/* ============================================
   F9: Exam Simulator
   ============================================ */
.exam-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--teal-tint);
  padding: 6px 12px;
  border-radius: 8px;
}
.exam-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  cursor: pointer;
  text-align: left;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-main);
  transition: all 0.15s;
  line-height: 1.5;
}
.exam-option:hover { border-color: var(--primary); background: var(--teal-tint); }
.exam-option.selected {
  border-color: var(--primary);
  background: var(--teal-tint);
  box-shadow: 0 0 0 2px rgba(58,153,176,0.2);
}
.exam-option-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
  color: var(--text-muted);
}
.exam-option.selected .exam-option-letter {
  background: var(--primary);
  color: white;
}
.exam-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.exam-grid-item {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
  transition: all 0.1s;
}
.exam-grid-item.answered { background: var(--teal-tint); color: var(--primary); border-color: rgba(58,153,176,0.2); }
.exam-grid-item.current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(58,153,176,0.2); }

/* FAB Simulado */
.exam-fab {
  position: fixed;
  bottom: 84px;
  right: 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(228,52,112,0.35);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 40;
  transition: transform 0.15s;
  text-decoration: none;
}
.exam-fab:active { transform: scale(0.92); }
@media (min-width: 768px) {
  .exam-fab { bottom: 24px; right: 24px; }
}
