/* ==========================================================================
   Manga Library - Modern OLED Dark Catalog & Gallery Stylesheet
   ========================================================================== */

body.library-page {
  overflow-y: auto !important;
  overflow-x: hidden;
  background-color: #06070a;
  background-image: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(244, 63, 94, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(56, 189, 248, 0.06), transparent);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header Navigation Bar
   ========================================================================== */
.library-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 64px;
  background: rgba(10, 12, 18, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.4);
}

.brand-title-group h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f8fafc;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fb7185;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Header Actions */
.header-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-action-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-action-link:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  transform: translateY(-1px);
}

.nav-action-link.highlight {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.2) 0%, rgba(225, 29, 72, 0.2) 100%);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.nav-action-link.highlight:hover {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(244, 63, 94, 0.45);
}

/* ==========================================================================
   Hero & Control Section
   ========================================================================== */
.library-main {
  flex: 1;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px 24px;
}

.library-hero {
  margin-bottom: 32px;
}

.hero-top-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.hero-title-area h2 {
  font-size: 1.85rem;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.hero-title-area p {
  color: #94a3b8;
  font-size: 0.92rem;
}

.hero-stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: rgba(18, 21, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.82rem;
  color: #cbd5e1;
}

.stat-pill strong {
  color: #f43f5e;
  font-weight: 700;
}

/* Search & Filter Toolbar */
.filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: rgba(15, 18, 26, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

.search-box-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 440px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 38px 10px 40px;
  border-radius: 10px;
  background: rgba(8, 10, 15, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: #f43f5e;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.18);
  background: rgba(12, 15, 22, 0.95);
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  display: none;
}

.search-clear-btn:hover {
  color: #cbd5e1;
}

.sort-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-label {
  font-size: 0.82rem;
  color: #94a3b8;
  font-weight: 500;
}

.sort-select {
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(8, 10, 15, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: rotate(45deg);
}

/* ==========================================================================
   Manga Grid & Card Architecture
   ========================================================================== */
.manga-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

@media (max-width: 640px) {
  .manga-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
  }
}

.manga-card {
  position: relative;
  border-radius: 14px;
  background: #0f1118;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.manga-card:hover {
  transform: translateY(-5px);
  border-color: rgba(244, 63, 94, 0.4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6), 0 0 20px rgba(244, 63, 94, 0.15);
}

/* Card Cover Container */
.card-cover-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4.3;
  overflow: hidden;
  background: #141722;
}

.card-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.manga-card:hover .card-cover-img {
  transform: scale(1.06);
}

.card-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #475569;
  background: linear-gradient(145deg, #131722 0%, #0d0f17 100%);
  padding: 16px;
  text-align: center;
}

.card-cover-placeholder span {
  font-size: 0.78rem;
  font-weight: 500;
}

/* Badges on Cover */
.chapter-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.card-overlay-btn {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.manga-card:hover .card-overlay-btn {
  opacity: 1;
}

.quick-read-btn {
  padding: 9px 18px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(244, 63, 94, 0.6);
  transform: translateY(6px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.manga-card:hover .quick-read-btn {
  transform: translateY(0);
}

/* Card Info Body */
.card-info {
  padding: 12px 14px 14px 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.35;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.5em;
}

.card-meta-row {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: #94a3b8;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.card-author {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}

/* ==========================================================================
   Shimmer Loading State
   ========================================================================== */
.skeleton-card {
  border-radius: 14px;
  background: #0f1118;
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.skeleton-cover {
  width: 100%;
  aspect-ratio: 3 / 4.3;
  background: linear-gradient(90deg, #131622 25%, #1c2133 50%, #131622 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-info {
  padding: 14px;
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #131622 25%, #1c2133 50%, #131622 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 8px;
}

.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-50 { width: 50%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   Empty & Error States
   ========================================================================== */
.empty-state-box {
  grid-column: 1 / -1;
  padding: 64px 20px;
  text-align: center;
  background: rgba(15, 18, 26, 0.5);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.empty-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(244, 63, 94, 0.1);
  color: #f43f5e;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-box h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f8fafc;
}

.empty-state-box p {
  color: #94a3b8;
  font-size: 0.88rem;
  max-width: 400px;
}

.btn-cta-upload {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  box-shadow: 0 4px 18px rgba(244, 63, 94, 0.4);
  transition: all 0.2s;
}

.btn-cta-upload:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(244, 63, 94, 0.6);
}

/* ==========================================================================
   Chapter Selection Modal / Slide-over Drawer
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.manga-detail-modal {
  position: relative;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  border-radius: 20px;
  background: #0d0f17;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(244, 63, 94, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .manga-detail-modal {
  transform: scale(1) translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: rgba(244, 63, 94, 0.2);
  color: #ffffff;
  border-color: #f43f5e;
}

/* Modal Header Content */
.modal-header-content {
  display: flex;
  gap: 20px;
  padding: 24px;
  background: linear-gradient(180deg, rgba(20, 24, 36, 0.6) 0%, rgba(13, 15, 23, 0) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-cover-img {
  width: 110px;
  aspect-ratio: 3 / 4.2;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.modal-meta-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-right: 30px;
}

.modal-manga-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.35;
  margin-bottom: 6px;
}

.modal-original-title {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-bottom: 8px;
}

.modal-author-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #38bdf8;
  margin-bottom: 12px;
}

.modal-actions-row {
  margin-top: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-modal-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-modal-action.primary {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 10px rgba(244, 63, 94, 0.35);
}

.btn-modal-action.secondary {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}

.btn-modal-action.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Modal Chapters Section */
.modal-chapters-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.chapters-section-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chapter-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(18, 22, 32, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 10px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

.chapter-item-card:hover {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.35);
  transform: translateX(4px);
}

.ch-info-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ch-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #f8fafc;
}

.ch-meta-sub {
  font-size: 0.75rem;
  color: #94a3b8;
}

.ch-read-arrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #f43f5e;
}
