/* ==========================================================================
   MONO — style.css
   Mục lục:
   1. Biến màu & chế độ sáng/tối
   2. Reset & nền tảng
   3. Bố cục chung (container, lưới, hộp, bảng)
   4. Header: logo, thanh điều hướng, nút biểu tượng, avatar
   5. Tìm kiếm & gợi ý
   6. Nút bấm
   7. Biểu mẫu (ô nhập, mật khẩu, lỗi, chip, màu)
   8. Trang chủ: hero, băng chuyền bộ sưu tập, danh mục, khuyến mãi
   9. Thẻ sản phẩm
  10. Trang danh sách sản phẩm & bộ lọc
  11. Trang chi tiết sản phẩm
  12. Giỏ hàng & thanh toán
  13. Tài khoản & đơn hàng (huy hiệu trạng thái)
  14. Trang quản trị (admin): tab, thống kê, biểu đồ, cửa sổ sửa
  15. Footer
  16. Thông báo (toast) & trạng thái rỗng
  17. Responsive: máy tính bảng & điện thoại
   ========================================================================== */


/* ==========================================================================
   1. BIẾN MÀU & CHẾ ĐỘ SÁNG/TỐI
   ========================================================================== */
:root {
  --bg: #fff; --bg2: #f5f5f4; --fg: #111; --mut: #6b6b6b; --line: #e5e5e3;
  --acc: #b4532a; --ok: #2f7d4f; --bad: #c0392b; --card: #fff;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212; --bg2: #1c1c1b; --fg: #f2f2f0; --mut: #a0a09b; --line: #2e2e2c;
    --acc: #e08a5f; --ok: #58b880; --bad: #e5695a; --card: #181817; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212; --bg2: #1c1c1b; --fg: #f2f2f0; --mut: #a0a09b; --line: #2e2e2c;
  --acc: #e08a5f; --ok: #58b880; --bad: #e5695a; --card: #181817; color-scheme: dark;
}


/* ==========================================================================
   2. RESET & NỀN TẢNG
   ========================================================================== */
* { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 22px; margin-top: 40px; }
mark { background: none; color: var(--acc); font-weight: 700; }
.mut { color: var(--mut); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--bg); padding: 8px; z-index: 99; }
.lnk { cursor: pointer; color: var(--mut); }
.lnk:hover { color: var(--fg); }


/* ==========================================================================
   3. BỐ CỤC CHUNG
   ========================================================================== */
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.row  { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.box  { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--card); }
.two  { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
.two.eq { grid-template-columns: 1fr 1fr; }
.tw   { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }


/* ==========================================================================
   4. HEADER: LOGO, THANH ĐIỀU HƯỚNG, NÚT BIỂU TƯỢNG, AVATAR
   ========================================================================== */
header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; gap: 14px; height: 56px; }
.sp  { flex: 1; }
.logo { font-weight: 800; letter-spacing: .18em; font-size: 18px; cursor: pointer; }

/* Thanh điều hướng: mọi mục cùng chiều cao, cùng độ rộng tối thiểu, canh giữa */
nav { display: flex; align-items: stretch; align-self: stretch; gap: 4px; margin-left: 12px; }
nav a {
  display: flex; align-items: center; justify-content: center;
  min-width: 112px; padding: 0 16px;
  color: var(--mut); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav a:hover { color: var(--fg); }
nav a.on { color: var(--fg); font-weight: 700; border-bottom-color: var(--acc); }

.burger { display: none; }
.ib {
  background: none; border: 0; cursor: pointer; position: relative;
  font-size: 19px; padding: 6px; min-width: 40px; min-height: 40px; color: var(--fg);
}
.cnt {
  position: absolute; top: 0; right: 0; background: var(--acc); color: #fff;
  border-radius: 9px; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; text-align: center;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--mut); color: #fff; font-weight: 700; font-size: 15px; line-height: 1;
}


/* ==========================================================================
   5. TÌM KIẾM & GỢI Ý
   ========================================================================== */
.sbox { position: relative; width: 230px; }
.srch { width: 100%; }
.sug {
  position: absolute; top: calc(100% + 8px); right: 0; width: min(92vw, 380px);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px #0003; padding: 6px 0; z-index: 40; max-height: 70vh; overflow: auto;
}
.sg { display: flex; gap: 10px; align-items: center; padding: 8px 12px; cursor: pointer; }
.sg:hover, .sg.act { background: var(--bg2); }
.sg img { width: 40px; height: 50px; object-fit: cover; border-radius: 6px; }
.sg-h { padding: 8px 12px 4px; font-size: 12px; color: var(--mut); text-transform: uppercase; letter-spacing: .06em; }
.sg.all { border-top: 1px solid var(--line); font-weight: 600; color: var(--acc); margin-top: 4px; }


/* ==========================================================================
   6. NÚT BẤM
   ========================================================================== */
.btn {
  background: var(--fg); color: var(--bg); border: 1px solid var(--fg);
  border-radius: 8px; padding: 10px 18px; cursor: pointer; font-weight: 600; min-height: 42px;
}
.btn.o { background: none; color: var(--fg); border-color: var(--line); }
.btn.s { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn.d { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }


/* ==========================================================================
   7. BIỂU MẪU
   ========================================================================== */
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; width: 100%;
}
.fld { margin-bottom: 10px; }
.fld label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* Ô mật khẩu có nút Hiện/Ẩn */
.pw { position: relative; }
.pw input { padding-right: 64px; }
.eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; color: var(--mut);
  font-size: 13px; font-weight: 600; padding: 6px 8px; border-radius: 6px;
}
.eye:hover { color: var(--fg); }

/* Chip (size, phân trang, tab) và ô chọn màu */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; min-height: 36px;
}
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip.x { opacity: .4; text-decoration: line-through; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.sw.on { outline: 2px solid var(--acc); outline-offset: 2px; }


/* ==========================================================================
   8. TRANG CHỦ: HERO, BĂNG CHUYỀN, DANH MỤC, KHUYẾN MÃI
   ========================================================================== */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: center; padding: 32px 0; }
.hero h1 { font-size: clamp(30px, 5vw, 52px); letter-spacing: -.02em; }
.hero p { color: var(--mut); max-width: 44ch; }

/* Băng chuyền bộ sưu tập (chữ hòa vào ảnh bằng lớp tối nhẹ ở đáy) */
.car { position: relative; overflow: hidden; border-radius: 14px; background: var(--bg2); min-width: 0; }
.trk { display: flex; transition: transform .6s ease; }
.sl  { min-width: 100%; position: relative; cursor: pointer; }
.sl img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.sl::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 55%;
  background: linear-gradient(to top, #000b, #0000); pointer-events: none;
}
.cap { position: absolute; left: 20px; right: 60px; bottom: 40px; z-index: 1; color: #fff; text-shadow: 0 1px 6px #0006; pointer-events: none; }
.cap span { font-size: 12px; opacity: .85; text-transform: uppercase; letter-spacing: .12em; }
.cap h3 { margin: 4px 0 0; font-size: clamp(22px, 3.2vw, 32px); letter-spacing: -.01em; }
.cb {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg);
  cursor: pointer; font-size: 22px; line-height: 1; box-shadow: 0 2px 8px #0003;
}
.pv { left: 10px; }
.nx { right: 10px; }
.dots { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; gap: 8px; }
.dots button { width: 9px; height: 9px; border-radius: 50%; border: 0; background: #fffa; padding: 0; cursor: pointer; transition: width .25s; }
.dots button.on { background: var(--acc); width: 22px; border-radius: 5px; }

/* Thẻ danh mục */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.cat { position: relative; cursor: pointer; border-radius: 12px; overflow: hidden; }
.cat img { aspect-ratio: 4 / 5; object-fit: cover; width: 100%; }
.cat b { position: absolute; left: 12px; bottom: 10px; background: var(--bg); padding: 4px 10px; border-radius: 6px; }

/* Banner khuyến mãi */
.promo {
  background: var(--fg); color: var(--bg); border-radius: 14px; padding: 28px; margin-top: 40px;
  display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap;
}
.promo .btn { background: var(--bg); color: var(--fg); }


/* ==========================================================================
   9. THẺ SẢN PHẨM
   ========================================================================== */
.card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 6px 20px #0002; }
.ph { position: relative; aspect-ratio: 4 / 5; cursor: pointer; background: var(--bg2); }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .25s; }
.ph img + img { opacity: 0; }
.ph:hover img + img { opacity: 1; }
.tag { position: absolute; top: 10px; left: 10px; background: var(--acc); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 5px; z-index: 2; }
.tag.g { background: #555; left: auto; right: 10px; top: auto; bottom: 10px; }
.heart {
  position: absolute; top: 6px; right: 6px; z-index: 2; width: 36px; height: 36px;
  background: var(--bg); border-radius: 50%; border: 0; cursor: pointer; font-size: 17px;
}
.ci { padding: 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.ci .nm { font-weight: 600; cursor: pointer; }
.pr b { font-size: 16px; }
.pr s { color: var(--mut); margin-left: 6px; font-size: 13px; }
.st { color: #d49a1f; font-size: 13px; }


/* ==========================================================================
  10. TRANG DANH SÁCH SẢN PHẨM & BỘ LỌC
   ========================================================================== */
.lay { display: grid; grid-template-columns: 240px 1fr; gap: 28px; margin-top: 20px; }
.side label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13px; }
.pag { display: flex; gap: 6px; justify-content: center; margin: 28px 0; }


/* ==========================================================================
  11. TRANG CHI TIẾT SẢN PHẨM
   ========================================================================== */
.det { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 20px; }
.det .big { border-radius: 12px; aspect-ratio: 4 / 5; object-fit: cover; width: 100%; }
.th { display: flex; gap: 8px; margin-top: 8px; }
.th img { width: 64px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.th img.on { border-color: var(--fg); }


/* ==========================================================================
  12. GIỎ HÀNG & THANH TOÁN
   (dùng lại .two, .box, table, .fld, .f2 ở các phần trên)
   ========================================================================== */


/* ==========================================================================
  13. TÀI KHOẢN & ĐƠN HÀNG
   ========================================================================== */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: var(--bg2); border: 1px solid var(--line); }
.badge.c4 { color: var(--ok); }
.badge.c5 { color: var(--bad); }


/* ==========================================================================
  14. TRANG QUẢN TRỊ (ADMIN)
   ========================================================================== */
.tabs { display: flex; gap: 6px; margin: 20px 0; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stats b { font-size: 24px; display: block; }
.bars { display: flex; gap: 10px; align-items: flex-end; height: 150px; }
.bars div { flex: 1; text-align: center; font-size: 11px; color: var(--mut); }
.bars i { display: block; background: var(--acc); border-radius: 4px 4px 0 0; margin-bottom: 4px; }

/* Cửa sổ thêm/sửa sản phẩm */
.ov { position: fixed; inset: 0; background: #0008; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.md { background: var(--bg); border-radius: 14px; padding: 20px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; }


/* ==========================================================================
  15. FOOTER
   ========================================================================== */
footer { margin-top: 60px; border-top: 1px solid var(--line); background: var(--bg2); padding: 36px 0 20px; }
.fg { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; }
.fg h4 { margin: 0 0 8px; }
.fg p, .fg li { color: var(--mut); margin: 4px 0; }
.fg ul { list-style: none; padding: 0; margin: 0; }


/* ==========================================================================
  16. THÔNG BÁO (TOAST) & TRẠNG THÁI RỖNG
   ========================================================================== */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 99;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 9px;
  display: none; max-width: 90vw;
}
.empty { text-align: center; padding: 60px 16px; color: var(--mut); }


/* ==========================================================================
  17. RESPONSIVE
   ========================================================================== */
@media (min-width: 861px) {
  .mo { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .trk, .dots button { transition: none; }
}
@media (max-width: 860px) {
  /* Header + điều hướng dạng menu thả xuống */
  .bar { gap: 4px; }
  .sp { display: none; }
  .logo { font-size: 16px; }
  .burger { display: inline-block; }
  .sbox { flex: 1; min-width: 0; width: auto; }
  nav { display: none; }
  nav.open {
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    position: absolute; top: 56px; left: 0; right: 0;
    background: var(--bg); padding: 10px 16px; border-bottom: 1px solid var(--line);
  }
  nav.open a { min-width: 0; justify-content: flex-start; padding: 12px 0; border-bottom: 0; }
  nav.open a.on { color: var(--acc); }

  /* Bố cục nhiều cột thành một cột */
  .hero, .det, .two, .two.eq { grid-template-columns: 1fr; }
  .car { order: -1; }
  .sl img { aspect-ratio: 4 / 3; }
  .lay { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .fg { grid-template-columns: 1fr 1fr; }
  .f2 { grid-template-columns: 1fr; }

  /* Bộ lọc thành ngăn kéo toàn màn hình */
  .side { display: none; }
  .side.open { display: block; position: fixed; inset: 0; background: var(--bg); z-index: 60; padding: 20px; overflow: auto; }
}
