/* ── Variables propias de la Biblioteca ─────────────── */
:root {
  --lib-primary: #023047;
  --lib-secondary: #0abce9;
  --lib-tertiary: #84d8ff;
  --lib-accent: #ffb703;
  --lib-accent-dark: #fb8500;
  --lib-border: rgba(10, 188, 233, 0.18);
  --lib-mono: 'DM Mono', monospace;
  --lib-pdf: #f87171;
  --lib-zip: var(--lib-accent);
  --lib-transition: 180ms ease;
  --lib-shadow: 0 5px 15px rgba(0, 0, 0, .5);
  --lib-shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.6);
  --lib-radius: 10px;
}

/* ── Biblioteca layout styles ───────────────────────── */

:root {
  --card-bg-gradient: linear-gradient(135deg, var(--blue) 0%, rgba(255, 255, 255, .15) 100%);

  /* Variables reemplazadas por style.css */
}

/* ── Layout ────────────────────────────────────────── */
.page-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.body-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  align-items: start;
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 80px;
  background: rgba(16, 55, 120, 0.45);
  border: 1.5px solid rgba(26, 86, 219, 0.2);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header i {
  font-size: 1rem;
  color: var(--teal);
}

.sidebar-header span {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--teal);
}

.sidebar-list {
  list-style: none;
  padding: 8px 0;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(10, 188, 233, .2) transparent;
}

.sidebar-list::-webkit-scrollbar {
  width: 3px;
}

.sidebar-list::-webkit-scrollbar-thumb {
  background: rgba(10, 188, 233, .25);
  border-radius: 99px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  font-size: .84rem;
  color: rgba(132, 216, 255, .7);
}

.sidebar-item:hover {
  background: rgba(5, 147, 162, 0.07);
  color: var(--teal);
  border-left-color: rgba(26, 86, 219, 0.3);
}

.sidebar-item.active {
  background: rgba(255, 122, 72, 0.1);
  color: var(--orange);
  border-left-color: var(--orange);
  font-weight: 600;
}

.sidebar-item .cat-count {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(26, 86, 219, 0.12);
  color: var(--gray);
  flex-shrink: 0;
  transition: all 180ms ease;
}

.sidebar-item.active .cat-count {
  background: rgba(255, 122, 72, 0.15);
  color: var(--orange);
}

/* ── Header de página (banner interno) ─────────────── */
.lib-page-header {
  padding: 120px 0 40px;
  border-bottom: 1px solid rgba(26, 86, 219, 0.18);
  margin-bottom: 36px;
  position: relative;
  text-align: center;
}

.lib-page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 80% at 50% 0%, rgba(26, 86, 219, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.lib-page-header .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Saira', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  text-decoration: none;
  margin-bottom: 1.5rem;
  transition: color 0.25s;
}

.lib-page-header .back-link:hover {
  color: var(--orange);
}

.lib-page-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--cobalt), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lib-page-header p {
  color: var(--gray);
  font-size: .95rem;
  opacity: .85;
}

/* ── Controls bar ──────────────────────────────────── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--secondary);
  font-size: 1.1rem;
  pointer-events: none;
}

.cat-search-wrap {
  position: relative;
  margin: 12px 16px;
}

.cat-search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--secondary);
  font-size: 1rem;
  pointer-events: none;
}

#cat-search {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1.5px solid rgba(26, 86, 219, 0.2);
  border-radius: 10px;
  background: rgba(16, 55, 120, 0.35);
  backdrop-filter: blur(8px);
  font-family: 'DM Sans', sans-serif;
  font-size: .85rem;
  color: var(--white);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

#cat-search:focus {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

#search {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1.5px solid rgba(26, 86, 219, 0.2);
  border-radius: 10px;
  background: rgba(16, 55, 120, 0.3);
  backdrop-filter: blur(8px);
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  color: var(--white);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

#search:focus {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

#search::placeholder {
  color: var(--gray);
  opacity: 0.6;
}

.view-toggle {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.view-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--tertiary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 1.1rem;
}

.view-btn:hover {
  border-color: var(--cobalt);
  color: var(--teal);
}

.view-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--white);
}

/* ── Results meta ──────────────────────────────────── */
.results-meta {
  font-size: .82rem;
  color: var(--gray);
  font-family: 'DM Mono', monospace;
  margin-bottom: 20px;
}

/* ── Section title ─────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 40px 0 16px;
}

.section-title h2 {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--teal);
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(26, 86, 219, 0.2);
}

.section-title .count {
  font-size: .72rem;
  font-family: 'DM Mono', monospace;
  color: var(--orange);
  background: rgba(255, 122, 72, 0.1);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 122, 72, 0.25);
}

/* ── Grid view ─────────────────────────────────────── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 22px;
}

.book-card {
  perspective: 1600px;
  perspective-origin: 55% 45%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.book-viewer {
  position: relative;
  display: flex;
  width: 260px;
  aspect-ratio: 1 / 1.35;
  height: 350px;
  transform-style: preserve-3d;
  padding: 5px 5px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.book-viewer:hover {
  transform: scale(1.02);
}

.book-cover {
  aspect-ratio: 2/3;
  overflow: hidden;
  background: rgba(11, 11, 36, .4);
  display: flex;
  align-items: center;
  justify-content: center;
}


.book-spine {
  position: relative;
  writing-mode: vertical-rl;
  text-transform: uppercase;
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: rgb(0, 0, 0);
  text-align: center;
  width: 20px;
  height: 100%;
  background: linear-gradient(150deg, #595959 0%, #9e9e9e 30%, #595959 100%);
  transform-style: preserve-3d;
  transform: rotateY(-30deg) rotateX(0deg) translateZ(0px);
  transform-origin: right center;
  overflow: hidden;
  box-shadow:
    inset -2px 0 6px rgba(0, 0, 0, 0.7),
    inset 1px 0 2px rgba(255, 245, 200, 0.3),
    -5px 6px 14px rgba(0, 0, 0, 0.5);
}


.book-cover {
  position: relative;
  flex: 1;
  height: 100%;
  background: linear-gradient(135deg, #6ae7fba1 0%, rgba(82, 82, 82, 0.367) 100%);
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  transform-style: preserve-3d;
  transform: rotateY(20deg) rotateX(0deg) translateZ(0px);
  transform-origin: left center;
  box-shadow:
    12px 14px 28px rgba(0, 0, 0, 0.5),
    3px 0 10px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgb(0, 0, 0);
  transition: transform 0.25s ease;
}

/* Imagen de portada (se adapta perfectamente) */
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.no-cover {
  font-size: 10rem;
  color: rgba(255, 0, 0, 0.516);
}
.book-shadow {
  position: absolute;
  bottom: -20px;
  left: 5%;
  width: 92%;
  height: 28px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.2) 70%, transparent);
  filter: blur(14px);
  z-index: -1;
  border-radius: 50%;
  transform: scaleX(0.95) rotateX(6deg);
  pointer-events: none;
}

.book-footer {
  padding: 0.8rem 0rem;
}

.book-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.book-title {
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--white);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-clamp: 2;
}

.book-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding: 0rem 1rem;
}

.btn-view,
.btn-download {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  border: 1.5px solid transparent;

}

.btn-view {
  border: 1px solid var(--orange);
  background: #fb860042;
  color: #fff;
  transition: all 180ms ease;
}

.btn-download {
  border: 1px solid var(--orange);
  background: #fb860042;
  color: #fff;
  flex: 1;
  justify-content: center;
  font-weight: 600;
  transition: all 180ms ease;
}

.btn-view:hover {
  background: var(--orange);
}
.btn-download:hover {
  background: var(--orange);
}
.btn-download .size,
.btn-download .file-size,
.list-dl .file-size {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  opacity: .8;
  margin-left: 2px;
}

/* ── List view ─────────────────────────────────────── */
.books-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(16, 55, 120, 0.25);
  border: 1.5px solid rgba(26, 86, 219, 0.18);
  border-radius: 10px;
  transition: all 180ms ease;
}

.list-item:hover {
  border-color: rgba(26, 86, 219, 0.4);
  background: rgba(16, 55, 120, 0.5);
  box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
}

.list-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.list-icon.pdf {
  color: #f87171;
}

.list-icon.zip {
  color: var(--orange);
}

.list-title {
  font-size: .87rem;
  font-weight: 400;
  flex: 1;
  color: var(--white);
  text-decoration: none;
}

.list-title:hover {
  color: var(--teal);
}

.list-size {
  font-family: 'DM Mono', monospace;
  font-size: .75rem;
  color: var(--gray);
  flex-shrink: 0;
}

.list-dl {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--orange);
  color: var(--white);
  text-decoration: none;
  font-size: .78rem;
  font-weight: 600;
  transition: background 180ms ease;
  flex-shrink: 0;
}

.list-dl:hover {
  background: var(--cobalt);
}

/* ── Loading / Error / Empty states ───────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--gray);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
  color: var(--teal);
  opacity: .4;
}

.empty-state p {
  font-size: .95rem;
}

.loading-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--gray);
  font-size: .95rem;
}

.loading-state i {
  font-size: 2rem;
  display: block;
  margin-bottom: 12px;
  color: var(--teal);
  animation: spin 1.2s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-state {
  text-align: center;
  padding: 40px 24px;
  color: #f87171;
  background: rgba(248, 113, 113, .06);
  border: 1.5px solid rgba(248, 113, 113, .2);
  border-radius: var(--radius);
}

.error-state i {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 10px;
}

.error-state p {
  font-size: .9rem;
  margin-bottom: 14px;
}

.error-state button {
  padding: 7px 18px;
  border-radius: 8px;
  border: none;
  background: var(--orange);
  color: var(--white);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 180ms ease;
}

.error-state button:hover {
  background: var(--cobalt);
}

.refresh-badge {
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  color: var(--gray);
  opacity: 0.5;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Pagination ────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 48px 0 12px;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1.5px solid rgba(26, 86, 219, 0.25);
  background: rgba(16, 55, 120, 0.35);
  backdrop-filter: blur(8px);
  color: var(--teal);
  font-family: 'DM Sans', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms ease;
}

.page-btn:hover:not(:disabled) {
  background: rgba(26, 86, 219, 0.35);
  border-color: var(--cobalt);
  color: var(--white);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-btn i {
  font-size: 1.1rem;
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-num {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1.5px solid rgba(26, 86, 219, 0.2);
  background: rgba(16, 55, 120, 0.25);
  color: rgba(132, 216, 255, 0.7);
  font-family: 'DM Mono', monospace;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 180ms ease;
}

.page-num:hover {
  border-color: var(--cobalt);
  background: rgba(26, 86, 219, 0.3);
  color: var(--white);
}

.page-num.active {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--white);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(255, 122, 72, 0.35);
}

.page-ellipsis {
  width: 28px;
  text-align: center;
  color: var(--gray);
  font-size: .9rem;
  user-select: none;
}

.page-info {
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  color: var(--gray);
  opacity: 0.6;
  margin-bottom: 8px;
}

@media (max-width: 600px) {
  .pagination {
    gap: 6px;
    margin-top: 32px;
  }

  .page-btn {
    padding: 6px 10px;
    font-size: .75rem;
  }

  .page-btn span {
    display: none;
  }

  .page-num {
    width: 32px;
    height: 32px;
    font-size: .72rem;
  }
}

/* ── Hidden ────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Responsive ────────────────────────────────────── */
/* ── Sidebar Overlay (Mobile) ───────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 28, 0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.close-sidebar {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.4rem;
  cursor: pointer;
  margin-left: auto;
}

@media (max-width: 1024px) {

  .book-viewer {
    width: 100%;
    height: 280px;
  }
  .book-actions {
    padding: 1rem 0.5rem;
  }
}
/* ── Responsive ────────────────────────────────────── */
@media (max-width: 992px) {
  .controls {
    position: sticky;
    top: 60px;
    background: rgba(21, 31, 48, 0.9);
    backdrop-filter: blur(12px);
    margin: 0 -24px 24px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(26, 86, 219, 0.15);
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    z-index: 10;
  }

  .refresh-badge,
  #btn-grid,
  #btn-list {
    display: none !important;
  }

  .search-wrap {
    min-width: 0;
  }

  .body-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    z-index: 1000;
    width: 280px;
    border-radius: 0;
    border-right: 1px solid rgba(132, 216, 255, 0.2);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-header {
    padding: 20px 16px;
    background: rgba(16, 55, 120, 0.6);
  }

  .close-sidebar {
    display: flex;
  }

  #btn-sidebar {
    display: grid !important;
  }
}

@media (min-width: 993px) {
  #btn-sidebar {
    display: none !important;
  }
}

@media (max-width: 600px) {
  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (max-width: 430px) {
  .page-wrap {
    padding: 0 16px 60px;
  }

  .lib-page-header {
    padding: 100px 0 30px;
  }

  .lib-page-header h1 {
    font-size: 1.8rem;
  }

  .lib-page-header p {
    font-size: 0.85rem;
  }

  .controls {
    top: 56px;
    padding: 10px 12px;
    margin: 0 -16px 20px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }

  .search-wrap {
    min-width: 0;
    flex: 1;
  }

  .view-toggle {
    width: auto;
    justify-content: flex-end;
  }

  .view-btn {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
  }

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
  }

  .book-viewer {
    width: 100%;
    height: 250px;
  }
  .book-footer {
    padding: 0.5rem 0rem;
  }
  .book-title {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property */
  }

  .book-actions {
    padding: 0.5rem 1rem;
  }
  .book-shadow {
    bottom: -5px;
    height: 15px;
  }
  .btn-download {
    width: 100%;
  }
}

/* ── Biblioteca page wrapper top-padding (accounts for fixed nav) ─── */
.page-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px 80px;
}