/**
 * PAITHON BOOK - ADVANCED FEATURES STYLES
 * Dark Mode, Font Size, Bookmarks, Notes, Search, Highlights, Progress
 */

/* ===== COMMON BUTTON STYLES ===== */
.dark-mode-toggle,
.font-size-trigger,
.bookmarks-toggle,
.notes-toggle,
.search-trigger,
.highlights-toggle,
.progress-toggle {
  position: fixed;
  right: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-color, #BD5FFF);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(189, 95, 255, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.dark-mode-toggle:hover,
.font-size-trigger:hover,
.bookmarks-toggle:hover,
.notes-toggle:hover,
.search-trigger:hover,
.highlights-toggle:hover,
.progress-toggle:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 24px rgba(189, 95, 255, 0.6);
  border-color: rgba(255, 255, 255, 0.6);
}

.dark-mode-toggle:active,
.font-size-trigger:active,
.bookmarks-toggle:active,
.notes-toggle:active,
.search-trigger:active,
.highlights-toggle:active,
.progress-toggle:active {
  transform: translateY(-1px) scale(0.98);
  box-shadow: 0 2px 8px rgba(189, 95, 255, 0.4);
}

/* Position each button differently - offset from existing scroll button */
.dark-mode-toggle { bottom: 100px; }
.font-size-trigger { bottom: 165px; }
.search-trigger { bottom: 230px; }
.bookmarks-toggle { bottom: 295px; }
.notes-toggle { bottom: 360px; }
.highlights-toggle { bottom: 425px; }
.progress-toggle { bottom: 490px; }

/* Counter badges */
.bookmarks-count,
.highlights-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ===== 1. DARK MODE ===== */
.dark-mode {
  --text-color: #e4e6eb;
  --text-light: #b0b3b8;
  --bg-main: #18191a;
  --bg-secondary: #242526;
  --bg-code: #2d2d2d;
  --border-color: #3e4042;
}

.dark-mode body {
  background: var(--bg-main);
  color: var(--text-color);
}

.dark-mode .bd-sidebar,
.dark-mode .navbar {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

.dark-mode pre,
.dark-mode code {
  background: var(--bg-code);
  border-color: var(--border-color);
}

.dark-mode .admonition {
  background: var(--bg-secondary);
}

/* ===== 2. FONT SIZE SELECTOR ===== */
.font-size-selector {
  position: fixed;
  right: 30px;
  bottom: 95px;
  z-index: 999;
}

.font-size-options {
  position: absolute;
  bottom: 60px;
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 1rem;
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

.font-size-options.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.font-size-label {
  font-weight: 700;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-color);
}

.font-size-option {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  margin: 0.25rem 0;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  text-align: left;
}

.font-size-option:hover {
  background: var(--primary-light);
  color: white;
  transform: translateX(4px);
}

.font-size-option.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-dark);
  font-weight: 700;
}

/* ===== 3. BOOKMARKS ===== */
.bookmarks-panel {
  position: fixed;
  right: 30px;
  bottom: 225px;
  z-index: 999;
}

.bookmarks-dropdown {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 350px;
  max-height: 500px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  overflow: hidden;
}

.bookmarks-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.bookmarks-header,
.highlights-header,
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-secondary);
}

.bookmarks-header h3,
.highlights-header h3,
.progress-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-color);
}

.bookmarks-clear,
.highlights-clear,
.progress-reset {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: transform 0.2s ease;
}

.bookmarks-clear:hover,
.highlights-clear:hover,
.progress-reset:hover {
  transform: scale(1.2);
}

.bookmarks-list,
.highlights-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem;
}

.bookmark-item,
.highlight-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin: 0.25rem 0;
  background: var(--bg-secondary);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.bookmark-item:hover,
.highlight-item:hover {
  background: var(--primary-light);
  transform: translateX(4px);
}

.bookmark-link {
  flex: 1;
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-remove,
.highlight-remove {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: #ff4444;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.bookmark-remove:hover,
.highlight-remove:hover {
  background: #ff4444;
  color: white;
}

.bookmarks-empty,
.highlights-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
  font-style: italic;
}

.page-bookmark-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  padding: 0.25rem;
}

.page-bookmark-btn:hover {
  transform: scale(1.2);
}

/* ===== 4. NOTES SIDEBAR ===== */
.notes-panel {
  position: fixed;
  right: 30px;
  bottom: 290px;
  z-index: 999;
}

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

.notes-sidebar.show {
  right: 0;
}

.notes-header {
  padding: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notes-header h3 {
  margin: 0;
  font-size: 1.3rem;
}

.notes-close {
  background: transparent;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.notes-close:hover {
  background: #ff4444;
  color: white;
}

.notes-textarea {
  flex: 1;
  padding: 1.5rem;
  border: none;
  resize: none;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  outline: none;
}

.notes-info {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  font-size: 0.85rem;
  color: var(--text-light);
  text-align: center;
  border-top: 1px solid var(--border-color);
}

/* ===== 5. SEARCH MODAL ===== */
.advanced-search {
  position: fixed;
  right: 30px;
  bottom: 160px;
  z-index: 999;
}

.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 10000;
}

.search-modal.show {
  opacity: 1;
  visibility: visible;
}

.search-box {
  width: 90%;
  max-width: 600px;
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.5rem;
  padding: 0.5rem;
  font-family: var(--font-body);
}

.search-close {
  background: transparent;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-light);
  transition: color 0.2s ease;
}

.search-close:hover {
  color: #ff4444;
}

.search-results {
  width: 90%;
  max-width: 600px;
  max-height: 60vh;
  background: white;
  border-radius: 12px;
  margin-top: 1rem;
  padding: 1rem;
  overflow-y: auto;
}

.search-count {
  font-weight: 700;
  padding: 0.5rem 1rem;
  color: var(--primary-color);
  font-size: 0.9rem;
}

.search-result {
  padding: 1rem;
  margin: 0.5rem 0;
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.6;
}

.search-result:hover {
  background: var(--primary-light);
  color: white;
  transform: translateX(4px);
}

.search-result mark {
  background: yellow;
  color: black;
  font-weight: 700;
  padding: 0 0.25rem;
  border-radius: 3px;
}

.search-hint,
.search-no-results {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
  font-style: italic;
}

.highlight-flash {
  animation: highlightFlash 2s ease;
}

@keyframes highlightFlash {
  0%, 100% { background: transparent; }
  50% { background: rgba(255, 255, 0, 0.5); }
}

/* ===== 6. HIGHLIGHTER ===== */
.highlighter-panel {
  position: fixed;
  right: 30px;
  bottom: 355px;
  z-index: 999;
}

.highlights-dropdown {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 350px;
  max-height: 500px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  overflow: hidden;
}

.highlights-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.highlight-menu {
  position: absolute;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 0.5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10000;
}

.highlight-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.highlight-btn:hover {
  transform: scale(1.2);
}

.highlight-color {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}

.highlight-text {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Highlight colors */
mark.highlight-yellow,
.highlight-color.highlight-yellow {
  background-color: #ffeb3b;
}

mark.highlight-green,
.highlight-color.highlight-green {
  background-color: #4caf50;
}

mark.highlight-blue,
.highlight-color.highlight-blue {
  background-color: #2196f3;
}

mark.highlight-pink,
.highlight-color.highlight-pink {
  background-color: #ff4081;
}

mark {
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

/* ===== 7. PROGRESS TRACKER ===== */
.progress-tracker {
  position: fixed;
  right: 30px;
  bottom: 420px;
  z-index: 999;
}

.progress-dropdown {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 350px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  overflow: hidden;
}

.progress-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  overflow: hidden;
  margin: 1rem 1.5rem;
  max-width: calc(100% - 3rem);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  transition: width 0.5s ease;
  border-radius: 6px;
}

.progress-stats {
  text-align: center;
  padding: 0.5rem 1.5rem;
  font-size: 0.95rem;
  color: var(--text-light);
  font-weight: 600;
}

.progress-current-page {
  padding: 1rem 1.5rem;
  border-top: 2px solid var(--border-color);
}

.mark-as-read-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mark-as-read-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(189, 95, 255, 0.4);
}

.read-indicator {
  display: inline-block;
  margin-left: 0.5rem;
  color: #4caf50;
  font-weight: 700;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
  .dark-mode-toggle,
  .font-size-trigger,
  .bookmarks-toggle,
  .notes-toggle,
  .search-trigger,
  .highlights-toggle,
  .progress-toggle {
    width: 45px;
    height: 45px;
    font-size: 18px;
    right: 20px;
  }

  .dark-mode-toggle { bottom: 90px; }
  .font-size-trigger { bottom: 145px; }
  .search-trigger { bottom: 200px; }
  .bookmarks-toggle { bottom: 255px; }
  .notes-toggle { bottom: 310px; }
  .highlights-toggle { bottom: 365px; }
  .progress-toggle { bottom: 420px; }
}

@media (max-width: 767px) {
  /* On mobile, hide some less critical buttons to avoid clutter */
  .highlights-toggle,
  .progress-toggle {
    display: none;
  }

  .dark-mode-toggle,
  .font-size-trigger,
  .bookmarks-toggle,
  .notes-toggle,
  .search-trigger {
    width: 40px;
    height: 40px;
    font-size: 16px;
    right: 15px;
  }

  .dark-mode-toggle { bottom: 80px; }
  .font-size-trigger { bottom: 130px; }
  .search-trigger { bottom: 180px; }
  .bookmarks-toggle { bottom: 230px; }
  .notes-toggle { bottom: 280px; }

  .font-size-options,
  .bookmarks-dropdown,
  .highlights-dropdown,
  .progress-dropdown {
    width: 280px;
    max-width: calc(100vw - 40px);
  }

  .notes-sidebar {
    width: 100%;
    right: -100%;
  }

  .search-box {
    width: 95%;
    padding: 1rem;
  }

  .search-input {
    font-size: 1.2rem;
  }

  .search-results {
    width: 95%;
  }
}

/* ===== DARK MODE ADJUSTMENTS ===== */
.dark-mode .font-size-options,
.dark-mode .bookmarks-dropdown,
.dark-mode .highlights-dropdown,
.dark-mode .progress-dropdown,
.dark-mode .notes-sidebar,
.dark-mode .search-box,
.dark-mode .search-results {
  background: var(--bg-secondary);
  color: var(--text-color);
}

.dark-mode .search-input,
.dark-mode .notes-textarea {
  background: var(--bg-main);
  color: var(--text-color);
}

.dark-mode .font-size-option,
.dark-mode .bookmark-item,
.dark-mode .highlight-item,
.dark-mode .search-result {
  background: var(--bg-main);
}

.dark-mode .font-size-option:hover,
.dark-mode .bookmark-item:hover,
.dark-mode .highlight-item:hover,
.dark-mode .search-result:hover {
  background: var(--primary-color);
}

/* ===== PRINT STYLES ===== */
@media print {
  .dark-mode-toggle,
  .font-size-trigger,
  .font-size-selector,
  .bookmarks-panel,
  .notes-panel,
  .search-trigger,
  .highlighter-panel,
  .progress-tracker,
  .page-bookmark-btn,
  .scroll-to-top,
  .reading-progress {
    display: none !important;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .font-size-options,
  .bookmarks-dropdown,
  .highlights-dropdown,
  .progress-dropdown,
  .notes-sidebar,
  .search-modal {
    transition: none;
  }
}
