@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Outfit:wght@400;600;700;800;900&display=swap');

:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(19, 27, 46, 0.7);
  --bg-card-hover: rgba(30, 41, 69, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(99, 102, 241, 0.35);
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --accent-gradient-orange: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --reader-bg: #05070c;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.safe-top-bar {
  padding-top: var(--safe-top);
}

.reader-safe-main {
  padding-top: calc(10px + var(--safe-top));
  padding-bottom: calc(120px + var(--safe-bottom));
}

.reader-bottom-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(9, 13, 22, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(51, 65, 85, 0.85);
  padding: 8px 12px calc(10px + var(--safe-bottom));
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.65);
}

body.reader-active header.glass-nav,
body.reader-active footer {
  display: none;
}

body.reader-active #mvZipProgressToast {
  bottom: calc(108px + var(--safe-bottom));
}

h1, h2, h3, h4, .font-heading {
  font-family: 'Outfit', sans-serif;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #090d16;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Glassmorphism Classes */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
}

.glass-nav {
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

/* Gradients & Buttons */
.btn-gradient {
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.35);
}
.btn-gradient:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(99, 102, 241, 0.5);
  filter: brightness(1.1);
}
.btn-gradient:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  transition: all 0.2s ease;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-download-action {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
  transition: all 0.25s ease;
}
.btn-download-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.55);
}

/* Manga Cards */
.manga-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.manga-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-accent);
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.6), 0 0 16px 0 rgba(99, 102, 241, 0.25);
}
.manga-card .cover-container {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4.2;
  overflow: hidden;
  background: #111827;
}
.manga-card .cover-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.manga-card:hover .cover-container img {
  transform: scale(1.05);
}

/* Badges */
.badge-manhwa {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}
.badge-manga {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: white;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}
.badge-action {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  color: white;
  font-weight: 700;
  font-size: 0.7rem;
}

/* Webtoon Continuous Scroll Reader */
.webtoon-viewport {
  background-color: var(--reader-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.webtoon-container {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  user-select: none;
}
.webtoon-image-wrapper {
  position: relative;
  width: 100%;
  min-height: 400px;
  background-color: #0b0f19;
  display: flex;
  justify-content: center;
  align-items: center;
}
.webtoon-image-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}

/* Manga Single Page Mode */
.manga-single-viewport {
  position: relative;
  width: 100%;
  height: calc(100dvh - 135px - var(--safe-top) - var(--safe-bottom));
  min-height: 360px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.manga-single-viewport img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  border-radius: 6px;
}

/* Shimmer Loading Skeleton */
.skeleton {
  background: linear-gradient(90deg, #131b2e 25%, #1e293b 50%, #131b2e 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Category Filter Pills */
.category-pill {
  padding: 8px 18px;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}
.category-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
}
.category-pill.active {
  background: var(--accent-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* Fixed Floating Reader Bar */
.reader-floating-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-accent);
  border-radius: 9999px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  z-index: 50;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Animations */
.animate-fade-in {
  animation: fadeIn 0.25s ease forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .webtoon-container {
    max-width: 100%;
  }
  .reader-floating-bar {
    width: 92%;
    bottom: calc(12px + var(--safe-bottom));
    padding: 8px 12px;
    justify-content: space-between;
  }
}
