/* ===== CSS Variables ===== */
:root {
  /* Colors - Dark Theme */
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-card: #242424;
  --bg-hover: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --border: #333333;
  --gradient-1: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
  --gradient-2: linear-gradient(135deg, #0ea5e9 0%, #7c3aed 100%);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s ease;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* ===== Layout ===== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden {
  display: none !important;
}

/* ===== Header ===== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-icon {
  font-size: 1.8rem;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.search-box input {
  background: transparent;
  border: none;
  padding: 10px 16px;
  color: var(--text-primary);
  width: 200px;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.btn-search {
  background: var(--accent);
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-search:hover {
  background: var(--accent-hover);
}

.provider-select {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
}

.btn-theme {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
}

.btn-theme:hover {
  background: var(--bg-hover);
}

/* ===== Hero ===== */
.hero {
  background: var(--gradient-1);
  padding: 60px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 12px;
  position: relative;
}

.hero-subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
  margin-bottom: 30px;
  position: relative;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 60px;
  position: relative;
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ===== Main Content ===== */
.main {
  padding: 40px 0;
}

/* ===== Section ===== */
.section {
  margin-bottom: 50px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
}

.section-controls {
  display: flex;
  gap: 10px;
}

.btn-refresh,
.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}

.btn-refresh:hover,
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* ===== Manga Grid ===== */
.manga-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.manga-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
}

.manga-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.manga-card-image {
  aspect-ratio: 3/4;
  position: relative;
  overflow: hidden;
}

.manga-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.manga-card:hover .manga-card-image img {
  transform: scale(1.05);
}

.manga-type {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.manga-status {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--success);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}

.manga-status.completed {
  background: var(--warning);
}

.manga-card-content {
  padding: 14px;
}

.manga-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.manga-chapter {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.manga-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--warning);
  margin-top: 6px;
}

/* Loading Skeleton */
.loading-skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
  height: 280px;
}

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

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 30px;
}

.pagination button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.pagination button:hover,
.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Modal ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}

.modal.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  max-width: 900px;
  width: 100%;
  margin-top: 40px;
  position: relative;
  border: 1px solid var(--border);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition);
  z-index: 10;
}

.modal-close:hover {
  background: var(--error);
  border-color: var(--error);
}

.modal-body {
  padding: 30px;
}

/* Detail Content */
.detail-header {
  display: flex;
  gap: 30px;
  margin-bottom: 30px;
}

.detail-cover {
  width: 220px;
  flex-shrink: 0;
}

.detail-cover img {
  width: 100%;
  border-radius: var(--radius);
}

.detail-info h1 {
  font-size: 1.8rem;
  margin-bottom: 12px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-meta span {
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
}

.detail-description {
  color: var(--text-secondary);
  line-height: 1.8;
}

.chapters-list {
  margin-top: 30px;
}

.chapters-list h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.chapter-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.chapter-item:hover {
  background: var(--bg-hover);
  padding-left: 24px;
}

.chapter-name {
  font-weight: 500;
}

.chapter-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== Reader Modal ===== */
.reader-modal {
  background: var(--bg-primary);
  flex-direction: column;
}

.reader-modal.active {
  display: flex;
}

.reader-header {
  background: var(--bg-secondary);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.btn-back,
.btn-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-back:hover,
.btn-nav:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.chapter-title {
  font-weight: 600;
}

.reader-nav {
  display: flex;
  gap: 10px;
}

.reader-content {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.reader-content img {
  max-width: 800px;
  width: 100%;
  border-radius: var(--radius-sm);
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 40px 0;
  margin-top: 60px;
}

.footer-content {
  text-align: center;
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copy {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 24px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: var(--transition);
  z-index: 2000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--error);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header .container {
    flex-wrap: wrap;
    height: auto;
    padding: 16px 20px;
  }
  
  .nav {
    display: none;
  }
  
  .header-actions {
    width: 100%;
    margin-top: 12px;
  }
  
  .search-box {
    flex: 1;
  }
  
  .search-box input {
    width: 100%;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-stats {
    gap: 30px;
  }
  
  .manga-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
  
  .detail-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .detail-cover {
    width: 160px;
  }
  
  .detail-meta {
    justify-content: center;
  }
}
