: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;
  --muted: var(--text-light);
  --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;

  /* Compatibilidad con variables usadas más abajo */
  --bg: var(--white-color);
  --text: var(--text-color);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Century Gothic";
  background: linear-gradient(
    135deg,
    var(--white-color) 0%,
    var(--white-color) 100%
  );
  color: var(--text-color);
  min-height: 100vh;
}

.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;
  }
}

/* Estilos para el menú responsive */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--white-color);
  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);
}

@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;
  }
}

@media (max-width: 768px) {
  .main-content {
    overflow-y: auto;
    overflow-x: hidden;
  }
}

.banner-image {
  width: 100%;
  object-fit: cover;
}

.banner-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Layout general */
.library-container {
  max-width: 90%;
  margin: 40px auto;
  padding: 0 24px;
  min-height: 100vh;
}

.section {
  margin-bottom: 50px;
}

.section-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* GRID DE LIBROS */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
}

/* CARD */
.book-card {
  background: var(--white-color);
  border-radius: 18px;
  padding: 14px;
  text-align: center;

  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);
}

/* Contenedor de la imagen */

/* Imagen del libro */
.book-card img {
  width: 100%;
  max-width: 120px;
  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(170px, 1fr));
  }
}

/* ===== Cards enriquecidas (respetando tu tema claro) ===== */
.book-card.book-card--rich {
  padding: 0;
  text-align: left;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.book-card.book-card--rich:hover {
  transform: translateY(-6px);
}

.book-card--rich .book-card__media {
  position: relative;
  height: 170px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.02));
  border-bottom: 3px solid var(--cover-accent, var(--orange-color));
}

.book-card--rich img.book-cover {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  border-radius: 0;
  object-fit: contain;
  display: block;
}

.book-card--rich .book-cover-fallback {
  width: 100%;
  height: 100%;
  display: block;
}

.book-card--rich .book-card__body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.book-card--rich .book-card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-dark);
}

.book-card--rich .book-card__author {
  margin: 0;
  font-size: 12px;
  color: var(--text-light);
}

.book-card--rich .book-card__desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-color);
  opacity: 0.9;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card--rich .book-card__meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.book-card--rich .meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border-color);
  background: var(--light-bg);
  color: var(--text-dark);
  white-space: nowrap;
}

.book-card--rich .meta-chip i {
  opacity: 0.85;
  color: var(--orange-color);
}

.book-card--rich .meta-chip.chip-warn {
  border-color: rgba(251, 142, 46, 0.45);
  background: rgba(251, 142, 46, 0.12);
}

.book-card--rich .meta-chip.chip-info {
  border-color: rgba(67, 97, 238, 0.35);
  background: rgba(67, 97, 238, 0.1);
}

@media (max-width: 520px) {
  .book-card--rich .book-card__media {
    height: 150px;
  }
}

/* ...existing code... */

/* ===== Promo discreta ===== */
.promo-area {
  max-width: 90%;
  margin: 18px auto 0;
  padding: 0 24px;
}

.promo-banner {
  background: var(--white-color);
  border: 1px solid var(--border-color);
  border-left: 6px solid var(--orange-color);
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.promo-left {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-width: 260px;
}

.promo-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(251, 142, 46, 0.12);
  border: 1px solid rgba(251, 142, 46, 0.35);
  color: var(--orange-color);
  flex: 0 0 auto;
}

.promo-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-dark);
}

.promo-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.35;
}

.promo-kpis {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.promo-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--light-bg);
  font-size: 12px;
  color: var(--text-dark);
  font-weight: 700;
}

.promo-pill i {
  color: var(--orange-color);
}

.promo-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-promo {
  border: 1px solid rgba(251, 142, 46, 0.45);
  background: rgba(251, 142, 46, 0.12);
  color: var(--text-dark);
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 800;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-promo:hover {
  transform: translateY(-1px);
  background: rgba(251, 142, 46, 0.16);
}

.btn-promo--ghost {
  border-color: var(--border-color);
  background: #fff;
}

.btn-promo--ghost:hover {
  background: var(--light-bg);
}

/* Highlight para libros por expirar */
.book-card--rich.is-expiring {
  border-color: rgba(251, 142, 46, 0.55) !important;
  box-shadow: 0 14px 26px rgba(251, 142, 46, 0.12);
}

@media (max-width: 768px) {
  .promo-area {
    padding: 0 16px;
  }
}


.promo-banner{
  position: relative;
}

.promo-close{
  position: absolute;
  top: -15px;
  right: -10px;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-light);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--transition);
}

.promo-close:hover{
  background: var(--light-bg);
  color: var(--text-dark);
  transform: translateY(-1px);
}

.promo-banner.is-hiding{
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease;
}

/* ...existing code... */