/* Catalog Page — Professional, smooth, innovative */

body.catalog-page {
  overflow: hidden;
  height: 100vh;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 72px);
  max-height: calc(100vh - 72px);
  margin-top: 72px;
  overflow: hidden;
  background: linear-gradient(180deg, #faf8f5 0%, #fff 30%);
}

/* Sidebar — Refined index */
.catalog-sidebar {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border-right: 1px solid rgba(232, 224, 208, 0.8);
  padding: 28px 0;
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow-y: auto;
  overflow-x: hidden;
}

.catalog-sidebar::-webkit-scrollbar {
  width: 6px;
}

.catalog-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.catalog-sidebar::-webkit-scrollbar-thumb {
  background: rgba(201, 162, 39, 0.25);
  border-radius: 3px;
}

.sidebar-header {
  padding: 0 24px 24px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.2);
}

.sidebar-header h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-black);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.sidebar-header p {
  font-size: 0.8rem;
  color: var(--color-grey);
  letter-spacing: 0.05em;
}

.index-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.index-nav li {
  margin: 0;
  animation: fadeInUp 0.4s ease-out backwards;
}

.index-nav li:nth-child(1) { animation-delay: 0.02s; }
.index-nav li:nth-child(2) { animation-delay: 0.04s; }
.index-nav li:nth-child(3) { animation-delay: 0.06s; }
.index-nav li:nth-child(4) { animation-delay: 0.08s; }
.index-nav li:nth-child(5) { animation-delay: 0.10s; }
.index-nav li:nth-child(6) { animation-delay: 0.12s; }
.index-nav li:nth-child(7) { animation-delay: 0.14s; }
.index-nav li:nth-child(8) { animation-delay: 0.16s; }
.index-nav li:nth-child(n+9) { animation-delay: 0.18s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.index-nav a {
  display: block;
  padding: 12px 24px;
  font-size: 0.85rem;
  color: var(--color-black);
  border-left: 3px solid transparent;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.index-nav a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.15), transparent);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.index-nav a:hover {
  background: rgba(201, 162, 39, 0.06);
  color: var(--color-gold-dark);
  border-left-color: var(--color-gold);
  padding-left: 28px;
}

.index-nav a:hover::before {
  width: 100%;
}

.index-nav a.active {
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.12), transparent);
  color: var(--color-gold-dark);
  font-weight: 600;
  border-left-color: var(--color-gold);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.08);
}

/* Main content */
.catalog-main {
  display: flex;
  flex-direction: column;
  padding: 12px 24px;
  background: transparent;
  overflow: hidden;
  min-height: 0;
}

/* Toolbar — Compact */
.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 8px 14px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  border: 1px solid rgba(232, 224, 208, 0.6);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-page {
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(232, 224, 208, 0.8);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.btn-page:hover {
  background: var(--gradient-gold);
  color: var(--color-white);
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(201, 162, 39, 0.35);
}

.btn-page:active {
  transform: translateY(0);
}

.btn-page.btn-primary {
  background: var(--gradient-gold);
  color: var(--color-white);
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(201, 162, 39, 0.3);
}

.page-info {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-grey);
  min-width: 48px;
  text-align: center;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.view-toggle .btn-view {
  border-radius: 0;
}

.view-toggle .btn-view:first-child {
  border-radius: 6px 0 0 6px;
}

.view-toggle .btn-view:last-child {
  border-radius: 0 6px 6px 0;
}

.view-toggle .btn-view.active {
  background: var(--gradient-gold);
  color: var(--color-white);
  border-color: transparent;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-jump label {
  font-size: 0.75rem;
  color: var(--color-grey);
}

.page-jump input {
  width: 40px;
  padding: 6px 8px;
  font-size: 0.8rem;
  border: 1px solid rgba(232, 224, 208, 0.8);
  border-radius: 6px;
  text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.page-jump input:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2);
}

/* Viewer — Fit to page, no vertical scroll */
.catalog-viewer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.catalog-page-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
  background: var(--color-white);
  position: relative;
}

.catalog-page-wrap.animating {
  pointer-events: none;
}

.catalog-page-wrap img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  object-position: center;
  transition: opacity 0.5s ease-in-out;
}

.catalog-page-wrap img.fade-out {
  opacity: 0;
}

.catalog-page-wrap img.fade-in {
  opacity: 1;
}

/* Click to lightbox */
.catalog-page-wrap {
  cursor: zoom-in;
}

/* Grid view — Staggered animation */
.catalog-grid-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.catalog-table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

.catalog-table-grid .grid-item {
  background: var(--color-white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation: gridItemFade 0.5s ease-out backwards;
  cursor: pointer;
}

.catalog-table-grid .grid-item:nth-child(1) { animation-delay: 0.03s; }
.catalog-table-grid .grid-item:nth-child(2) { animation-delay: 0.06s; }
.catalog-table-grid .grid-item:nth-child(3) { animation-delay: 0.09s; }
.catalog-table-grid .grid-item:nth-child(4) { animation-delay: 0.12s; }
.catalog-table-grid .grid-item:nth-child(5) { animation-delay: 0.15s; }
.catalog-table-grid .grid-item:nth-child(6) { animation-delay: 0.18s; }
.catalog-table-grid .grid-item:nth-child(7) { animation-delay: 0.21s; }
.catalog-table-grid .grid-item:nth-child(8) { animation-delay: 0.24s; }
.catalog-table-grid .grid-item:nth-child(n+9) { animation-delay: 0.27s; }

@keyframes gridItemFade {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.catalog-table-grid .grid-item:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(201, 162, 39, 0.15);
}

.catalog-table-grid .grid-item .img-wrap {
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--color-cream);
}

.catalog-table-grid .grid-item .img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.catalog-table-grid .grid-item:hover .img-wrap img {
  transform: scale(1.05);
}

.catalog-table-grid .grid-item .label {
  padding: 14px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-black);
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  transition: background 0.3s;
}

.catalog-table-grid .grid-item:hover .label {
  background: rgba(201, 162, 39, 0.08);
  color: var(--color-gold-dark);
}

/* Page nav bottom */
.page-nav-bottom {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
  flex-shrink: 0;
}

.page-nav-bottom .btn-page {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.catalog-footer {
  text-align: center;
  padding: 12px 16px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  border: 1px solid rgba(232, 224, 208, 0.5);
  font-size: 0.8rem;
  color: var(--color-grey);
}

.catalog-footer a {
  color: var(--color-gold);
  font-weight: 600;
  transition: color 0.3s;
}

.catalog-footer a:hover {
  color: var(--color-gold-dark);
}

/* Lightbox */
.catalog-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s;
}

.catalog-lightbox.open {
  opacity: 1;
  visibility: visible;
}

.catalog-lightbox img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.catalog-lightbox.open img {
  transform: scale(1);
}

.catalog-lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 24px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s;
}

.catalog-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 1024px) {
  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .catalog-sidebar {
    position: relative;
    top: 0;
    height: auto;
    max-height: 280px;
    border-right: none;
    border-bottom: 1px solid rgba(232, 224, 208, 0.6);
  }

  .index-nav {
    max-height: 180px;
    overflow-y: auto;
  }
}
