/* ================= BLUE 3D THEME ================= */
:root{
  --bg:#eaf2ff; --surface:#ffffff;
  --text:#0f172a; --muted:#475569; --border:#cfe0ff;
  --primary:#1e40af; --primary-500:#2563eb; --primary-600:#1e3a8a; --primary-50:#eff6ff;
  --ring:rgba(37,99,235,.28);
  --shadow:0 10px 24px rgba(2,6,23,.10);
  --shadow-lg:0 18px 36px rgba(2,6,23,.16);
}

/* ========== RESET ========== */
*{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
a, a:visited, a:hover, .btn, .btn *{text-decoration:none!important}

/* NỀN XANH “3D” */
body{
  font-family:Inter,system-ui,sans-serif;
  color:var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #a5b4fc 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 10%, #93c5fd 0%, transparent 55%),
    linear-gradient(180deg,#e9f0ff 0%,#dbeafe 35%,#c7d2fe 70%,#bfdbfe 100%);
  margin:0;
}

/* ========== BUTTONS ========== */
.btn{
  display:inline-flex;align-items:center;justify-content:center;
  height:44px;padding:0 18px;border:none;border-radius:12px;
  font-weight:700;font-size:14px;cursor:pointer;transition:.22s ease;
}
.btn-main{
  background:linear-gradient(135deg,var(--primary-500),var(--primary));
  color:#fff;box-shadow:0 6px 16px rgba(37,99,235,.25);
}
.btn-main:hover{transform:translateY(-1px);filter:brightness(1.06)}
.btn.secondary{background:#fff;color:var(--text);border:1px solid var(--border)}

/* ========== HEADER FULL-BLEED ========== */
.header{
  position:fixed; left:0; right:0; top:0;
  z-index:1000;
  background:rgba(255,255,255,.94);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
}
body.has-fixed-header{ padding-top: var(--header-h,72px); }

.header .container{
  max-width:none;width:100%;
  padding:12px 56px;gap:24px;
  display:grid;grid-template-columns:auto 1fr auto;align-items:center;
}
.brand{display:flex;align-items:center;gap:12px}
.brand img{width:42px;height:42px;border-radius:10px;border:1px solid var(--border)}
.brand .name{font-weight:800;color:var(--text);font-size:18px}
.brand .sub{font-size:13px;color:#64748b}
.menu{display:flex;align-items:center;gap:22px;justify-self:end}
.menu a,.menu .btn{min-width:120px;text-align:center;border-radius:10px;padding:10px 16px;font-weight:700;color:var(--text)}
.menu a:hover{background:var(--primary-50)}
.menu a.active{background:linear-gradient(135deg,#93c5fd,#bfdbfe);color:#0f172a}
.iconbar.right{justify-self:end;display:flex;align-items:center;gap:10px}

/* ICONS + POPOVER */
.iconwrap{position:relative}
.iconbtn{
  width:40px;height:40px;border:none;background:#fff0;
  display:grid;place-items:center;border-radius:10px;color:#0f172a;cursor:pointer;
}
/* Badge số trên chuông */
.iconbtn{ position:relative; }                 /* để định vị tuyệt đối */
.iconbtn .dot{
  position:absolute; top:-4px; right:-4px;
  min-width:18px; height:18px; padding:0 5px;
  background:#ef4444; color:#fff; border-radius:999px;
  font-size:11px; line-height:18px; text-align:center;
  border:2px solid #fff; pointer-events:none;
}

.iconbtn:hover{background:#eff6ff}
.popover{
  position:absolute;top:110%;right:0;width:300px;
  background:#fff;border:1px solid var(--border);border-radius:14px;
  box-shadow:0 20px 48px rgba(2,6,23,.18);
  padding:12px;z-index:1000;display:none;opacity:0;transform:translateY(-6px);
  transition:opacity .25s,transform .25s;
}
.popover::before{
  content:"";position:absolute;top:-8px;right:22px;width:12px;height:12px;
  background:#fff;border-left:1px solid var(--border);border-top:1px solid var(--border);transform:rotate(45deg);
}
/* hỗ trợ 2 cách toggle: .show hoặc .iconwrap.open */
.popover.show{display:block;opacity:1;transform:translateY(0)}
.iconwrap.open .popover{display:block;opacity:1;transform:translateY(0)}

.pv-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
.pv-head strong{font-weight:800;color:var(--text)}
.pv-head .link{border:none;background:#fff0;color:#2563eb;cursor:pointer}
#notif-list{max-height:320px;overflow:auto;display:flex;flex-direction:column;gap:8px}
.pv-item{padding:6px 8px;border-radius:10px}
.pv-item:hover{background:#f1f5ff}
.pv-title{font-weight:600;color:var(--text)}
.pv-meta{font-size:12.5px;color:#64748b}

/* PROFILE POPOVER + ĐỔI MẬT KHẨU */
.pv-user{width:360px}
.pv-user-head{display:flex;gap:10px;align-items:center;margin-bottom:10px}
.avatar.circle{
  width:56px;height:56px;border-radius:50%;border:1px solid var(--border);
  overflow:hidden;display:grid;place-items:center;background:#eff6ff
}
.pv-user .info .pv-title{font-weight:700;color:var(--text)}
.pv-user .info .pv-meta{font-size:12.5px;color:#64748b}
.pv-link{border:none;background:#fff0;color:#2563eb;cursor:pointer}
.pv-link.full{display:block;padding:8px;border-radius:10px}
.pv-link.full:hover{background:#f1f5ff}

#form-password{display:none;margin-top:8px;padding-top:8px;border-top:1px dashed var(--border)}
#form-password input[type="password"]{
  height:42px;border:1px solid var(--border);border-radius:10px;
  padding:0 12px;font-size:14px;width:100%;
}
#form-password .actions{display:flex;gap:8px;justify-content:flex-end;margin-top:10px}
#form-password .btn{height:40px;padding:0 14px;border-radius:10px}

/* ========== SEARCH HEADER CENTER ========== */
.search-header{padding:28px 16px 12px;text-align:center;animation:pageIn .28s ease-out}
.search-header h1{font-size:34px;margin-bottom:8px}
.searchbar{max-width:720px;margin:0 auto 12px;position:relative}
.searchbar input{
  width:100%;height:46px;border:1px solid var(--border);border-radius:12px;
  background:#fff;padding:0 40px 0 14px;font-size:15px
}
.searchbar .icon{position:absolute;right:12px;top:50%;transform:translateY(-50%)}
.chips{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.chip{padding:6px 14px;border-radius:999px;border:1px solid var(--border);background:#fff;color:var(--text)}
.chip.active{background:linear-gradient(135deg,#93c5fd,#60a5fa);color:#0f172a;border:none}

/* === Gallery: giống ngoài (8-6-4-3-2 cột), tên KHÔNG đậm === */
.gallery{ padding:10px 20px 60px; }
.grid{
  max-width:1280px;
  margin:0 auto;
  display:grid;
  gap:18px;
  align-items:start; /* thêm dòng này để các ô bám theo đầu hàng */
}
@media (min-width:1400px){ .grid{ grid-template-columns:repeat(8,1fr); } }
@media (min-width:1100px) and (max-width:1399.98px){ .grid{ grid-template-columns:repeat(6,1fr); } }
@media (min-width:820px) and (max-width:1099.98px){ .grid{ grid-template-columns:repeat(4,1fr); } }
@media (min-width:600px) and (max-width:819.98px){ .grid{ grid-template-columns:repeat(3,1fr); } }
@media (max-width:599.98px){ .grid{ grid-template-columns:repeat(2,1fr); } }

.gallery .title{
  margin-top:8px;
  font-size:14.5px;
  font-weight:400;
  text-align:center;
  width:100%;
  height:40px;              /* cố định vùng chứa tên */
  line-height:1.3;
  overflow:hidden;          /* ẩn chữ dư */
  text-overflow:ellipsis;
  display:-webkit-box;
  -webkit-line-clamp:2;     /* hiển thị tối đa 2 dòng */
  -webkit-box-orient:vertical;
  white-space:normal;       /* cho phép xuống dòng */
}

.gallery .cover img{
  width:100%; aspect-ratio:3/4; object-fit:cover; border-radius:10px;
  box-shadow:0 6px 18px rgba(2,6,23,.12);
}

/* Tránh xung đột với tiêu đề thẻ .card */
.card > .title{
  color:var(--text); font-size:22px; font-weight:800; text-align:center; margin-bottom:10px;
}



.item{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start; /* thêm dòng này */
  height:100%; /* giữ chiều cao đều */
}
.cover{
  width:100%;
  aspect-ratio:3/4; /* cố định tỉ lệ khung */
  overflow:hidden;
  border-radius:12px;
  display:block;
  background:#fff;
}

.cover img{
  width:100%;
  height:100%;
  object-fit:cover; /* quan trọng: ép khít khung */
  border-radius:12px;
  box-shadow:0 10px 22px rgba(2,6,23,.12);
  transition:transform .22s ease, box-shadow .22s ease;
}
.cover:hover img{transform:translateY(-3px);box-shadow:0 20px 44px rgba(2,6,23,.20)}
.title{
  margin-top:10px;font-size:16px;font-weight:400;
  line-height:1;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;
}

/* ========== AUTH ========== */
.auth-page{min-height:auto;display:flex;align-items:center;justify-content:center;padding:24px}
.glass-card{background:rgba(255,255,255,.95);border:1px solid var(--border);border-radius:18px;box-shadow:var(--shadow-lg);backdrop-filter:blur(10px);padding:28px 26px 34px;width:min(420px,90vw);text-align:center}
.login-logo{display:flex;flex-direction:column;align-items:center;gap:8px;margin-bottom:8px}
.logo-lg{width:84px;height:84px;object-fit:contain;filter:drop-shadow(0 6px 12px rgba(30,64,175,.25))}
.lead{color:#64748b;font-size:14px;margin-bottom:8px}
.form{display:flex;flex-direction:column;gap:14px;margin-top:10px}
.input{width:100%;max-width:360px;height:46px;border:1px solid var(--border);border-radius:12px;background:#fff;padding:0 14px;font-size:15px;transition:.2s;margin:0 auto;display:block}
.input:focus{border-color:#bfdbfe;box-shadow:0 0 0 3px var(--ring)}

/* ========== BOOK DETAIL ========== */
.book-detail{
  max-width:1080px;margin:28px auto;padding:26px;background:#fff;
  border:1px solid var(--border);border-radius:18px;box-shadow:var(--shadow);
  display:grid;grid-template-columns:300px 1fr;gap:24px;
}
.book-cover-lg{width:300px;aspect-ratio:3/4;object-fit:cover;border-radius:12px;border:1px solid var(--border);box-shadow:0 10px 22px rgba(30,64,175,.18)}
.bd-title{font-size:30px;font-weight:800;margin:2px 0 8px}
.bd-meta{display:grid;grid-template-columns:repeat(2,minmax(260px,1fr));gap:8px 18px;font-size:16px;color:#334155;margin:8px 0 2px}
.bd-meta li{list-style:none}
.bd-desc{margin-top:12px;font-size:16px;line-height:1.7}
.book-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:16px}
.price-note{font-size:14px;color:#334155;margin-top:12px}
@media(max-width:880px){.book-detail{grid-template-columns:1fr}.book-cover-lg{width:100%}}

/* ========== TABLES / BADGES / PAGINATION / CARD ========== */
.card{background:#fff;border:1px solid var(--border);border-radius:14px;padding:20px 24px;box-shadow:var(--shadow)}
.title{color:var(--text);font-size:22px;font-weight:800;text-align:center;margin-bottom:10px}
.badge{border-radius:999px;padding:4px 10px;font-size:12px;font-weight:600}
.badge.cho_xac_nhan{background:#eff6ff;color:#1d4ed8}
.badge.da_tra{background:#e0f2fe;color:#0ea5e9}
.badge.dang_muon{background:#e8f5e9;color:#166534}
.badge.bi_huy{background:#fee2e2;color:#b91c1c}
.pg{padding:6px 12px;border:1px solid var(--border);border-radius:10px;text-decoration:none;color:#0f172a;background:#fff;font-size:13.5px}
.pg.active{background:#eff6ff;font-weight:700}
.pg.disabled{pointer-events:none;opacity:.5}

/* ========== FOOTER ========== */
.footer{text-align:center;padding:20px 0 30px;font-size:15px;color:#334155;background:transparent}
.footer .contact{display:flex;justify-content:center;flex-wrap:wrap;gap:14px;margin-bottom:6px}
.footer .contact a{color:var(--primary-500)}

/* ========== CHAT TOÀN XANH ========== */
#fab-chat,.fab-chat{
  position:fixed;right:22px;bottom:22px;width:52px;height:52px;border-radius:50%;
  display:grid;place-items:center;border:none;cursor:pointer;
  background:linear-gradient(135deg,#2563eb,#1e40af)!important;color:#fff!important;
  box-shadow:0 10px 24px rgba(37,99,235,.28)!important;z-index:9997;
}
.chatbox{
  position:fixed;right:22px;bottom:82px;width:340px;border-radius:16px;
  border:1px solid var(--border)!important;background:rgba(255,255,255,.98)!important;
  box-shadow:0 22px 48px rgba(2,6,23,.22)!important;backdrop-filter:blur(8px);z-index:9999;
}
.chatbox[aria-hidden="true"]{display:none!important}
.cb-head{
  display:flex;justify-content:space-between;align-items:center;padding:10px 12px;
  background:linear-gradient(180deg,#eef2ff,transparent)!important;
  color:#0f172a!important;border-bottom:1px solid var(--border)!important;font-weight:700;
}
.cb-close{
  width:28px;height:28px;border-radius:50%;border:1px solid var(--border);background:#fff;color:#0f172a;
  display:grid;place-items:center;cursor:pointer;
}
.cb-close:hover{background:#eff6ff}
.cb-body{padding:10px;height:280px;overflow:auto;display:flex;flex-direction:column;gap:8px}
.cb-body .msg{max-width:78%;padding:8px 10px;border-radius:12px;border:1px solid var(--border);background:#fff;white-space:pre-wrap}
.cb-body .msg.me{margin-left:auto;background:#eff6ff!important;border-color:#bfdbfe!important}
.cb-input{display:flex;border-top:1px solid var(--border)}
#cb-textarea{flex:1;border:1px solid var(--border);border-radius:10px;padding:10px;background:#fff;min-height:44px;max-height:140px;resize:none}
.cb-input button.btn{background:linear-gradient(135deg,#2563eb,#1e40af)!important;color:#fff!important}

/* Chat chooser */
.chat-chooser[aria-hidden="true"]{display:none!important}
.chooser-panel{border:1px solid var(--border)!important;border-radius:16px;background:#fff;box-shadow:0 16px 36px rgba(2,6,23,.2)!important}
.chooser-panel .btn{background:linear-gradient(135deg,#2563eb,#1e40af)!important;color:#fff!important}
.chooser-panel .btn.secondary{background:#fff!important;color:#0f172a!important;border:1px solid var(--border)!important}

/* ========== ANIMATION ========== */
.header,.main{animation:none!important}
@keyframes pageIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}

/* ===== Common page card + toolbars ===== */
.card--page{max-width:1100px;margin:18px auto}
.toolbar{display:flex;gap:10px;flex-wrap:wrap;align-items:center}

/* Meta + empty */
.pv-meta{color:#64748b;font-size:14px}
.pv-empty{color:#64748b;text-align:center;padding:14px}

/* ===== Reader (PDF) ===== */
.pdf-wrap{
  border:1px solid var(--border);border-radius:12px;background:#fff;
  height:80vh;overflow:auto;overflow-x:hidden;padding:14px;
  box-shadow:inset 0 0 6px rgba(2,6,23,.04)
}
.pdf-wrap canvas{width:100%;height:auto;border-radius:8px;box-shadow:0 2px 8px rgba(2,6,23,.08);background:#fff}
.pdf-wrap::-webkit-scrollbar{width:8px}
.pdf-wrap::-webkit-scrollbar-thumb{background:#cfe0ff;border-radius:4px}

/* ===== Payment boxes ===== */
.pay-box{
  margin:0 auto 24px;max-width:460px;border:1px solid var(--border);
  border-radius:14px;padding:16px 20px;background:#f6f8ff;text-align:center
}

/* ===== Profile form ===== */
.form-grid{display:grid;gap:12px;grid-template-columns:1fr 1fr}
@media(max-width:720px){.form-grid{grid-template-columns:1fr}}
form.card input,form.card select{
  height:46px;border:1px solid var(--border);border-radius:12px;
  padding:0 14px;font-size:15px;width:100%;background:#fff
}
form.card input.readonly{background:#f8fafc}
.actions{display:flex;gap:8px;justify-content:flex-end}
/* ===== STAFF TABLES ===== */
.pv-table{ width:100%; border-collapse:collapse; margin-top:8px }
.pv-table th{
  background:#f8fbff; color:#0f172a; font-weight:700;
  padding:10px 8px; border-bottom:1px solid var(--border); text-align:left
}
.pv-table td{
  padding:10px 8px; border-top:1px solid var(--border); vertical-align:middle
}
.pv-table tbody tr:hover{ background:#f5faff }

/* Pager thống nhất */
.pager{ display:flex; gap:8px; justify-content:center; align-items:center; margin:14px 0; flex-wrap:wrap }
.pg{ padding:6px 12px; border:1px solid var(--border); border-radius:10px; background:#fff; color:#0f172a; text-decoration:none; font-size:13.5px }
.pg.active{ background:#eff6ff; font-weight:700 }
.pg.disabled{ pointer-events:none; opacity:.5 }
