/* Manhwa18xx - High Performance Modern Dark & Light Stylesheet */

:root {
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --bg-card: #162032;
  --bg-card-hover: #1e293b;
  --bg-input: #1e293b;
  --border-color: #243047;
  --border-highlight: #3b82f6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-primary: #6366f1;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  --accent-cyan: #06b6d4;
  --accent-star: #eab308;
  --badge-bg: rgba(99, 102, 241, 0.15);
  --badge-border: rgba(99, 102, 241, 0.35);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --container-max: 1280px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 16px;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
}

.brand-logo span.highlight {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-18 {
  font-size: 0.65rem;
  background: #ef4444;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 900;
}

/* Nav links desktop */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 20px;
  list-style: none;
}

.nav-link {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover, .nav-link.active {
  color: #38bdf8;
}

/* Search bar */
.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 380px;
}

.search-input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px 8px 36px;
  border-radius: 999px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--border-highlight);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: none;
  z-index: 100;
  max-height: 380px;
  overflow-y: auto;
}

.search-autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}

.search-autocomplete-item:hover {
  background: var(--bg-card);
}

.search-item-thumb {
  width: 42px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
}

.search-item-info h4 {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
}

.search-item-info span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Language selector */
.lang-dropdown {
  position: relative;
}

.lang-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  min-width: 140px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  display: none;
  z-index: 100;
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.lang-item:hover, .lang-item.active {
  background: var(--bg-card);
  color: #38bdf8;
}

/* User Auth Button */
.btn-auth {
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s;
}

.btn-auth:hover {
  opacity: 0.9;
}

/* Main Hero Featured Banner */
.hero-section {
  padding: 24px 0 16px;
}

.hero-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(236, 72, 153, 0.1) 100%), var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  gap: 24px;
  align-items: center;
}

.hero-cover {
  width: 160px;
  height: 220px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 12px 24px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.hero-content {
  flex: 1;
}

.hero-tag {
  display: inline-block;
  background: rgba(236, 72, 153, 0.2);
  color: #f43f5e;
  border: 1px solid rgba(236, 72, 153, 0.4);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.hero-title {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 8px;
}

.hero-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-actions {
  display: flex;
  gap: 12px;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Manga Grid Section */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0 16px;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.manga-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.manga-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-highlight);
  box-shadow: 0 12px 24px rgba(0,0,0,0.3);
}

.card-thumb-wrapper {
  position: relative;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: #000;
}

.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

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

.card-badge-rating {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  color: var(--accent-star);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.card-badge-status {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(16, 185, 129, 0.9);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-chapters {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-chap-link {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  transition: color 0.15s;
}

.card-chap-link:hover {
  color: #38bdf8;
}

/* Genre Pills */
.genre-pills-wrap {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 16px;
  scrollbar-width: none;
}

.genre-pills-wrap::-webkit-scrollbar {
  display: none;
}

.genre-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: all 0.2s;
}

.genre-pill:hover, .genre-pill.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

/* Manga Details Page */
.manga-detail-wrapper {
  padding: 32px 0;
}

.manga-detail-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  margin-bottom: 24px;
}

.detail-cover {
  width: 100%;
  border-radius: 12px;
  aspect-ratio: 3/4;
  object-fit: cover;
  box-shadow: 0 12px 24px rgba(0,0,0,0.5);
}

.detail-meta-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.meta-item {
  font-size: 0.88rem;
}

.meta-item span.label {
  color: var(--text-dim);
  font-weight: 500;
}

.detail-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn-bookmark {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-bookmark.bookmarked {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #000;
}

/* Chapter List Box */
.chapter-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.chapter-filter-input {
  width: 100%;
  max-width: 300px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.chapter-rows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.chap-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s;
}

.chap-card-item:hover {
  border-color: #38bdf8;
  background: var(--bg-card-hover);
}

/* Reader Page */
.reader-container {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
}

.reader-floating-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: transform 0.3s ease;
}

.reader-select {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  max-width: 200px;
}

.reader-stream {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 16px 0;
}

.reader-page-img {
  width: 100%;
  max-width: 100%;
  display: block;
  min-height: 200px;
  background: #000;
  margin-bottom: 0;
  border: none;
}

.reader-single-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
}

.reader-bottom-nav {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 24px 0 48px;
}

/* Mobile Bottom Dock Navigation */
.mobile-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  z-index: 50;
  justify-content: space-around;
  align-items: center;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.dock-item.active {
  color: #38bdf8;
}

/* Auth Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  max-width: 420px;
  width: 100%;
  padding: 28px;
  position: relative;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-highlight);
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  justify-content: center;
}

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

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-desc {
  max-width: 500px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .nav-menu {
    display: none;
  }
  .mobile-dock {
    display: flex;
  }
  body {
    padding-bottom: 60px;
  }
  .hero-banner {
    flex-direction: column;
    text-align: center;
  }
  .hero-actions {
    justify-content: center;
  }
  .manga-detail-banner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .detail-cover {
    max-width: 200px;
    margin: 0 auto;
  }
  .detail-actions {
    justify-content: center;
  }
  .manga-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
}
