/* =========================================================
   KHONGGIANCHU - OTRUYEN-LIKE THEME (FULL REWRITE - FIX MOBILE)
   DÁN NGUYÊN FILE assets/style.css
   ========================================================= */

/* 0) Reset */
*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  background:#0b0f14;
  color:#e9eef6;
  font-family:system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height:1.45;
}
img{ max-width:100%; height:auto; display:block; }
a{ color:inherit; text-decoration:none; }
a:hover{ opacity:.95; }

/* 1) Variables */
:root{
  --bg:#0b0f14;

  --panel:rgba(255,255,255,.03);
  --panel2:rgba(255,255,255,.04);
  --panel3:rgba(255,255,255,.06);

  --text:#e9eef6;
  --muted:rgba(233,238,246,.72);

  --line:rgba(255,255,255,.12);
  --line2:rgba(255,255,255,.18);

  --shadow:0 12px 30px rgba(0,0,0,.35);

  --radius:16px;
  --radius-sm:12px;
  --gap:14px;

  --accent:#4aa3ff;
  --green:#22c55e;

  --wrap:980px;
}

/* 2) Common layout */
.container{
  max-width:var(--wrap);
  margin:0 auto;
  padding:16px 12px;
}

.section{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:var(--panel);
  box-shadow:var(--shadow);
  overflow:hidden;
}

.section .head{
  padding:14px;
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,.02);
}

.sub{
  color:var(--muted);
  font-size:13px;
  margin-top:6px;
}

.footer{
  max-width:var(--wrap);
  margin:20px auto 30px;
  padding:0 12px;
  color:var(--muted);
  font-size:13px;
}

/* 3) Hero */
.hero{
  margin:12px 0 16px;
  padding:16px;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:linear-gradient(180deg, rgba(74,163,255,.10), rgba(255,255,255,.02));
  box-shadow:var(--shadow);
}
.hero h1{ margin:0 0 6px; font-size:22px; }
.hero p{ margin:0; color:var(--muted); }

/* =========================================================
   HEADER (header.php) - 3 layers
   ========================================================= */
.site-header{
  position:sticky;
  top:0;
  z-index:999;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
  background:
    linear-gradient(
      180deg,
      rgba(255,255,255,.06) 0%,
      rgba(255,255,255,.02) 40%,
      rgba(255,255,255,0) 100%
    );

  /* hide/show */
  transition: transform .25s ease, opacity .25s ease;
  will-change: transform;
}

/* wrap inside header */
.wrap{ max-width:var(--wrap); margin:0 auto; padding:0 12px; }

/* Layer 1 */
.top-strip{
  background:rgba(255,255,255,.02);
  border-bottom:1px solid var(--line);
}
.strip-row{
  height:34px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.strip-link{
  color:var(--muted);
  font-size:13px;
}
.strip-link:hover{ text-decoration:underline; }
.dot{ color:var(--muted); margin:0 8px; }

/* Layer 2 */
.mainbar{
  background:rgba(255,255,255,.02);
  border-bottom:1px solid var(--line);
  min-height:72px;
  display:flex;
  align-items:center;
}
.main-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:14px 0;
  flex-wrap:wrap;
}

/* Brand */
.brand2{
  display:flex;
  align-items:center;
  gap:10px;
  flex:0 0 auto;
  min-width:0;
}

/* Logo chính */
.logo-main{
  width:42px;
  height:42px;
  border-radius:12px;
  padding:6px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border:1px solid var(--line);
  box-shadow:0 10px 22px rgba(0,0,0,.35);
  display:block;
  flex:0 0 auto;
}

.brand-name{
  font-weight:900;
  font-size:18px;
  letter-spacing:.4px;
  background: linear-gradient(90deg,#eaf2ff,#9ecbff);
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;

  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:320px;
}

/* Search */
.search2{
  flex:1;
  display:flex;
  gap:8px;
  min-width:220px;
}
.search2 input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  color:var(--text);
  outline:none;
  -webkit-appearance:none;
  appearance:none;
}
.search2 input::placeholder{ color:rgba(233,238,246,.45); }
.search2 button{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  color:var(--text);
  cursor:pointer;
  -webkit-appearance:none;
  appearance:none;
}
.search2 button:hover{ background:rgba(255,255,255,.05); border-color:var(--line2); }

/* User pill */
.userbox{ display:flex; align-items:center; }
.userpill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  color:var(--text);
  max-width:240px;
  min-width:0;
}
.userpill:hover{ background:rgba(255,255,255,.05); border-color:var(--line2); }
.userpill span{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.userpill img{
  width:24px; height:24px;
  border-radius:50%;
  object-fit:cover;
  border:1px solid var(--line);
  display:block;
}

/* Layer 3 menu */
.menubar{
  background:rgba(255,255,255,.015);
  border-bottom:1px solid var(--line);
}
.menu-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 0;
  flex-wrap:wrap;
}
.menu-link{
  color:var(--text);
  font-size:14px;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid transparent;
  background:transparent;
  cursor:pointer;
}
.menu-link:hover{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.10);
}

/* Dropdown */
.dropdown{ position:relative; }
.dropbtn{ border:none; background:transparent; }
.dropdown-content{
  display:none;
  position:absolute;
  top:40px;
  left:0;
  min-width:240px;
  padding:8px;
  border:1px solid var(--line);
  background:#121826;
  border-radius:14px;
  box-shadow:var(--shadow);
}
.dropdown-content a{
  display:block;
  padding:10px 10px;
  border-radius:10px;
  color:var(--text);
  font-size:14px;
}
.dropdown-content a:hover{ background:rgba(255,255,255,.06); }
.dropdown:hover .dropdown-content{ display:block; }

/* =========================================================
   GRID + CARD
   ========================================================= */
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(260px, 1fr));
  gap:var(--gap);
}

.card{
  display:block;
  padding:12px;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:rgba(255,255,255,.02);
  box-shadow:0 10px 26px rgba(0,0,0,.22);
  transition:transform .15s ease, border-color .15s ease, background .15s ease;
}
.card:hover{
  transform:translateY(-2px);
  border-color:rgba(255,255,255,.22);
  background:rgba(255,255,255,.03);
}

.title{
  font-weight:800;
  letter-spacing:.15px;
  font-size:15px;
  margin-bottom:6px;
}

.meta{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  color:var(--muted);
  font-size:12.5px;
}

.badge{
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  color:var(--muted);
  border-radius:999px;
  padding:6px 10px;
  display:inline-flex;
  align-items:center;
  gap:6px;
}

/* ✅ FIX: ÉP ẢNH BÌA TRONG CARD KHÔNG BAO GIỜ PHÌNH */
.grid .card img{
  width:72px !important;
  height:96px !important;
  object-fit:cover !important;
  border-radius:12px !important;
  border:1px solid var(--line) !important;
  flex:0 0 auto !important;
  display:block !important;
}

/* ✅ desc2 (index.php đang dùng) */
.desc2{
  margin-top:8px;
  color:var(--muted);
  font-size:13px;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

/* =========================================================
   BUTTON / PILL
   ========================================================= */
.btn, .pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  color:var(--text);
  border-radius:999px;
  padding:10px 12px;
  line-height:1;
  cursor:pointer;
  transition:transform .12s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:hover, .pill:hover{
  background:rgba(255,255,255,.05);
  border-color:rgba(255,255,255,.18);
}

.btn.primary{
  background:rgba(74,163,255,.16);
  border-color:rgba(74,163,255,.40);
  color:#dff0ff;
}
.btn.primary:hover{ background:rgba(74,163,255,.22); }

.btn.green{
  background:rgba(34,197,94,.14);
  border-color:rgba(34,197,94,.33);
}
.btn.green:hover{ background:rgba(34,197,94,.20); }

.btn.small{ padding:8px 10px; font-size:13px; }

/* =========================================================
   LIST + CHAPTER ITEM
   ========================================================= */
.list{ padding:10px; }

.chapter-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:14px;
  background:rgba(255,255,255,.02);
  margin-bottom:10px;
  transition:background .12s ease, border-color .12s ease, transform .12s ease;
}
.chapter-item:hover{
  background:rgba(255,255,255,.04);
  border-color:rgba(255,255,255,.18);
  transform:translateY(-1px);
}
.chapter-item .c-title{ font-weight:700; }
.chapter-item .right{ color:var(--muted); }

.notice{
  padding:12px;
  border:1px dashed rgba(255,255,255,.18);
  border-radius:14px;
  background:rgba(255,255,255,.02);
  color:var(--muted);
  margin:10px;
}

.desc{
  padding:14px;
  color:var(--muted);
  line-height:1.65;
}

/* =========================================================
   READER (chapter.php)
   ========================================================= */
.reader{
  padding:14px;
  background:rgba(255,255,255,.02);
  border-radius:var(--radius);
  border:1px solid var(--line);
}
.reader h1{ margin:0 0 8px; font-size:22px; }
.rmeta{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  color:var(--muted);
  font-size:13px;
  margin-bottom:12px;
}
.reader-nav{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin:12px 0;
}
.reader-content{
  padding:14px;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:rgba(0,0,0,.10);
  line-height:1.9;
  font-size:18px;
  color:var(--text);
}

/* =========================================================
   FORM INPUTS
   ========================================================= */
input, textarea, select{
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  color:var(--text);
  border-radius:var(--radius-sm);
  outline:none;
}
textarea{ width:100%; }

/* =========================================================
   LEGACY TOPBAR (những trang còn dùng .topbar)
   ========================================================= */
.topbar{
  position:sticky;
  top:0;
  z-index:998;
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,.02);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.topbar .row{
  max-width:var(--wrap);
  margin:0 auto;
  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.sub-brand,
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--text);
}

/* Logo mini cho menu phụ */
.mini-logo,
.logo-mini{
  width:28px;
  height:28px;
  border-radius:10px;
  padding:4px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.10);
  box-shadow:0 10px 22px rgba(0,0,0,.35);
  display:block;
  flex:0 0 auto;
}

/* Nếu còn dùng <span class="logo"></span> cũ */
.logo{
  width:28px;
  height:28px;
  border-radius:10px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.06);
  display:inline-block;
}

.nav{ display:flex; gap:8px; flex-wrap:wrap; }

/* =========================================================
   DARK MODE class (nếu bạn toggle body.dark)
   ========================================================= */
body.dark{
  background:#0b0f14 !important;
  color:var(--text) !important;
}
body.dark .section,
body.dark .card,
body.dark .reader{
  background:rgba(255,255,255,.03) !important;
  border-color:rgba(255,255,255,.12) !important;
}
body.dark .dropdown-content{ background:#151820 !important; }
body.dark a{ color:inherit; }

body.dark .site-header{
  background:
    linear-gradient(
      180deg,
      rgba(30,41,59,.55) 0%,
      rgba(15,23,42,.35) 45%,
      rgba(15,23,42,0) 100%
    );
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 700px){
  .grid{ grid-template-columns:1fr; }
  .reader-content{ padding:12px; }
}
@media (max-width: 480px){
  .hero{ padding:14px; }
  .btn, .pill{ padding:9px 11px; }
  .section .head{ padding:12px; }
}

/* =========================================================
   MOBILE COMPACT + HIDE FULL HEADER ON SCROLL
   ========================================================= */
@media (max-width: 900px){
  .top-strip{ display:none !important; }

  /* MAINBAR: 2 hàng gọn */
  .main-row{
    display:grid !important;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand user"
      "search search";
    gap:10px !important;
    padding:10px 0 !important;
    align-items:center;
  }
  .brand2{ grid-area:brand; min-width:0; }
  .userbox{ grid-area:user; justify-self:end; }
  .search2{ grid-area:search; width:100%; min-width:0 !important; }

  .brand-name{ font-size:16px !important; max-width:220px; }
  .userpill{ max-width:160px; }

  .search2 input{ height:40px; }
  .search2 button{ height:40px; }

  /* menubar gọn */
  .menu-row{ gap:6px !important; padding:6px 0 !important; }
  .menu-link{ padding:7px 9px !important; font-size:13px !important; }
}

/* ✅ Khi scroll xuống: ẩn toàn bộ header */
.site-header.hide-header{
  transform: translateY(-120%);
  opacity: 0;
  pointer-events: none;
}

/* Desktop luôn hiện */
@media (min-width: 901px){
  .site-header{
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}
/* ===============================
   STORY COVER - CENTER & BIG
   =============================== */

.story-cover{
  display: block;
  margin: 0 auto 14px;   /* căn giữa */
  width: 180px;          /* desktop */
  max-width: 70vw;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
}

/* Mobile */
@media (max-width: 900px){
  .story-cover{
    width: 220px;        /* TO hơn trên điện thoại */
    max-width: 80vw;
  }
}

@media (max-width: 480px){
  .story-cover{
    width: 260px;        /* TO rõ rệt */
    max-width: 88vw;
  }
}
/* ===============================
   STORY COVER - BIG + CENTER
   =============================== */
.story-cover{
  display:block !important;
  margin: 14px auto 16px !important;
  width: 320px !important;     /* mặc định to */
  max-width: 88vw !important;  /* không tràn màn */
  height: auto !important;
  border-radius: 18px !important;
  border: 1px solid rgba(255,255,255,.12) !important;
  box-shadow: 0 16px 40px rgba(0,0,0,.50) !important;
  object-fit: cover !important;
}

/* Mobile: còn to hơn */
@media (max-width: 900px){
  .story-cover{
    width: 360px !important;
    max-width: 92vw !important;
  }
}

@media (max-width: 480px){
  .story-cover{
    width: 92vw !important;   /* full gần hết màn */
    max-width: 92vw !important;
  }
}
/* =========================================================
   READER LIGHT MODE (NỀN TRẮNG DỄ ĐỌC)
   ========================================================= */

/* Mặc định: dark mode */
.reader-content{
  background: rgba(255,255,255,.04);
  color: #e9eef6;
}

/* LIGHT MODE cho reader */
body.reader-light .reader-content{
  background: #f9fafb !important;      /* nền giấy */
  color: #111827 !important;           /* chữ đen dịu */
  border-color: #e5e7eb !important;
}

/* Chữ trong light mode */
body.reader-light .reader-content p,
body.reader-light .reader-content span,
body.reader-light .reader-content div{
  color: #111827 !important;
}

/* Meta + badge khi light mode */
body.reader-light .rmeta,
body.reader-light .badge{
  color: #374151 !important;
  border-color: #d1d5db !important;
  background: #f3f4f6 !important;
}

/* Nút trong reader khi light */
body.reader-light .reader .btn{
  background: #ffffff !important;
  color: #111827 !important;
  border-color: #d1d5db !important;
}
body.reader-light .reader .btn.primary{
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
}

/* Tools bar light */
body.reader-light .reader-tools{
  background: rgba(249,250,251,.95) !important;
  border-bottom: 1px solid #e5e7eb !important;
}
/* ===============================
   CHAPTER NAV - COMPACT (MOBILE)
   =============================== */
@media (max-width: 900px){
  /* vùng chứa 3 nút (nếu bạn đang bọc bằng .reader-nav) */
  .reader-nav{
    display: grid !important;
    grid-template-columns: 1fr auto; /* trái: prev/next | phải: list */
    gap: 8px !important;
    margin: 10px 0 !important;
  }

  /* Nếu 3 nút đều là .btn */
  .reader-nav .btn,
  .reader-nav .pill{
    padding: 9px 10px !important;
    font-size: 14px !important;
    border-radius: 999px !important;
    min-height: 40px;
  }

  /* Nút "Danh sách chương" nhỏ gọn, nằm bên phải */
  .reader-nav .btn.list-btn,
  .reader-nav .pill.list-btn{
    width: 44px;
    padding: 0 !important;
    justify-content: center;
  }

  /* Prev/Next nằm full hàng trái */
  .reader-nav .btn.prev-btn,
  .reader-nav .pill.prev-btn,
  .reader-nav .btn.next-btn,
  .reader-nav .pill.next-btn{
    width: 100%;
  }

  /* Nếu bạn muốn "Chương sau" nằm cùng hàng với "Chương trước"
     thì dùng flex cho cụm trái (xem phần HTML gợi ý bên dưới) */
}
/* =========================================================
   CHAPTER PAGE – FULL BLEED (SÁT VIỀN MÀN HÌNH) – FINAL
   Áp dụng CHỈ trang đọc chương: <body class="chapter-page">
   ========================================================= */

body.chapter-page .container{
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Section không bo, không giữ viền 2 bên */
body.chapter-page .section{
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  margin: 0 !important;
}

/* Reader KHÔNG được max-width/margin auto nữa */
body.chapter-page .reader{
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  padding: 14px 12px !important; /* vẫn có đệm để đọc */
}

/* Khung nội dung sát viền (không border, không bo) */
body.chapter-page .reader-content{
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 16px 12px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: rgba(0,0,0,.10);
  line-height: 1.9;
  font-size: 18px;
}

/* NAV 3 nút gọn: Trước | ☰ | Sau */
body.chapter-page .reader-nav.reader-nav-compact{
  display: grid !important;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

body.chapter-page .reader-nav.reader-nav-compact .btn{
  padding: 10px 12px;
  white-space: nowrap;
}

body.chapter-page .reader-nav.reader-nav-compact .iconbtn{
  width: 46px;
  padding: 10px 0;
  justify-content: center;
  border-radius: 14px;
}

body.chapter-page .btn.is-disabled{
  opacity: .5;
  pointer-events: none;
}
/* =====================================================
   CHAPTER PAGE – ABSOLUTE FULL WIDTH (FINAL, NO GAP)
   ===================================================== */

body.chapter-page{
  margin: 0 !important;
  padding: 0 !important;
}

/* container KHÔNG giữ lề */
body.chapter-page .container{
  max-width: 100% !important;
  width: 100% !important;
  padding: 0 !important;
}

/* XÓA HOÀN TOÀN khung .section */
body.chapter-page .section{
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* reader sát viền */
body.chapter-page .reader{
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
}

/* content CHẠM MÉP MÀN HÌNH */
body.chapter-page .reader-content{
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;

  padding: 18px 14px !important; /* đệm đọc */
  border: none !important;
  border-radius: 0 !important;

  background: rgba(0,0,0,.10) !important;
}

/* meta + title không tạo khoảng hở */
body.chapter-page h1,
body.chapter-page .rmeta,
body.chapter-page .reader-nav,
body.chapter-page .reader-tools{
  padding-left: 14px;
  padding-right: 14px;
}
/* ===============================
   STORY PAGE (truyen.php) – ACTIONS UNIFORM
   =============================== */

.story-top{
  text-align: center;
}

.story-title{
  margin: 10px 0 6px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .2px;
}

.story-meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:center;
  margin-top:10px;
}

.muted-link{
  color: var(--muted);
  text-decoration: underline;
}

.story-actions{
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.story-actions .btn,
.story-actions .pill{
  width: 100%;
  min-height: 44px;
  padding: 10px 12px !important;
  border-radius: 999px !important;
  justify-content: center;
  white-space: nowrap;
}

.story-actions .btn span,
.story-actions .pill span{
  display:inline-flex;
  align-items:center;
}

.story-actions .btn span:first-child,
.story-actions .pill span:first-child{
  width: 20px;           /* khóa độ rộng icon */
  justify-content: center;
}

@media (max-width: 480px){
  .story-actions{
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .story-title{ font-size: 24px; }
}
.btn.danger{
  background: rgba(239,68,68,.16);
  border-color: rgba(239,68,68,.45);
  color: #fee2e2;
}
.btn.danger:hover{
  background: rgba(239,68,68,.26);
}
/* Layout chia cột */
.main-wrapper {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}
.content-main { flex: 3; min-width: 0; }
.sidebar-hot { flex: 1; min-width: 300px; }

/* Bảng xếp hạng Truyện Hot */
.hot-list {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 15px;
}
.hot-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.hot-item:last-child { border: none; }
.rank-number {
    font-size: 18px;
    font-weight: 800;
    color: #888;
    width: 30px;
    text-align: center;
}
.rank-1 { color: #ff4500; font-size: 22px; }
.rank-2 { color: #ff8c00; }
.rank-3 { color: #ffd700; }
.hot-info .hot-title {
    font-size: 14px;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.hot-info .hot-view { font-size: 12px; color: #666; }

/* Responsive cho Mobile */
@media (max-width: 900px) {
    .main-wrapper { flex-direction: column; }
    .sidebar-hot { width: 100%; }
}
/* Lịch sử đọc truyện */
#history-container {
    display: none; /* Ẩn đi nếu không có lịch sử */
    margin-bottom: 30px;
    background: rgba(0, 188, 212, 0.05);
    padding: 15px;
    border-radius: 16px;
    border: 1px dashed var(--primary);
}
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 10px;
}
.history-card {
    display: flex;
    gap: 10px;
    background: var(--bg-card);
    padding: 10px;
    border-radius: 10px;
    text-decoration: none;
    align-items: center;
}
.history-card img {
    width: 40px;
    height: 55px;
    object-fit: cover;
    border-radius: 6px;
}
.history-info { min-width: 0; }
.history-info .h-title {
    font-size: 13px;
    font-weight: bold;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-info .h-chap { font-size: 11px; color: var(--primary); }
/* Container của ô tìm kiếm */
.search-container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

/* Khung hiển thị kết quả gợi ý */
#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1e23;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-top: 8px;
    z-index: 1000;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: none; /* Ẩn khi không có kết quả */
}

/* Từng dòng kết quả */
.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s;
}

.suggestion-item:last-child { border: none; }
.suggestion-item:hover { background: rgba(255,255,255,0.05); }

.suggestion-item img {
    width: 35px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
}

.suggestion-info { min-width: 0; }
.suggestion-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.suggestion-author {
    font-size: 12px;
    color: #888;
}
/* Phân trang */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 30px 0;
    flex-wrap: wrap;
}
.pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}
.pagination .page-link:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination .page-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination .page-link.disabled {
    opacity: 0.3;
    pointer-events: none;
}
/* Đảm bảo Header luôn nằm trên cùng */
.site-header {
    z-index: 9999 !important;
    position: relative;
}

/* Sửa lỗi không tương tác được với Dropdown */
.dropdown {
    position: relative;
    z-index: 10000;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #1a1e23;
    min-width: 200px;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    z-index: 10001 !important; /* Đảm bảo cao hơn tất cả content bên dưới */
}

/* Hiệu ứng hover cho Desktop */
@media (min-width: 901px) {
    .dropdown:hover .dropdown-content {
        display: block !important;
    }
}

/* Đảm bảo danh sách không bị Sidebar đè */
.menubar {
    position: relative;
    z-index: 999;
}
/* Đảm bảo Header luôn ưu tiên trên mọi trang */
.site-header {
    z-index: 9999 !important;
    position: relative;
}

/* Sửa lỗi menu dropdown bị Sidebar hoặc Content đè */
.menubar {
    position: relative;
    z-index: 1000;
}

.dropdown {
    position: relative;
    z-index: 1001;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #1a1e23;
    min-width: 200px;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.6);
    z-index: 10002 !important; /* Phải cao nhất để hiển thị đè lên Grid/Sidebar */
}

/* Hiệu ứng Desktop */
@media (min-width: 901px) {
    .dropdown:hover .dropdown-content {
        display: block !important;
    }
}
/* Sửa lỗi menu Thể loại không kéo xuống được trên điện thoại */
.dropdown-content {
    max-height: 70vh; /* Giới hạn chiều cao menu bằng 70% chiều cao màn hình */
    overflow-y: auto; /* Cho phép kéo lên xuống khi danh sách quá dài */
    -webkit-overflow-scrolling: touch; /* Giúp thao tác cuộn trên điện thoại mượt mà hơn */
}

/* Tùy chỉnh thanh cuộn mini để menu nhìn gọn và đẹp hơn */
.dropdown-content::-webkit-scrollbar {
    width: 5px;
}
.dropdown-content::-webkit-scrollbar-track {
    background: #1a1a1a; 
}
.dropdown-content::-webkit-scrollbar-thumb {
    background: #444; 
    border-radius: 10px;
}
.dropdown-content::-webkit-scrollbar-thumb:hover {
    background: #00bcd4; /* Đổi màu khi chạm vào thanh cuộn */
}
.dropdown-content {
    max-height: 400px !important; /* Giới hạn chiều cao */
    overflow-y: auto !important;  /* Cho phép cuộn */
    -webkit-overflow-scrolling: touch !important; /* Vuốt mượt trên mobile */
    background-color: #1a1a1a;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
}
.void-icon { transition: transform 0.3s ease; }
.void-currency-box:hover .void-icon {
    transform: scale(1.1) rotate(5deg);
    filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.9));
}
/* =========================================
   GACHA SYSTEM UI (Giao diện Rút Hệ Thống)
========================================= */

/* 1. Nút kích hoạt trên Header (Vuông, xanh, hoa văn nhỏ) */
.sys-trigger-btn {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0288d1, #01579b);
    border: 1px solid #4fc3f7;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 15px;
    box-shadow: 0 0 10px rgba(2, 136, 209, 0.5);
    position: relative;
    transition: all 0.3s;
}
.sys-trigger-btn:hover {
    transform: scale(1.1) rotate(45deg); /* Xoay nhẹ khi di chuột */
    box-shadow: 0 0 15px #29b6f6;
}
/* Hoa văn nhỏ trên nút (dùng icon font) */
.sys-trigger-btn i {
    color: #fff;
    font-size: 18px;
    animation: pulseGlow 2s infinite;
}

/* 2. Màn hình nền mờ (Overlay) */
.gacha-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: none; /* Mặc định ẩn */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

/* 3. Bảng Gacha Chính (Xanh nước biển) */
.gacha-box {
    width: 90%;
    max-width: 500px;
    background: radial-gradient(circle, #0d47a1 0%, #002171 100%); /* Xanh biển sâu */
    border: 2px solid #29b6f6;
    border-radius: 2px;
    padding: 40px 20px;
    text-align: center;
    position: relative;
    box-shadow: 0 0 50px rgba(13, 71, 161, 0.8);
    animation: zoomIn 0.3s ease-out;
}

/* 4. Hoa văn 4 góc (Dùng CSS vẽ) */
.corner {
    position: absolute;
    width: 30px; height: 30px;
    border: 3px solid #ffd700; /* Màu vàng kim */
    transition: all 0.5s;
}
.corner-tl { top: -2px; left: -2px; border-right: none; border-bottom: none; } /* Góc Trái Trên */
.corner-tr { top: -2px; right: -2px; border-left: none; border-bottom: none; } /* Góc Phải Trên */
.corner-bl { bottom: -2px; left: -2px; border-right: none; border-top: none; } /* Góc Trái Dưới */
.corner-br { bottom: -2px; right: -2px; border-left: none; border-top: none; } /* Góc Phải Dưới */

/* Khi hover vào bảng, 4 góc co lại chút cho đẹp */
.gacha-box:hover .corner { width: 40px; height: 40px; border-color: #fff; }

/* 5. Nội dung bên trong */
.gacha-title {
    font-family: 'Cinzel', serif; /* Font kiểu thần thoại (nếu có) */
    font-size: 28px;
    font-weight: bold;
    color: #4fc3f7;
    text-transform: uppercase;
    text-shadow: 0 0 10px #0288d1;
    margin-bottom: 30px;
    letter-spacing: 2px;
    background: -webkit-linear-gradient(#fff, #4fc3f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gacha-desc {
    font-size: 16px;
    color: #e1f5fe;
    margin-bottom: 40px;
    line-height: 1.6;
}

/* 6. Nút Rút Hệ Thống */
.btn-gacha-draw {
    background: linear-gradient(180deg, #ffca28 0%, #ff6f00 100%); /* Màu vàng cam */
    color: #3e2723;
    font-size: 20px;
    font-weight: bold;
    padding: 15px 50px;
    border: 2px solid #fff;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 0 #bf360c, 0 10px 20px rgba(0,0,0,0.5);
    transition: all 0.1s;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}
.btn-gacha-draw:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #bf360c;
}
/* Hiệu ứng ánh sáng quét qua nút */
.btn-gacha-draw::after {
    content: "";
    position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0) 100%);
    transform: rotate(30deg);
    animation: shine 3s infinite;
}

/* 7. Giá tiền bên dưới */
.gacha-cost {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
}

/* Nút đóng (X) */
.gacha-close {
    position: absolute; top: 10px; right: 15px;
    color: #aaa; font-size: 24px; cursor: pointer;
}
.gacha-close:hover { color: #fff; }

@keyframes shine { 0% {left: -100%;} 20% {left: 100%;} 100% {left: 100%;} }
@keyframes pulseGlow { 0% {opacity: 0.8;} 50% {opacity: 1; text-shadow: 0 0 10px #fff;} 100% {opacity: 0.8;} }
@keyframes zoomIn { from {transform: scale(0.8); opacity: 0;} to {transform: scale(1); opacity: 1;} }