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

/* ============================================
   CSS Variables - DocLN Style Light Mode
============================================ */
:root {
  /* Màu nền */
  --bg-main: #f1f5f9;
  --bg-white: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar-header: #334155;

  /* Màu chữ */
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-link: #36a189;

  /* Màu nhấn */
  --accent-teal: #36a189;
  --accent-green: #22c55e;
  --accent-red: #e11d48;
  --accent-purple: #6366f1;

  /* Border */
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-hover: 0 8px 20px rgba(0,0,0,0.1);

  /* Navbar */
  --navbar-bg: #ffffff;
  --navbar-height: 56px;

  /* Reader themes */
  --theme-bg: #f4ecd8;
  --theme-text: #3d2b1f;
  --theme-toolbar-bg: rgba(255,255,255,0.97);
  --theme-toolbar-border: rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Open Sans', 'Inter', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent-teal);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ============================================
   Navbar - Trắng sạch như DocLN
============================================ */
.navbar {
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--border-color);
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-teal);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none !important;
}
.nav-brand:hover { text-decoration: none !important; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.nav-links a:hover {
  background: var(--bg-main);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-links .btn-logout {
  color: #ef4444;
}
.nav-links .btn-logout:hover { background: #fef2f2; }

.nav-user-info {
  color: var(--accent-teal) !important;
  font-weight: 600 !important;
}

/* ============================================
   Main Layout - 2 cột như DocLN
============================================ */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.25rem;
  align-items: start;
}

.main-content { min-width: 0; }

.sidebar {
  position: sticky;
  top: calc(var(--navbar-height) + 1rem);
}

/* ============================================
   Section Box (khối div trắng như DocLN)
============================================ */
.section-box {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.section-box-header {
  background: var(--bg-sidebar-header);
  color: #fff;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-box-body {
  padding: 1rem;
}

/* Section title cho main content */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent-teal);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   Novel Grid Cards - Style DocLN
============================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
}

.novel-card {
  cursor: pointer;
  transition: all 0.2s ease;
}

.novel-card:hover {
  transform: translateY(-3px);
}

.novel-card:hover .novel-card-title {
  color: var(--accent-teal);
}

.novel-card-cover {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: #e2e8f0;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.novel-card-cover-wrapper {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.novel-card-cover-wrapper img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}

.novel-card-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff;
  font-size: 0.7rem;
  padding: 1.5rem 0.4rem 0.4rem;
  border-radius: 0 0 4px 4px;
}

.novel-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.5rem;
  line-height: 1.4;
  transition: color 0.15s;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   Search Bar
============================================ */
.search-container {
  margin-bottom: 1.25rem;
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper i {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.search-input-wrapper input:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(54, 161, 137, 0.1);
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.75rem;
}

.filter-tag {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  padding: 3px 12px;
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  font-weight: 500;
}

.filter-tag.active,
.filter-tag:hover {
  background: var(--accent-teal);
  color: #fff;
  border-color: var(--accent-teal);
}

/* ============================================
   Buttons
============================================ */
.btn-primary {
  background: var(--accent-teal);
  color: #fff;
  border: none;
  padding: 0.6rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover {
  background: #2d8a74;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--accent-teal);
  border: 1px solid var(--accent-teal);
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none !important;
}
.btn-outline:hover {
  background: var(--accent-teal);
  color: #fff;
}

/* ============================================
   Form Inputs (Glass replaced with clean white)
============================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.glass-input {
  width: 100%;
  padding: 0.6rem 0.875rem;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.glass-input:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(54, 161, 137, 0.1);
}

/* ============================================
   Request Container (Scrape Form)
============================================ */
.request-container {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ============================================
   Hero Section (đơn giản hơn)
============================================ */
.hero {
  text-align: left;
  padding: 1.5rem 0 0.5rem;
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.hero p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

/* ============================================
   Novel Detail Page
============================================ */
.novel-header {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.5rem;
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.novel-cover {
  width: 160px;
  height: 230px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.novel-info { flex: 1; min-width: 200px; }

.novel-info h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #dcfce7;
  color: #15803d;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* Tags inline style */
.tag-pill {
  display: inline-block;
  background: #f0fdfb;
  color: var(--accent-teal);
  border: 1px solid #99e6d8;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 4px;
  margin-bottom: 4px;
}

/* Chapter list */
.library-section {
  padding: 0;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chapter-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  color: var(--accent-teal);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

.chapter-btn:hover {
  background: var(--bg-main);
  text-decoration: none;
}

.chapter-btn:last-child {
  border-bottom: none;
}

/* ============================================
   Reader Page
============================================ */
body.reader-mode {
  background: var(--theme-bg) !important;
  background-image: none !important;
  color: var(--theme-text) !important;
}

.theme-light {
  --theme-bg: #f9f9fb;
  --theme-text: #1e293b;
  --theme-toolbar-bg: rgba(255,255,255,0.97);
  --theme-toolbar-border: rgba(0,0,0,0.06);
}
.theme-dark {
  --theme-bg: #1e293b;
  --theme-text: #f1f5f9;
  --theme-toolbar-bg: rgba(30, 41, 59, 0.97);
  --theme-toolbar-border: rgba(255,255,255,0.07);
}
.theme-amoled {
  --theme-bg: #000000;
  --theme-text: #e2e8f0;
  --theme-toolbar-bg: rgba(0,0,0,0.97);
  --theme-toolbar-border: rgba(255,255,255,0.08);
}
.theme-sepia {
  --theme-bg: #f4ecd8;
  --theme-text: #3d2b1f;
  --theme-toolbar-bg: rgba(244,236,216,0.97);
  --theme-toolbar-border: rgba(91,70,54,0.1);
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: var(--theme-toolbar-bg, rgba(255,255,255,0.97));
  border-bottom: 1px solid var(--theme-toolbar-border, rgba(0,0,0,0.08));
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.reader-toolbar .nav-brand {
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--theme-text, var(--text-primary));
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.lang-toggle {
  display: inline-flex;
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}

.lang-toggle button {
  padding: 4px 14px;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s;
  font-family: inherit;
}

.lang-toggle button.active {
  background: var(--accent-teal);
  color: #fff;
}

.trans-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.trans-badge.done { background: #dcfce7; color: #15803d; }
.trans-badge.pending { background: #fef9c3; color: #854d0e; }
.trans-badge.none { background: #f1f5f9; color: var(--text-muted); }

.reader-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 6rem;
  font-size: 1.1rem;
  line-height: 1.9;
}

.reader-container h2 {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--theme-text, var(--text-primary));
}

.reader-container p {
  margin-bottom: 1.25rem;
  color: var(--theme-text, var(--text-primary));
}

.reader-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.08);
}

/* Bottom Nav */
.reader-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--theme-toolbar-bg, rgba(255,255,255,0.97));
  border-top: 1px solid var(--theme-toolbar-border, rgba(0,0,0,0.08));
  display: flex;
  justify-content: space-between;
  padding: 8px 24px;
  backdrop-filter: blur(10px);
  z-index: 99;
  box-shadow: 0 -1px 6px rgba(0,0,0,0.06);
}

.reader-bottom-nav button {
  background: transparent;
  color: var(--theme-text, var(--text-primary));
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 6px;
  transition: background 0.15s;
}

.reader-bottom-nav button:hover {
  background: rgba(0,0,0,0.05);
}

/* ============================================
   Settings Panel
============================================ */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999;
  display: none;
  backdrop-filter: blur(3px);
}
.settings-overlay.show { display: block; }

.settings-panel {
  position: fixed;
  bottom: -100%;
  left: 0; right: 0;
  background: var(--bg-white);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  z-index: 1000;
  transition: bottom 0.3s ease;
  border-radius: 16px 16px 0 0;
  color: var(--text-primary);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
}

@media (min-width: 640px) {
  .settings-panel {
    bottom: auto; top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    width: 380px;
    border-radius: 12px;
    opacity: 0; visibility: hidden;
    transition: all 0.25s ease;
    border: 1px solid var(--border-color);
  }
  .settings-panel.show {
    opacity: 1; visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    bottom: auto !important;
  }
}
.settings-panel.show { bottom: 0; }

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.settings-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s;
}
.close-btn:hover { background: var(--bg-main); }

.setting-group { margin-bottom: 1.25rem; }
.setting-group label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.theme-options { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.15s;
  position: relative;
}
.theme-btn:hover { transform: scale(1.1); }
.theme-btn.active { border-color: var(--accent-teal); box-shadow: 0 0 0 2px var(--accent-teal); }
.bg-light { background: #f9f9fb; }
.bg-dark { background: #1e293b; }
.bg-amoled { background: #000; }
.bg-sepia { background: #f4ecd8; }

.font-size-ctrl, .font-family-ctrl { display: flex; gap: 8px; }
.font-size-ctrl button {
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.15s;
}
.font-size-ctrl button:hover { background: var(--accent-teal); color: #fff; border-color: var(--accent-teal); }

.font-family-ctrl select {
  flex: 1;
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
}

/* ============================================
   Auth Page
============================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  padding: 1rem;
}

.auth-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

/* ============================================
   Card Tag (status pill)
============================================ */
.card-tag {
  display: inline-block;
  background: var(--accent-teal);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* Glass card (kept for any legacy use, now plain white) */
.glass-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.glass-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.glass-card .card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0.6rem 0.75rem;
}
.glass-card .card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 0.75rem 0.6rem;
}

/* ============================================
   Sidebar Widgets
============================================ */
.sidebar-recent-list { list-style: none; }
.sidebar-recent-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82rem;
}
.sidebar-recent-list li:last-child { border-bottom: none; }
.sidebar-recent-list a { color: var(--text-primary); font-weight: 500; }
.sidebar-recent-list a:hover { color: var(--accent-teal); text-decoration: none; }

/* ============================================
   Admin Page
============================================ */
.admin-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.admin-card-title {
  color: var(--accent-teal);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.admin-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.status-msg { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.875rem; font-weight: 600; display: none; }
.status-msg.ok { background: #dcfce7; color: #15803d; display: block; }
.status-msg.err { background: #fee2e2; color: #b91c1c; display: block; }

/* ============================================
   Responsive - Mobile
============================================ */
@media (max-width: 768px) {
  .page-wrapper {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }
  .sidebar { display: none; }
  .novel-header { gap: 1rem; }
  .novel-cover { width: 120px; height: 175px; }
  .novel-info h1 { font-size: 1.2rem; }
  .hero h1 { font-size: 1.4rem; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
  .reader-container { font-size: 1rem; padding: 1.5rem 1rem 5rem; }
  .reader-container h2 { font-size: 1.2rem; }
  .navbar { flex-direction: column; height: auto; padding: 0.75rem 0.5rem; gap: 0.5rem; }
  .nav-links { flex-wrap: wrap; justify-content: center; }
  .nav-links a { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
