/* Trang /tiktok-shop-link-generator — tách từ <style> inline 18/09 khi làm lại giao diện.
 * Thứ tự: hero + lối tắt → 4 KPI → [chọn sản phẩm | tạo link] → lịch sử.
 * ⚠ <link> file này TRƯỚC tiktok-shop-mobile.css: rule mobile chung của cụm /tiktok-shop*
 * phải thắng cascade (xem đầu file đó). */

.gen-page { --gen-accent: #fe2c55; --gen-ink: #111827; --gen-muted: #6b7280; --gen-line: #eef0f2; }

/* ─── Hero + lối tắt ─── */
.gen-hero { position: relative; overflow: hidden; background: linear-gradient(135deg, #010101 0%, #1f1f1f 60%, #2b0a12 100%); border-radius: 16px; padding: 20px 22px; margin-bottom: 14px; color: #fff; }
.gen-hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle, rgba(254,44,85,.35), transparent 70%); pointer-events: none; }
.gen-hero h1 { font-size: 1.5rem; font-weight: 800; margin: 0 0 4px; }
.gen-hero p { color: rgba(255,255,255,.65); font-size: .875rem; margin: 0; max-width: 560px; }
.gen-shortcuts { position: relative; z-index: 1; display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.gen-shortcuts::-webkit-scrollbar { display: none; }
.gen-shortcut { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 20px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); color: #fff; font-size: .8rem; font-weight: 600; text-decoration: none; transition: background .15s; }
.gen-shortcut:hover { background: rgba(255,255,255,.2); color: #fff; }
.gen-shortcut.is-featured { background: #fff; color: var(--gen-ink); border-color: #fff; }
.gen-shortcut.is-featured i { color: var(--gen-accent); }

/* ─── Card chung ─── */
.gen-card { background: #fff; border: 1px solid #f0f0f0; border-radius: 14px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.05); min-width: 0; }
.gen-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.gen-card__title { font-size: .98rem; font-weight: 700; margin: 0; color: var(--gen-ink); display: flex; align-items: center; gap: 6px; }
.gen-step { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--gen-ink); color: #fff; font-size: .72rem; font-weight: 800; }

/* ─── KPI ─── */
.ls-pills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ls-pill { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--gen-line); border-radius: 12px; padding: 12px; min-width: 0; }
.ls-pill__body { min-width: 0; }
.ls-pill__icon { flex: 0 0 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; background: #f3f4f6; color: #374151; }
.ls-pill.today .ls-pill__icon { background: #e8f1ff; color: #0d6efd; }
.ls-pill.orders .ls-pill__icon { background: #fff4e5; color: #ea580c; }
.ls-pill.money .ls-pill__icon { background: #dcfce7; color: #15803d; }
.ls-pill .num { font-size: 1.2rem; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-pill .lbl { font-size: .7rem; color: #8a8f98; text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.ls-pill.today .num { color: #0d6efd; }
.ls-pill.money .num { color: #15803d; }
.ls-freq-wrap { margin-top: 14px; }
.ls-freq { display: flex; gap: 5px; align-items: flex-end; height: 86px; }
.ls-freq-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; cursor: default; }
.ls-freq-col .ls-bar { background: linear-gradient(180deg, #fe2c55, #ff6b88); border-radius: 4px 4px 0 0; }
.ls-freq-col:hover .ls-bar { background: #d61f45; }
.ls-freq-col .ls-day { font-size: .6rem; color: #adb2b8; text-align: center; margin-top: 3px; white-space: nowrap; overflow: hidden; }

/* ─── Chọn sản phẩm ─── */
.gen-search { position: relative; margin-bottom: 10px; }
.gen-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9ca3af; pointer-events: none; }
.gen-search input { width: 100%; height: 40px; border: 1px solid #e5e7eb; border-radius: 20px; padding: 0 14px 0 36px; font-size: .86rem; background: #f9fafb; outline: none; }
.gen-search input:focus { border-color: var(--gen-accent); background: #fff; }
#productList { max-height: 420px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.product-row { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1.5px solid transparent; border-radius: 10px; cursor: pointer; transition: background .15s, border-color .15s; }
.product-row + .product-row { margin-top: 2px; }
.product-row:hover { background: #f8f9fa; }
.product-row.selected { background: #fff1f4; border-color: var(--gen-accent); }
.product-row img { flex: 0 0 52px; width: 52px; height: 52px; object-fit: cover; border-radius: 9px; background: #f0f0f0; }
.product-row .info { flex: 1; min-width: 0; }
.product-row .info .name { font-size: .85rem; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-row .info .pid { font-size: .7rem; color: #9ca3af; margin-top: 2px; }
.gen-comm { display: inline-block; margin-top: 3px; font-size: .7rem; font-weight: 700; color: #15803d; background: #dcfce7; padding: 1px 8px; border-radius: 20px; }
.product-row__check { flex: 0 0 22px; height: 22px; border-radius: 50%; border: 2px solid #d1d5db; display: flex; align-items: center; justify-content: center; color: #fff; font-size: .75rem; }
.product-row.selected .product-row__check { background: var(--gen-accent); border-color: var(--gen-accent); }
.gen-empty { text-align: center; color: var(--gen-muted); font-size: .84rem; padding: 24px 8px; }

/* ─── Tạo link ─── */
.gen-types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; background: #f3f4f6; border-radius: 12px; margin-bottom: 14px; }
.gen-type { border: 0; background: transparent; border-radius: 9px; padding: 8px 4px; font-size: .82rem; font-weight: 600; color: var(--gen-muted); display: flex; align-items: center; justify-content: center; gap: 5px; }
.gen-type.is-active { background: #fff; color: var(--gen-ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.gen-type.is-active i { color: var(--gen-accent); }

.gen-selected { display: flex; align-items: center; gap: 10px; background: #f8f9fa; border: 1.5px dashed #dee2e6; border-radius: 10px; padding: 10px 12px; font-size: .84rem; color: var(--gen-muted); min-height: 58px; }
.gen-selected.is-set { background: #fff1f4; border: 1.5px solid #fecdd6; color: var(--gen-ink); }
.gen-selected img { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #f0f0f0; }
.gen-selected__body { flex: 1; min-width: 0; }
.gen-selected__name { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gen-selected__meta { font-size: .72rem; color: var(--gen-muted); }
.gen-or { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; font-size: .72rem; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; }
.gen-or::before, .gen-or::after { content: ""; flex: 1; height: 1px; background: #eee; }

.gen-showcase-note { display: flex; gap: 10px; align-items: flex-start; background: #eff6ff; border: 1px solid #dbeafe; border-radius: 10px; padding: 12px; font-size: .82rem; color: #1e3a8a; }
.gen-showcase-note i { font-size: 1.1rem; color: #2563eb; }
.gen-showcase-note a { font-weight: 700; }

.gen-submit { height: 46px; font-weight: 700; border-radius: 12px; }

.gen-result { margin-top: 14px; border: 1.5px solid #86efac; background: #f0fdf4; border-radius: 12px; padding: 12px; }
.gen-result__label { font-size: .78rem; font-weight: 700; color: #15803d; margin-bottom: 6px; }
.gen-result__link { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; word-break: break-all; background: #fff; border: 1px solid #bbf7d0; border-radius: 8px; padding: 8px 10px; color: #14532d; }
.gen-result__actions { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; margin-top: 8px; }

/* Chốt sau khi tạo link — mời sang app (phase 02 growth). */
.gen-app-upsell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; background: #fff; border: 1px dashed #86efac; border-radius: 10px; }
.gen-app-upsell i { color: var(--gen-accent); font-size: 1.05rem; flex: 0 0 auto; }
.gen-app-upsell span { flex: 1 1 auto; font-size: .82rem; color: #14532d; font-weight: 600; min-width: 160px; }

/* ─── Lịch sử ─── */
#linkHistory { max-height: 620px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.hist-row { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--gen-line); border-radius: 12px; background: #fff; transition: .15s; }
.hist-row:hover { border-color: #dde1e6; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.hist-row > img, .h-thumb-icon { width: 54px; height: 54px; border-radius: 9px; flex-shrink: 0; }
.hist-row > img { object-fit: cover; background: #f0f0f0; }
.h-thumb-icon { display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.h-thumb-icon.showcase { background: #eaf4ff; color: #0d6efd; }
.h-thumb-icon.campaign { background: #fff0e6; color: #fd7e14; }
.h-thumb-icon.product { background: #f0f0f0; color: #aaa; }
.hist-row .h-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.hist-row .h-title { font-size: .85rem; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hist-row .h-link a { color: #0d6efd; font-family: monospace; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; text-decoration: none; }
.hist-row .h-link a:hover { text-decoration: underline; }
.hist-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .7rem; color: #8a8f98; }
.hist-badge { display: inline-block; font-size: .65rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: #eef1f4; color: #444; letter-spacing: .2px; }
.hist-tag { display: inline-flex; align-items: center; gap: 3px; font-size: .65rem; padding: 2px 8px; border-radius: 20px; background: #fff3cd; color: #7a5b00; font-family: monospace; }
.hist-stats { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 3px; font-size: .75rem; }
.hist-stat { display: inline-flex; align-items: center; gap: 4px; color: #333; font-weight: 700; }
.hist-stat .lbl { color: #9aa0a6; font-weight: 500; }
.hist-stat.money { color: #15803d; }
.hist-stat.empty { color: #b0b4b9; font-weight: 500; }
.hist-actions { align-self: flex-start; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.hist-copy { flex-shrink: 0; }
.hist-del { flex-shrink: 0; color: #dc3545; border-color: #f1c2c7; }
.hist-del:hover { background: #dc3545; border-color: #dc3545; color: #fff; }
.hist-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#histLiveBtn.live { background: #d1f0dc; border-color: #198754; color: #0d4f26; }
#histLiveBtn.live i { animation: lsPulse 1.2s ease-in-out infinite; }
@keyframes lsPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.hist-pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.hist-pager span { color: #8a8f98; font-size: .78rem; }
.hist-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hist-filters .gen-search { flex: 1 1 220px; margin: 0; max-width: 300px; }
.hist-filters .gen-search input { height: 31px; font-size: .8rem; }
.hist-filters .form-select { width: auto; }

/* QR overlay (không phụ thuộc bootstrap modal) */
#qrOverlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 2000; align-items: center; justify-content: center; }
#qrOverlay .qr-box { background: #fff; border-radius: 14px; padding: 22px; text-align: center; max-width: 300px; }
#qrOverlay img { width: 220px; height: 220px; display: block; margin: 0 auto 10px; }
#qrOverlay .qr-link { font-family: monospace; font-size: .7rem; word-break: break-all; color: #666; }

@media (max-width: 991.98px) {
    .ls-pills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #productList { max-height: 320px; }
}
@media (max-width: 575.98px) {
    /* Ô KPI chỉ còn ~170px: bỏ icon để số tiền dài (4.820.000đ) không bị cắt "…". */
    .ls-pill { padding: 10px 12px; }
    .ls-pill__icon { display: none; }
    .ls-pill .num { font-size: 1.1rem; }
    /* tiktok-shop-mobile.css ép .hist-toolbar/.hist-filters thành lưới (1 cột ≤399px) bằng
       !important ⇒ cần !important + selector dài hơn. 3 nút gọn 1 hàng; bộ lọc 2 cột, ô tìm trọn hàng. */
    .gen-page .hist-toolbar { display: flex !important; flex-wrap: nowrap; }
    .gen-page .hist-toolbar > .btn { flex: 1 1 0; white-space: nowrap; padding-left: 6px; padding-right: 6px; }
    .gen-page .hist-filters { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .gen-page .hist-filters > .gen-search { grid-column: 1 / -1; }
    /* 14 cột ~22px không đủ chỗ cho "05/09" ⇒ nhãn cách một. */
    .ls-freq-col:nth-child(even) .ls-day { visibility: hidden; }
    .gen-type { font-size: .78rem; }
    .hist-row { flex-wrap: wrap; }
    .hist-actions { flex-direction: row; width: 100%; justify-content: flex-end; }
    .hist-filters .gen-search { max-width: none; }
}
