/* Trang Sản phẩm bán chạy (/tiktok-shop-bestselling).
   Trước là block <style> inline trong PHP (hero đen + accent hồng TikTok). Nay tông cam như
   trang chính; phần chung với Tìm SP / Video / LIVE (huy hiệu hạng, nhãn hoa hồng, bảng,
   trạng thái rỗng/lỗi/đang tải) ở tiktok-shop-product-discovery-shared.css.

   ⚠ <link> file này SAU tiktok-shop-mobile.css: block mobile (bảng → thẻ) cần thắng
   `td { overflow-wrap:anywhere }` của file đó — bản cũ bị bóp còn 1 ký tự/dòng ở cột Shop. */

/* Nền cam nhạt đặt sẵn (app không nạp subpage-hero.css; app-view.css tự gỡ nền hero). */
.tts-hero { background:linear-gradient(135deg,#fff7ed 0%,#ffedd5 100%); border:1px solid #fed7aa; color:#111827; border-radius:16px; padding:20px 24px; margin-bottom:16px; position:relative; overflow:hidden; }
.tts-hero h1 > .bi:first-child { color:#ea580c; }
.tts-hero h1 { font-size:1.4rem; font-weight:800; margin:0 0 4px; }
.tts-hero p  { font-size:.86rem; margin:0; color:#6b7280; }

/* ─── Lưới thẻ ─── */
.bs-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:14px; }
.bs-card { background:#fff; overflow:hidden; display:flex; flex-direction:column; transition:box-shadow .18s, transform .18s; }
.bs-card:hover { transform:translateY(-2px); }
.bs-thumb { position:relative; aspect-ratio:1/1; background:#f6f7f9; overflow:hidden; }
.bs-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.bs-thumb .ph { width:100%; height:100%; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,#fff7ed,#ffedd5); color:#fdba74; font-size:2rem; }
.bs-rank { position:absolute; top:8px; left:8px; display:inline-flex; align-items:center; justify-content:center; min-width:30px; height:28px; padding:0 8px; border-radius:9px; font-weight:800; font-size:.82rem; color:#fff; backdrop-filter:blur(3px); }
.bs-mv-ov { position:absolute; top:8px; right:8px; }
.bs-mv-ov .mv { box-shadow:0 1px 3px rgba(0,0,0,.12); }
.bs-body { padding:11px 12px 12px; display:flex; flex-direction:column; gap:6px; flex:1; }
.bs-name { font-size:.84rem; font-weight:600; line-height:1.35; color:#111827; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; min-height:2.7em; }
.bs-shop { font-size:.72rem; color:#9ca3af; display:flex; align-items:center; gap:4px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.bs-earn { display:flex; align-items:center; min-height:1.6em; }
.bs-meta { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:auto; }
.bs-gmv { display:flex; flex-direction:column; min-width:0; }
.bs-gmv .v { font-size:.9rem; font-weight:800; color:#15803d; line-height:1.15; white-space:nowrap; }
.bs-gmv .l { font-size:.6rem; color:#9ca3af; text-transform:uppercase; letter-spacing:.4px; }
.bs-rating { display:inline-flex; align-items:center; gap:3px; font-size:.78rem; font-weight:700; color:#f59e0b; white-space:nowrap; }
.bs-actions { display:flex; gap:6px; margin-top:2px; }
.bs-actions .btn { height:36px; min-height:36px; padding:0 10px; font-size:.8rem; border-radius:10px; display:inline-flex; align-items:center; justify-content:center; }
.bs-actions .btn:first-child { flex:1; min-width:0; }
.bs-actions .btn:last-child { flex:0 0 38px; padding:0; }

/* ─── Bảng ─── */
.bs-row:hover > td { background:#fffaf5; }
.rank-badge { display:inline-flex; align-items:center; justify-content:center; width:30px; height:30px; font-weight:800; font-size:.85rem; }
.bs-tbl-thumb { width:44px; height:44px; border-radius:10px; object-fit:cover; background:#f6f7f9; flex:0 0 auto; }
.bs-tbl-name { display:flex; align-items:center; gap:10px; min-width:220px; }
.bs-tbl-name .nm { font-weight:600; font-size:.82rem; line-height:1.3; color:#111827; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.bsr-shop { color:#6b7280; max-width:180px; }
.bsr-shop-nm { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bsr-table > tbody > tr > td.bsr-star-cell { color:#f59e0b; font-weight:700; white-space:nowrap; }
.bsr-act .btn { height:32px; min-height:32px; padding:0 10px; font-size:.76rem; border-radius:9px; display:inline-flex; align-items:center; }

/* Biến động hạng (▲/▼/MỚI so với hôm qua) */
.mv { display:inline-flex; align-items:center; gap:2px; font-size:.72rem; font-weight:800; padding:2px 7px; border-radius:20px; line-height:1.1; }
.mv-up   { color:#15803d; background:#dcfce7; }
.mv-down { color:#b91c1c; background:#fee2e2; }
.mv-flat { color:#9ca3af; background:#f3f4f6; }

/* ─── Dải "Tăng hạng mạnh" + "Mới vào bảng" ─── */
.mvr { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px; margin-bottom:16px; align-items:start; }
.mvr-col { min-width:0; background:#fff; padding:12px; }
.mvr-h { font-size:.82rem; font-weight:800; color:#111827; margin-bottom:8px; display:flex; align-items:center; gap:6px; }
/* Tối đa ~5 dòng rồi cuộn trong khung: 20 mục mỗi cột đẩy bảng chính xuống quá xa trên mobile. */
.mvr-list { max-height:200px; overflow-y:auto; overscroll-behavior:contain; margin-right:-4px; padding-right:4px; }
.mvr-chip { display:flex; align-items:center; gap:8px; width:100%; min-width:0; text-align:left; background:#fafafa; border:1px solid #f1f2f4; border-radius:10px; padding:6px 9px; margin-bottom:6px; cursor:pointer; transition:.15s; }
.mvr-chip:last-child { margin-bottom:0; }
.mvr-chip:hover { background:#fff7ed; border-color:#fed7aa; }
.mvr-chip .mvr-rank { font-weight:800; font-size:.75rem; color:#ea580c; flex:0 0 auto; min-width:30px; }
.mvr-chip .mvr-nm { flex:1; min-width:0; font-size:.78rem; font-weight:600; color:#374151; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mvr-chip .mvr-tag { flex:0 0 auto; font-size:.68rem; font-weight:800; color:#15803d; }
.mvr-hint { padding:6px 2px; }
#bsMovers > .mvr-hint { background:#fff7ed; border:1px dashed #fed7aa; border-radius:12px; padding:9px 12px; margin-bottom:14px; color:#9a3412 !important; }

/* ─── Modal: đầu thông tin sản phẩm ─── */
#bsChartModal .modal-content { border:0; border-radius:16px; }
#bsChartModal .modal-header { border-bottom-color:#f3f4f6; }
.bsh { display:flex; flex-direction:column; gap:12px; padding-bottom:14px; margin-bottom:14px; border-bottom:1px solid #f3f4f6; }
.bsh-top { display:flex; gap:14px; align-items:flex-start; }
.bsh-thumb { position:relative; width:88px; height:88px; flex:0 0 auto; border-radius:12px; overflow:hidden; background:#f6f7f9; }
.bsh-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.bsh-thumb .ph { width:100%; height:100%; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,#fff7ed,#ffedd5); color:#fdba74; font-size:1.8rem; }
.bsh-rank { position:absolute; top:6px; left:6px; width:auto; min-width:26px; height:24px; padding:0 6px; font-size:.72rem; }
.bsh-head { flex:1; min-width:0; display:flex; flex-direction:column; gap:6px; }
.bsh-name { font-size:.92rem; font-weight:700; line-height:1.35; color:#111827; text-decoration:none; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.bsh-name:hover { color:#ea580c; }
.bsh-name i { font-size:.72rem; color:#9ca3af; }
.bsh-shop { font-size:.76rem; color:#6b7280; display:flex; align-items:center; gap:5px; }
.bsh-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(110px,1fr)); gap:8px; }
.bsh-stat { background:#f9fafb; border:1px solid #f3f4f6; border-radius:10px; padding:8px 11px; display:flex; flex-direction:column; gap:3px; min-width:0; }
.bsh-stat .l { font-size:.64rem; color:#6b7280; text-transform:uppercase; letter-spacing:.3px; }
.bsh-stat .v { font-size:.9rem; font-weight:800; color:#111827; display:inline-flex; align-items:center; gap:4px; flex-wrap:wrap; }
.bsh-rate { color:#ea580c; }
.bsh-actions { display:flex; flex-wrap:wrap; gap:8px; }
.bsh-actions .btn { flex:1 1 auto; font-size:.8rem; height:40px; min-height:40px; display:inline-flex; align-items:center; justify-content:center; border-radius:10px; }

/* ─── Modal: biểu đồ 30 ngày ─── */
.bsc-stat { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:14px; }
.bsc-stat > div { background:#f9fafb; border:1px solid #f3f4f6; border-radius:10px; padding:9px 11px; display:flex; flex-direction:column; gap:3px; min-width:0; }
.bsc-stat .l { font-size:.64rem; color:#6b7280; text-transform:uppercase; letter-spacing:.3px; }
.bsc-stat .v { font-size:.92rem; font-weight:800; color:#111827; }
.bsc-chart { position:relative; margin-top:12px; background:#fff; border:1px solid #eef0f3; border-radius:12px; padding:12px 12px 8px; }
.bsc-cap { font-size:.8rem; font-weight:700; color:#374151; margin-bottom:8px; display:flex; align-items:center; flex-wrap:wrap; }
.bsc-cap .bi { color:#ea580c; }
.bsc-hint { font-weight:500; color:#9ca3af; margin-left:5px; font-size:.72rem; }
.bsc-chart svg text { font-family:inherit; }
.bsc-svg .bsc-hit { cursor:crosshair; }
/* Tooltip bám con trỏ */
.bsc-tip { position:absolute; z-index:5; pointer-events:none; background:#111827; color:#fff; border-radius:8px; padding:5px 9px; font-size:.72rem; line-height:1.35; white-space:nowrap; box-shadow:0 4px 14px rgba(0,0,0,.22); transition:opacity .1s; display:flex; flex-direction:column; }
.bsc-tip .d { color:rgba(255,255,255,.7); font-size:.64rem; }
.bsc-tip .n { font-weight:800; font-size:.82rem; }

/* ═══ MOBILE ═══════════════════════════════════════════════════════ */
@media (max-width:575.98px) {
    .tts-hero { padding:14px 16px; margin-bottom:12px; }
    .tts-hero h1 { font-size:1.1rem; }
    .tts-hero p { font-size:.78rem; line-height:1.4; }

    /* Tiêu đề khu + thanh công cụ: 1 hàng, control cao 38px */
    .bs-head { margin-bottom:10px !important; row-gap:8px !important; }
    .bs-head small { font-size:.72rem; }
    .bs-toolbar { width:100%; flex-wrap:nowrap !important; gap:6px !important; }
    .bs-toolbar .form-select { flex:1 1 auto; width:auto !important; min-width:0; height:38px; min-height:38px; padding:0 30px 0 12px; font-size:16px; background-position:right 10px center; }
    .bs-toolbar .btn { min-height:38px; height:38px; min-width:40px; padding:0 11px; font-size:.95rem; }

    .mvr { grid-template-columns:1fr; gap:8px; margin-bottom:12px; }
    .mvr-col { padding:10px; }
    .mvr-list { max-height:150px; }

    /* ─── Bảng → danh sách thẻ (CSS grid trên từng <tr>) ───
       [hạng][ảnh + tên ............................]
       [ 24h][GMV ................][hoa hồng]
       [    ][shop · ★ ...........][Tạo link][↗] */
    .bsr-wrap { overflow:visible; }
    .bsr-table > thead { display:none; }
    .bsr-table, .bsr-table > tbody { display:block; width:100%; }
    .bsr-table > tbody > tr {
        display:grid; grid-template-columns:34px minmax(0,1fr) auto;
        grid-template-areas:"rank prod prod" "mv gmv rate" ". shop act";
        column-gap:8px; row-gap:6px; align-items:center;
        background:#fff; border:1px solid #eef0f3; border-radius:12px; box-shadow:0 1px 2px rgba(17,24,39,.04);
        padding:10px; margin-bottom:8px;
    }
    .bsr-table > tbody > tr > td { display:block; padding:0; border:0; background:transparent !important; box-shadow:none; text-align:left !important; overflow-wrap:normal; min-width:0; }
    .bsr-table > tbody > tr > td.bsr-rank { grid-area:rank; align-self:start; }
    .bsr-table > tbody > tr > td.bsr-mv { grid-area:mv; justify-self:center; }
    .bsr-table > tbody > tr > td.bsr-mv .mv { padding:2px 5px; font-size:.66rem; }
    .bsr-table > tbody > tr > td.bsr-prod { grid-area:prod; }
    .bsr-table > tbody > tr > td.bsr-gmv { grid-area:gmv; font-size:.9rem; }
    .bsr-table > tbody > tr > td.bsr-rate { grid-area:rate; justify-self:end; }
    .bsr-table > tbody > tr > td.bsr-rate > .text-muted { display:none; }
    .bsr-table > tbody > tr > td.bsr-star-cell { display:none; }
    .bsr-table > tbody > tr > td.bsr-shop { grid-area:shop; display:flex; gap:6px; align-items:center; max-width:none; font-size:.74rem; }
    .bsr-shop-nm { min-width:0; }
    .bsr-star { flex:0 0 auto; color:#f59e0b; font-weight:700; }
    .bsr-table > tbody > tr > td.bsr-act { grid-area:act; display:flex; gap:6px; justify-self:end; }
    .bsr-act .btn { height:32px; min-height:32px; border-radius:16px; }
    .bsr-act .bsr-open { width:34px; padding:0; justify-content:center; }
    .bsr-table .rank-badge { width:30px; height:30px; font-size:.8rem; }
    .bs-tbl-name { min-width:0; }
    .bs-tbl-thumb { width:48px; height:48px; }
    .bs-tbl-name .nm { font-size:.84rem; }

    /* ─── Lưới: 2 cột ─── */
    .bs-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
    .bs-card { padding:0; }
    .bs-card:hover { transform:none; }
    .bs-body { padding:9px 10px 10px; gap:5px; }
    .bs-name { font-size:.78rem; }
    .bs-rank { top:6px; left:6px; min-width:26px; height:24px; padding:0 6px; border-radius:7px; font-size:.72rem; }
    .bs-mv-ov { top:6px; right:6px; }
    .bs-gmv .v { font-size:.82rem; }
    .bs-actions .btn { height:34px; min-height:34px; }
    .tsd-rate { font-size:.7rem; padding:2px 7px; }

    .bsc-stat { grid-template-columns:repeat(2,1fr); }
    .bsh-thumb { width:72px; height:72px; }
    /* 4 ô (24h · GMV · hoa hồng · đánh giá) thành 2×2: 3 cột làm khoảng GMV rớt dòng. */
    .bsh-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .bsh-stat .v { white-space:nowrap; }
}
