:root {
  --primary-color: #4361ee;
  --secondary-color: #3a0ca3;
  --accent-color: #7209b7;
  --success-color: #28a745;
  --light-bg: #f8f9fa;
  --dark-bg: #212529;
  --text-color: #333;
  --text-light: #6c757d;
  --border-color: #dee2e6;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
  --white-color: #ffffff;
  --orange-color: #fb8e2e;
  --orange-color-hover: #ff9f43;
  --gray-filter-btn: #a4a4a4;
  --text-dark: #1e1e1e;
  --toc-background: #f4f4f4;
  --white-color: #ffffff;
  --chapter-active: #ffe7d2;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  /* font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; */
    font-family: "Century Gothic";
  background: linear-gradient(
    135deg,
    var(--white-color) 0%,
    var(--white-color) 100%
  );
  min-height: 100vh;
  color: var(--text-color);
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--text-dark);
  box-shadow: var(--shadow);
  border-bottom: 3px solid var(--orange-color);
  position: relative;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo i {
  font-size: 2rem;
  color: var(--orange-color);
}

.logo h1 {
  font-size: 1.5rem;
  color: var(--white-color);
}

.user-stats {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--white-color);
}

.stat i {
  color: var(--orange-color);
}

.logout-btn {
  background: var(--orange-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logout-btn:hover {
  background: var(--orange-color-hover);
  transform: translateY(-2px);
}

.admin-btn {
  background: var(--orange-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.admin-btn:hover {
  background: var(--orange-color-hover);
  transform: translateY(-2px);
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  background: rgba(255, 255, 255, 0.08);
  color: var(--white-color);
  border: 1px solid rgba(251, 142, 46, 0.65); /* naranja suave */
  border-radius: 10px;

  padding: 0.5rem 2.2rem 0.5rem 0.9rem; /* espacio a la derecha para la flecha */
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;

  cursor: pointer;
  transition: var(--transition);

  /* Para que los emojis de banderas se vean bien *

  /* Flecha custom (SVG inline) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath fill='%23fb8e2e' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 18px 18px;
}

.lang-select:hover {
  border-color: var(--orange-color);
  background-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.lang-select:focus {
  outline: none;
  border-color: var(--orange-color);
  box-shadow: 0 0 0 3px rgba(251, 142, 46, 0.25);
}

.lang-select:active {
  transform: translateY(0);
}

/* Nota: el estilo de <option> es limitado por el navegador/SO */
.lang-select option {
  color: #111;
  background: #fff;
  font-weight: 700;
}

/* En el menú responsive, que no se vea apretado */
@media (max-width: 1024px) {
  .lang-select {
    width: 100%;
    max-width: 220px;
  }
}

/* Contenido Principal */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

@media (max-width: 768px) {
  .main-content {
    overflow-y: auto;
    overflow-x: hidden;
  }
}

/* Panel de Biblioteca */
.library-panel {
  width: 300px;
  background: var(--toc-background);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 1.5rem;
  background: var(--toc-background);
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-buttons {
  display: flex;
  gap: 0.5rem;
}

.filter-btn {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: var(--gray-filter-btn);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  color: var(--light-bg);
}

.filter-btn:hover {
  border-color: var(--text-light);
}

.filter-btn.active {
  background: var(--orange-color);
  color: white;
  border-color: var(--orange-color-hover);
}

.library-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.book-item {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  box-shadow: var(--shadow);
}

.book-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.book-item.active {
  border-color: var(--orange-color);
  background: linear-gradient(135deg, #ffffff 0%, #fbf9f4 100%);
}

.book-item.escuchado {
  opacity: 0.8;
  position: relative;
}

.book-item.escuchado::after {
  content: "✓";
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--success-color);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.book-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.book-cover {
  width: 50px;
  height: 70px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--accent-color)
  );
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  overflow: hidden;
  position: relative;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.book-info {
  flex: 1;
}

.book-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--dark-bg);
}

.book-author {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.book-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-light);
}

.book-progress-bar {
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.book-progress-fill {
  height: 100%;
  background: var(--orange-color);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

/* Panel del Reproductor */
.player-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
}

.player-header {
  margin-bottom: 2rem;
}

.player-header h2 {
  font-size: 1.8rem;
  color: var(--text-dark);
  margin-bottom: 1rem;
}

.book-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: visible;
  position: relative;
}

.progress-fill {
  height: 100%;

  background: linear-gradient(90deg, #fb8e2e, #ffb36b);
  border-radius: 999px;
  position: relative;
  transition: width 0.3s ease;
}

.progress-icon {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
  background: white;
  color: #fb8e2e;

  width: 22px;
  height: 22px;
  font-size: 12px;

  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

#book-progress-text {
  font-weight: 600;
  color: var(--text-color);
  min-width: 100px;
}

/* Contenedor del Reproductor */
.player-container {
  display: flex;
  gap: 2rem;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1024px) {
  .player-container {
    flex-direction: column;
  }
}

.audio-player-section {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.book-cover-img {
  width: 250px;
  height: 360px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  overflow: hidden;
  position: relative;
  box-shadow: rgba(14, 30, 37, 0.12) 0px 2px 4px 0px,
    rgba(14, 30, 37, 0.32) 0px 2px 16px 0px;
}

.book-cover-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.section-buttons {
  margin-top: 10px;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

#current-book-description {
  text-align: justify;
}

.player-wrapper {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.custom-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.control-btn {
  padding: 0.75rem 1.5rem;
  background: var(--orange-color);
  border: 1.5px solid var(--orange-color);
  color: var(--white-color);
  /* border-radius: 8px; */
  /* border-radius: 10px; */
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-btn:hover {
  background: var(--orange-color-hover);
  color: white;
  transform: translateY(-2px);
}

.control-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  display: none;
}

/* Tabla de Contenido */
.toc-section {
  flex: 1;
  background: var(--toc-background);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--light-bg);
}

.toc-header h3 {
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chapter-count {
  background: var(--text-dark);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  color: var(--orange-color);
}

.toc-list {
  flex: 1;
  overflow-y: auto;
}

.chapter-item {
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: var(--white-color);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 4px solid transparent;
}

.chapter-item:hover {
  background: #fbf9f4; /*ver este */

  transform: translateX(5px);
}

.chapter-item.active {
  background: var(--chapter-active);
  border-bottom-color: var(--orange-color);
  font-weight: 600;
}

.chapter-item.escuchado {
  opacity: 0.7;
  position: relative;
}

.chapter-item.escuchado::before {
  content: "✓";
  position: absolute;
  right: 1rem;
  color: var(--success-color);
  font-weight: bold;
}

.chapter-number {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.chapter-title {
  color: var(--text-dark);
}

.chapter-duration {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.empty-toc {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.empty-toc i {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--border-color);
}

/* PDF Viewer */
.pdf-viewer-section {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.5rem;
}

.close-btn:hover {
  color: var(--primary-color);
}

.pdf-container {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #f9f9f9;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem;
}

#pdf-canvas {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.pdf-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  padding: 1.5rem;
  background: var(--light-bg);
  border-radius: 8px;
  margin-top: 1.5rem;
}

.pdf-btn {
  padding: 0.75rem 1.5rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pdf-btn:hover {
  background: var(--secondary-color);
  transform: translateY(-2px);
}

#page-info {
  font-weight: 600;
  color: var(--secondary-color);
  min-width: 150px;
  text-align: center;
}

/* Footer */
.app-footer {
  padding: 1rem 2rem;
  background: white;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-info {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-info p {
  color: var(--text-light);
  font-weight: 600;
}

.progress-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--dark-color);
  font-weight: 600;
}

@media (max-width: 768px) {
  .app-footer {
    flex-direction: column;
    padding: 0.75rem 1rem;
    text-align: center;
  }

  .footer-info {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .footer-info p {
    font-size: 0.85rem;
  }

  .progress-indicator {
    font-size: 0.8rem;
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .library-panel {
    width: 250px;
  }

  .player-panel {
    padding: 1.5rem;
  }

  .audio-player-section {
    gap: 1rem;
  }

  .book-cover-img {
    width: 200px;
    height: 350px;
    margin: 0 auto;
  }

  .control-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  .library-panel {
    width: 100%;
    height: 300px;
  }

  .player-panel {
    padding: 1rem;
    height: auto;
    min-height: calc(100vh - 300px - 120px);
  }

  .player-container {
    flex-direction: column;
    gap: 1rem;
  }

  .book-cover-img {
    width: 100%;
    max-width: 300px;
    height: 400px;
    margin: 0 auto;
  }

  .audio-player-section {
    width: 100%;
  }

  .player-wrapper {
    padding: 1rem;
  }

  .custom-controls {
    gap: 0.5rem;
    padding: 0.5rem 0;
  }

  .control-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    flex: 1 1 auto;
    min-width: calc(50% - 0.25rem);
    justify-content: center;
  }

  .control-btn i {
    margin-right: 0.3rem;
  }

  .toc-section {
    min-height: 300px;
  }

  .player-header h2 {
    font-size: 1.4rem;
  }

  .book-progress {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Estilos para el menú responsive */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #333;
  cursor: pointer;
  padding: 0.5rem;
}

.header-menu {
  display: flex;
  transition: all 0.3s ease;
}


/* ===== Dropdown usuario (Header) ===== */
.user-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.user-dropdown-toggle {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white-color);
  border: 1px solid rgba(251, 142, 46, 0.65);
  border-radius: 12px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
}

.user-dropdown-toggle:hover {
  border-color: var(--orange-color);
  background-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.user-dropdown-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(251, 142, 46, 0.25);
}

.user-dropdown-toggle .dropdown-caret {
  font-size: 0.9rem;
  color: var(--orange-color);
}

.user-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  background: var(--text-dark);
  border: 1px solid rgba(251, 142, 46, 0.35);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  z-index: 2000;
  flex-direction: column;
}

.user-dropdown.open .user-dropdown-menu {
  display: flex;
}

.user-dropdown-item {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--white-color);
  text-decoration: none;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-weight: 700;
  transition: var(--transition);
}

.user-dropdown-item i {
  color: var(--orange-color);
  width: 18px;
  text-align: center;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* En responsive (menú desplegable del header), mejor que el dropdown sea tipo “acordeón” */
@media (max-width: 1024px) {
  .user-dropdown {
    width: 100%;
  }

  .user-dropdown-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .user-dropdown-menu {
    position: static;
    width: 100%;
    margin-top: 0.75rem;
    box-shadow: none;
  }
}

/* Media queries para tablets y móviles */
@media (max-width: 1024px) {
  /* Tablets */
  .menu-toggle {
    display: block;
  }

  .header-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--text-dark);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    z-index: 1000;
    display: none; /* Oculto por defecto */
    border-top: 1px solid #eee;
  }

  .header-menu.active {
    display: flex; /* Mostrar cuando tenga clase active */
  }

  .user-stats {
    flex-direction: column;
    width: 100%;
    gap: 1rem;
  }

  .stat {
    width: 100%;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
  }

  .stat:last-child {
    border-bottom: none;
  }

  .logout-btn {
    margin-top: 1rem;
    align-self: flex-start;
  }
}

@media (max-width: 768px) {
  /* Móviles */
  .logo h1 {
    font-size: 1.2rem;
  }

  .header-menu {
    padding: 0.75rem;
  }

  .stat {
    font-size: 0.9rem;
  }
}

/* ============= ESTILOS DE RESEÑAS (MODAL) ============= */

/* Modal container */
.reviews-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Overlay oscuro */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  z-index: 10001;
}

/* Contenido del modal */
.modal-content {
  position: relative;
  background: white;
  border-radius: 30px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  z-index: 10002;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease;
  overflow: hidden;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header del modal */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 2px solid var(--border-color);
  background: var(--text-dark);
  border-radius: 30px 30px 0 0;
}

.modal-header h3 {
  font-size: 1.5rem;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.close-modal {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.3s ease;
}

.close-modal:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Body del modal */
.modal-body {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
  margin-right: 4px;
  padding-right: 16px;
}

/* Scrollbar personalizado */
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: var(--light-bg);
  border-radius: 10px;
  margin: 10px 4px 10px 0;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--orange-color);
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--gray-filter-btn);
}

/* Botones de acción */
.reviews-actions {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
}

.btn-primary {
  background: var(--orange-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--orange-color-hover);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--text-light);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-danger {
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-danger:hover {
  background: #c82333;
}

/* Formulario de reseña */
.review-form-container {
  background: var(--light-bg);
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.review-form h4 {
  margin-bottom: 1rem;
  color: var(--text-color);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-color);
}

.rating-input {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.rating-star {
  background: none;
  border: none;
  font-size: 2rem;
  color: #ddd;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.rating-star:hover,
.rating-star.hover {
  color: #ffc107;
  transform: scale(1.2);
}

.rating-star.active {
  color: #ffc107;
}

.rating-value {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--dark-color);
  margin-top: 0.5rem;
  display: block;
}

#review-comment {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 20px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  transition: var(--transition);
}

#review-comment:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Estadísticas de reseñas */
.review-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(
    135deg,
    var(--orange-color),
    var(--orange-color-hover)
  );
  border-radius: 12px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: white;
}

.stat-icon {
  font-size: 2.5rem;
  opacity: 0.9;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.9;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Lista de reseñas */
.reviews-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.review-item {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.review-item:hover {
  border-color: var(--orange-color-hover);
  box-shadow: var(--shadow);
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.reviewer-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.reviewer-info i {
  font-size: 2rem;
  color: var(--orange-color);
}

.reviewer-name {
  font-weight: 600;
  color: var(--text-color);
  font-size: 1.1rem;
}

.review-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.review-rating i {
  color: #ffc300;
  font-size: 1rem;
}

.review-rating i.far {
  color: #ddd;
}

.rating-number {
  font-weight: 600;
  color: var(--text-color);
  margin-left: 0.5rem;
}

.review-body {
  margin-bottom: 1rem;
}

.review-body p {
  color: var(--text-color);
  line-height: 1.6;
  white-space: pre-wrap;
}

.review-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--gray-filter-btn);
  font-size: 0.9rem;
}

.review-date {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.edited-label {
  font-style: italic;
  color: var(--text-light);
  margin-left: 0.5rem;
}

/* Estados vacíos y de carga */
.loading-reviews,
.empty-reviews,
.error-reviews {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.loading-reviews i,
.empty-reviews i,
.error-reviews i {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.empty-reviews {
  color: var(--text-light);
}

.error-reviews {
  color: #dc3545;
}

.load-more-container {
  text-align: center;
  margin-top: 2rem;
}

/* Responsive para modal de reseñas */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 90vh;
    margin: 1rem;
  }

  .modal-header {
    padding: 1rem 1.5rem;
  }

  .modal-header h3 {
    font-size: 1.2rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .review-stats {
    grid-template-columns: 1fr;
  }

  .review-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions button {
    width: 100%;
  }

  .rating-star {
    font-size: 1.5rem;
  }
}

/* ========================================
   MODAL DE NOTAS
   ======================================== */

.notes-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notes-modal-content {
  position: relative;
  background: white;
  border-radius: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 1000px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease-out;
  z-index: 10001;
  overflow: hidden; /* Añade esto para contener el scroll dentro del border-radius */
}

.notes-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 30px;
  background: var(--text-dark);
  color: white;
  border-radius: 30px 30px 0 0;
}

.notes-modal .modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notes-stats {
  display: flex;
  align-items: center;
  gap: 15px;
}

.notes-count-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes-modal-body {
  padding: 25px 30px;
  overflow-y: auto;
  flex: 1;
  margin-right: 4px;
  padding-right: 16px;
}

/* Scrollbar personalizado para modal de notas */
.notes-modal-body::-webkit-scrollbar {
  width: 8px;
}

.notes-modal-body::-webkit-scrollbar-track {
  background: var(--light-bg);
  border-radius: 10px;
  margin: 10px 4px 10px 0;
}

.notes-modal-body::-webkit-scrollbar-thumb {
  background: var(--orange-color);
  border-radius: 10px;
}

.notes-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--gray-filter-btn);
}

/* Acciones de notas */
.notes-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
  gap: 15px;
}

.notes-filters {
  display: flex;
  gap: 15px;
  flex: 1;
  justify-content: flex-end;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 100%;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

.search-box input {
  width: 100%;
  padding: 10px 15px 10px 40px;
  border: 2px solid #e0e0e0;
  border-radius: 50px;
  font-size: 0.95rem;
  transition: all 0.3s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--orange-color);
}

.chapter-filter {
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 50px;
  font-size: 0.95rem;
  background: white;
  cursor: pointer;
  transition: all 0.3s;
}

.chapter-filter:focus {
  outline: none;
  border-color: var(--orange-color);
}

/* Formulario de nota */
.note-form-container {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 25px;
}

.note-form h4 {
  margin: 0 0 20px 0;
  color: #333;
  font-size: 1.2rem;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-weight: 500;
  font-size: 0.95rem;
}

.required {
  color: #e74c3c;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.3s;
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--orange-color);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

/* Lista de notas */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.empty-notes,
.loading-notes,
.error-message {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-notes i,
.loading-notes i {
  font-size: 4rem;
  margin-bottom: 20px;
  opacity: 0.3;
}

.empty-subtitle {
  font-size: 0.9rem;
  margin-top: 10px;
}

/* Item de nota */
.note-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 20px;
  transition: all 0.3s;
  box-shadow: var(--shadow);
}

.note-item:hover {
  border-color: var(--orange-color-hover);
  box-shadow: var(--shadow);
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.note-chapter-info {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chapter-badge {
  background: linear-gradient(
    135deg,
    var(--text-dark) 0%,
    var(--text-dark) 100%
  );
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.timestamp-badge {
  background: #f0f0f0;
  color: #555;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s;
}

.timestamp-badge:hover {
  background: var(--orange-color-hover);
  color: white;
}

.note-actions {
  display: flex;
  gap: 8px;
}

.note-action-btn {
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.3s;
  font-size: 1rem;
}

.note-action-btn:hover {
  background: #f0f0f0;
  color: #333;
}

.note-action-btn.delete-note:hover {
  background: #fee;
  color: #e74c3c;
}

.note-title-display h4 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 1.1rem;
}

.note-content {
  margin-bottom: 15px;
  margin: 10px 0 15px 20px;
}

.note-content p {
  margin: 0;
  color: #555;
  line-height: 1.6;
}

.note-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
}

.note-date {
  font-size: 0.85rem;
  color: #999;
  display: flex;
  align-items: center;
  gap: 6px;
}

.edited-badge {
  font-style: italic;
  color: #667eea;
  margin-left: 5px;
}

/* Badge de notas en botón */
.control-btn .notes-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #e74c3c;
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
}

.control-btn.has-notes {
  position: relative;
}

/* Responsive */
@media (max-width: 768px) {
  .notes-modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .notes-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .notes-filters {
    flex-direction: column;
  }

  .search-box {
    max-width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .note-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .note-actions {
    align-self: flex-end;
  }
}

/* Información automática en el formulario de notas */
.auto-info-section {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
  padding: 15px;
  background: var(--light-bg);
  border-radius: 10px;
  border: 2px dashed var(--text-light);
}

.info-badge {
  flex: 1;
  background: white;
  padding: 12px 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.info-badge span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #555;
  font-weight: 500;
  font-size: 0.95rem;
}

.info-badge i {
  color: var(--dark-color);
  font-size: 1.1rem;
}

.chapter-info {
  border-left: 4px solid var(--orange-color);
}

.time-info {
  border-left: 4px solid var(--orange-color-hover);
}

.form-help {
  display: block;
  margin-top: 8px;
  color: #999;
  font-size: 0.85rem;
  font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
  .auto-info-section {
    flex-direction: column;
  }
}

/* Estilos para el contenido HTML de las reseñas */
.review-comment-content {
  line-height: 1.6;
  color: var(--text-color);
}

.review-comment-content p {
  margin-bottom: 0.5rem;
}

.review-comment-content ul,
.review-comment-content ol {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.review-comment-content strong {
  font-weight: 600;
  color: var(--dark-bg);
}

.review-comment-content em {
  font-style: italic;
  color: var(--text-light);
}

.review-comment-content a {
  color: var(--primary-color);
  text-decoration: underline;
}

.review-comment-content a:hover {
  color: var(--accent-color);
}

/* ========================================
   HOME - SECCIONES DE LIBROS
   ======================================== */

.library-container {
  max-width: 1300px;
  margin: 40px auto;
  padding: 0 24px;
}

.section {
  margin-bottom: 50px;
}

.section-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* GRID DE LIBROS */
.books-grid {
  display: flex;
  gap: 22px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 15px;
  scroll-behavior: smooth;
}

/* Estilo del scrollbar */
.books-grid::-webkit-scrollbar {
  height: 8px;
}

.books-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.books-grid::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

.books-grid::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* CARD */
.book-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  min-width: 150px;
  max-width: 150px;
  flex-shrink: 0;

  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);

  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
}

.book-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.15);
}

/* Imagen del libro */
.book-card img {
  width: 100%;
  max-width: 130px;
  margin: 0 auto 12px;
  display: block;
  border-radius: 10px;
}

/* Título */
.book-card h3 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 6px;
}

/* Autor */
.book-card p {
  font-size: 12px;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 768px) {
  .section-title {
    font-size: 20px;
  }

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
