/* ══════════════════════════════════════════════
   Manga Theme - Main Styles
   ══════════════════════════════════════════════ */

/* ── CSS Custom Properties (Dark Theme Default) ── */
:root,
[data-theme="dark"] {
  --primary: #4bdd9e;
  --primary-hover: #3cc48a;
  --primary-rgb: 75, 221, 158;
  --bg-body: #1a1a2e;
  --bg-header: #0f0f23;
  --bg-card: #16213e;
  --bg-card-hover: #1a2847;
  --bg-input: #0f3460;
  --bg-footer: #0f0f23;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --border-color: #2a2a4a;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
}

[data-theme="light"] {
  --bg-body: #f5f5f5;
  --bg-header: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f0;
  --bg-input: #e8e8e8;
  --bg-footer: #2d2d2d;
  --text-primary: #1a1a2e;
  --text-secondary: #555555;
  --text-muted: #999999;
  --border-color: #dddddd;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; display: block; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ── */
.site-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.site-logo:hover { color: var(--primary); }
.site-logo i { font-size: 1.5rem; }

.main-nav { flex: 0 0 auto; }

.nav-menu {
  list-style: none;
  display: flex;
  gap: 4px;
}

.nav-menu li a {
  display: block;
  padding: 8px 14px;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background 0.2s;
}
.nav-menu li a:hover {
  background: var(--bg-card);
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* ── Search ── */
.search-wrapper { position: relative; }

.search-form {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
  transition: border-color 0.2s;
}
.search-form:focus-within { border-color: var(--primary); }

.search-input {
  background: transparent;
  border: none;
  padding: 8px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 220px;
  outline: none;
}
.search-input::placeholder { color: var(--text-muted); }

.search-btn {
  background: var(--primary);
  border: none;
  padding: 8px 12px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}
.search-btn:hover { background: var(--primary-hover); }

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  min-width: 320px;
}
.search-results-dropdown.active { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}
.search-result-item:hover { background: var(--bg-card-hover); }
.search-result-item:last-child { border-bottom: none; }

.search-result-cover { width: 40px; height: 56px; flex-shrink: 0; border-radius: var(--radius-sm); overflow: hidden; }
.search-result-cover img { width: 100%; height: 100%; object-fit: cover; }

.search-result-info { flex: 1; min-width: 0; }
.search-result-title { display: block; font-weight: 600; font-size: 0.9rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-genres { display: block; font-size: 0.75rem; color: var(--text-muted); }
.search-result-chapter { display: block; font-size: 0.75rem; color: var(--primary); }
.search-result-rating { font-size: 0.8rem; color: #ffc107; white-space: nowrap; }
.search-no-result { padding: 20px; text-align: center; color: var(--text-muted); }

/* ── Theme Toggle & Mobile Menu ── */
.theme-toggle, .mobile-menu-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.theme-toggle:hover, .mobile-menu-toggle:hover { border-color: var(--primary); color: var(--primary); }
.mobile-menu-toggle { display: none; }

/* ── Layout ── */
.content-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  padding: 24px 0;
}

.homepage, .archive-page, .search-page { padding-top: 0; }

/* ── Sections ── */
.section { margin-bottom: 32px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.section-header h1,
.section-header h2 {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header h1 i,
.section-header h2 i { color: var(--primary); }

.view-all {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.manga-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.manga-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.manga-card-link { display: block; color: var(--text-primary); }

.manga-card-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--bg-input);
}
.manga-card-cover img { width: 100%; height: 100%; object-fit: cover; }

.no-cover, .no-cover-lg, .no-cover-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--bg-input);
}

.card-rating {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffc107;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.manga-card-info { padding: 10px; }

.manga-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.latest-chapter { font-size: 0.75rem; color: var(--primary); }
.update-time { font-size: 0.7rem; color: var(--text-muted); display: block; }
.view-count { font-size: 0.75rem; color: var(--text-secondary); }

/* ── Status Badge ── */
.status-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.status-ongoing   { background: var(--primary); color: #000; }
.status-completed { background: #3b82f6; color: #fff; }
.status-hiatus    { background: #ef4444; color: #fff; }

/* ── Manga Detail Page ── */
.manga-detail { padding: 24px 0; }

.manga-header {
  display: flex;
  gap: 24px;
  margin-bottom: 32px;
}

.manga-cover-wrapper {
  width: 250px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.manga-cover-wrapper img { width: 100%; }

.manga-info { flex: 1; }

.manga-title { font-size: 1.8rem; margin-bottom: 4px; }
.manga-alt-title { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px; }

.manga-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.meta-value { font-size: 0.9rem; }

.manga-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.genre-tag {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.8rem;
  transition: background 0.2s;
}
.genre-tag:hover { background: rgba(var(--primary-rgb), 0.3); color: var(--primary); }

.manga-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #000; }
.btn-primary:hover { background: var(--primary-hover); color: #000; }

.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn.disabled { opacity: 0.4; pointer-events: none; }

.bookmark-btn.bookmarked { background: var(--primary); color: #000; }

/* ── Synopsis ── */
.manga-synopsis { margin-bottom: 32px; }
.manga-synopsis h2 { font-size: 1.2rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.manga-synopsis h2 i { color: var(--primary); }
.synopsis-content { color: var(--text-secondary); line-height: 1.8; }

/* ── Chapter List ── */
.chapter-list-section { margin-bottom: 32px; }
.chapter-count { font-size: 0.85rem; color: var(--text-muted); }

.chapter-list {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 600px;
  overflow-y: auto;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: background 0.2s;
}
.chapter-item:hover { background: var(--bg-card-hover); }
.chapter-item:last-child { border-bottom: none; }
.chapter-item.chapter-read { opacity: 0.5; }

.chapter-number { font-weight: 600; white-space: nowrap; min-width: 100px; }
.chapter-title { flex: 1; font-size: 0.9rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-date { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

/* ── Chapter Reader ── */
.chapter-reader { background: #000; min-height: 100vh; }

.chapter-nav-bar {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 60px;
  z-index: 50;
}

.chapter-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  gap: 12px;
}

.back-to-manga {
  color: var(--text-primary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.current-chapter {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.chapter-nav-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

.chapter-images {
  max-width: 900px;
  margin: 0 auto;
}

.chapter-page img {
  width: 100%;
  display: block;
}

.chapter-bottom-nav {
  background: var(--bg-header);
  border-top: 1px solid var(--border-color);
  padding: 16px 0;
}

.chapter-bottom-nav .chapter-nav-buttons {
  justify-content: center;
}

/* ── Genre Filter ── */
.genre-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.genre-filter-btn {
  padding: 6px 14px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 20px;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.genre-filter-btn:hover, .genre-filter-btn.active {
  background: var(--primary);
  color: #000;
}

/* ── Sidebar ── */
.sidebar { position: sticky; top: 84px; }

.sidebar-widget {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.widget-title {
  font-size: 1.1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.widget-title i { color: #ffc107; }

.ranking-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.ranking-tab {
  flex: 1;
  padding: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.ranking-tab.active, .ranking-tab:hover {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}
.ranking-item:last-child { border-bottom: none; }

.rank-number {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-input);
  color: var(--text-muted);
}
.rank-1 { background: #ffd700; color: #000; }
.rank-2 { background: #c0c0c0; color: #000; }
.rank-3 { background: #cd7f32; color: #fff; }

.rank-cover {
  width: 40px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.rank-cover img { width: 100%; height: 100%; object-fit: cover; }

.rank-info { flex: 1; min-width: 0; }
.rank-title { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-title:hover { color: var(--primary); }
.rank-meta { display: flex; gap: 8px; font-size: 0.7rem; color: var(--text-muted); }
.rank-rating { color: #ffc107; }
.rank-views { font-size: 0.7rem; color: var(--text-muted); }

/* ── Star Rating ── */
.star-rating { color: #ffc107; font-size: 0.85rem; }
.star-rating .rating-number { color: var(--text-secondary); margin-left: 4px; }

/* ── 404 ── */
.error-404 { padding: 80px 0; text-align: center; }
.error-content h1 { font-size: 6rem; color: var(--primary); margin-bottom: 8px; }
.error-content p { color: var(--text-secondary); margin-bottom: 24px; font-size: 1.1rem; }
.error-actions { display: flex; gap: 12px; justify-content: center; }

/* ── No Data ── */
.no-data { text-align: center; color: var(--text-muted); padding: 40px 20px; }
.no-results { text-align: center; padding: 60px 20px; grid-column: 1 / -1; }

/* ── Load More ── */
.load-more-wrapper { text-align: center; margin-top: 24px; }

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

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 32px;
}

.footer-col h4 {
  font-size: 1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.footer-col h4 i { color: var(--primary); }
.footer-col p { font-size: 0.85rem; color: var(--text-secondary); }

.footer-menu { list-style: none; }
.footer-menu li a { display: block; padding: 4px 0; font-size: 0.85rem; color: var(--text-secondary); }
.footer-menu li a:hover { color: var(--primary); }

.footer-genres { display: flex; flex-wrap: wrap; gap: 6px; }

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding: 16px 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Pagination (WordPress default) ── */
.nav-links {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
}
.nav-links a, .nav-links span {
  padding: 8px 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.nav-links .current { background: var(--primary); color: #000; }
.nav-links a:hover { background: var(--primary-hover); color: #000; }

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

/* ══════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════ */
@media (max-width: 992px) {
  .content-with-sidebar {
    grid-template-columns: 1fr;
  }
  .sidebar { position: static; }
}

@media (max-width: 768px) {
  .main-nav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--bg-header); border-bottom: 1px solid var(--border-color); padding: 12px; }
  .main-nav.open { display: block; }
  .nav-menu { flex-direction: column; }
  .mobile-menu-toggle { display: flex; }

  .search-input { width: 140px; }
  .manga-header { flex-direction: column; align-items: center; text-align: center; }
  .manga-cover-wrapper { width: 200px; }
  .manga-meta-grid { grid-template-columns: 1fr 1fr; }
  .manga-actions { justify-content: center; }
  .manga-genres { justify-content: center; }

  .manga-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

  .footer-grid { grid-template-columns: 1fr; gap: 20px; }

  .chapter-nav-inner { flex-wrap: wrap; }
  .back-to-manga { flex: 100%; }
  .error-content h1 { font-size: 4rem; }
}

@media (max-width: 480px) {
  .manga-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .manga-card-info { padding: 6px; }
  .manga-card-title { font-size: 0.75rem; }
  .header-inner { gap: 8px; }
  .search-input { width: 100px; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }
