/* Phase 7.G — Recent viewed UI (boxtaikhoan-inspired). All under .bk-recent-* prefix. */

/* ─── Floating popup (bottom-right) ──────────────────────────────────── */
.bk-recent-popup { position: fixed; right: 16px; bottom: 16px; z-index: 990; font-family: 'Be Vietnam Pro', system-ui, sans-serif; }
.bk-recent-popup[hidden] { display: none !important; }

.bk-recent-toggle {
    width: 52px; height: 52px; border-radius: 50%; border: 0; background: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.08);
    color: #13A459; font-size: 20px; cursor: pointer; position: relative;
    display: inline-flex; align-items: center; justify-content: center; transition: 0.2s;
}
.bk-recent-toggle:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.18); }
.bk-recent-count {
    position: absolute; top: -4px; right: -4px; background: #DC2626; color: #fff;
    border-radius: 10px; min-width: 18px; height: 18px; font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
.bk-recent-count:empty { display: none; }

.bk-recent-panel {
    position: absolute; bottom: 60px; right: 0; width: 320px; max-height: 480px;
    background: #fff; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08);
    display: none; flex-direction: column; overflow: hidden;
}
.bk-recent-popup[data-state="expanded"] .bk-recent-panel { display: flex; }
.bk-recent-popup[data-state="expanded"] .bk-recent-toggle { background: #13A459; color: #fff; }

.bk-recent-head { padding: 12px 14px; border-bottom: 1px solid #F3F4F6; display: flex; justify-content: space-between; align-items: center; }
.bk-recent-head strong { font-size: 14px; color: #1F2937; }
.bk-recent-close { border: 0; background: none; font-size: 22px; color: #9CA3AF; cursor: pointer; line-height: 1; padding: 0 4px; }
.bk-recent-close:hover { color: #DC2626; }

.bk-recent-list { list-style: none; padding: 8px; margin: 0; overflow-y: auto; flex: 1; max-height: 360px; }
.bk-recent-list .bk-recent-item {
    display: flex; gap: 10px; padding: 8px; border-radius: 8px; text-decoration: none; color: inherit;
    transition: 0.15s; align-items: center;
}
.bk-recent-list .bk-recent-item:hover { background: #F9FAFB; }
.bk-recent-item-img { flex: 0 0 48px; height: 48px; border-radius: 6px; overflow: hidden; background: #F3F4F6; display: flex; align-items: center; justify-content: center; }
.bk-recent-item-img img { width: 100%; height: 100%; object-fit: cover; }
.bk-recent-item-img i { font-size: 20px; color: #9CA3AF; }
.bk-recent-item-body { flex: 1; min-width: 0; }
.bk-recent-item-name { font-size: 13px; color: #27272A; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk-recent-item-price { font-size: 13px; color: #DC2626; font-weight: 700; margin-top: 2px; }

.bk-recent-foot { border-top: 1px solid #F3F4F6; padding: 8px 14px; text-align: right; }
.bk-recent-clear { border: 0; background: none; color: #9CA3AF; font-size: 12px; cursor: pointer; padding: 4px 8px; }
.bk-recent-clear:hover { color: #DC2626; }

@media (max-width: 768px) {
    .bk-recent-popup { right: 8px; bottom: 76px; }
    .bk-recent-panel { width: calc(100vw - 32px); right: -8px; max-width: 360px; }
}

/* ─── Embedded section (home / category / product) ───────────────────── */
.bk-recent-section { padding: 18px 0 12px; margin-top: 12px; position: relative; }
.bk-recent-section[hidden] { display: none !important; }

/* Divider-line header: ─── ✦ Title ✦ ─── (Phase 10.AL polish) */
.bk-recent-header, .bk-divider-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    padding: 0;
}
.bk-recent-header h3, .bk-divider-header h3 {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    letter-spacing: 0.3px;
    margin: 0;
    line-height: 1;
}
.bk-recent-header h3::before, .bk-recent-header h3::after,
.bk-divider-header h3::before, .bk-divider-header h3::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #E5E7EB 40%, #E5E7EB 60%, transparent);
}
.bk-recent-header h3 .star, .bk-divider-header h3 .star {
    color: #C7D2FE;
    font-size: 11px;
    line-height: 1;
    display: inline-block;
    transform: translateY(-0.5px);
}
.bk-recent-header h3 .title, .bk-divider-header h3 .title {
    white-space: nowrap;
    padding: 0 2px;
}
/* Hide inline FA icon nếu legacy markup vẫn còn */
.bk-recent-header h3 > i:first-child:not(.star) { display: none; }

/* Clear link: absolute top-right, kín đáo, chỉ hiện rõ khi hover section */
.bk-recent-section .bk-recent-clear-link {
    position: absolute;
    top: 18px;
    right: 0;
    font-size: 11px;
    color: #D1D5DB;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s, opacity 0.2s;
    z-index: 2;
    opacity: 0;
    background: #fff;
    padding: 2px 6px;
    border-radius: 4px;
}
.bk-recent-section:hover .bk-recent-clear-link { opacity: 1; }
.bk-recent-section .bk-recent-clear-link i { font-size: 10px; }
.bk-recent-section .bk-recent-clear-link:hover { color: #DC2626; }

/* Grid variant — for home + category bottom (legacy) */
.bk-recent-variant-grid .bk-recent-section-list {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}
@media (max-width: 1199px) { .bk-recent-variant-grid .bk-recent-section-list { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px)  { .bk-recent-variant-grid .bk-recent-section-list { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px)  { .bk-recent-variant-grid .bk-recent-section-list { grid-template-columns: repeat(2, 1fr); } }

/* Row variant — compact horizontal scroll (legacy 180px) */
.bk-recent-variant-row .bk-recent-section-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.bk-recent-variant-row .bk-recent-card { flex: 0 0 180px; }

/* ─── Generic carousel — reusable cho recent-viewed, related products, ... ── */
/* Wrap: positioning context cho overlay nav buttons */
.bk-carousel-wrap { position: relative; }

.bk-carousel-list,
.bk-recent-variant-carousel .bk-recent-section-list {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scroll-padding-left: 4px;
    padding: 4px 4px 4px;
    -webkit-overflow-scrolling: touch;
    /* Ẩn scrollbar hoàn toàn (Firefox + IE) */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
/* Ẩn scrollbar WebKit (Chrome / Safari / Edge) */
.bk-carousel-list::-webkit-scrollbar,
.bk-recent-variant-carousel .bk-recent-section-list::-webkit-scrollbar { display: none; width: 0; height: 0; }
.bk-carousel-list > *,
.bk-recent-variant-carousel .bk-recent-section-list > * {
    flex: 0 0 calc((100% - 14px * 4) / 5);
    scroll-snap-align: start;
    min-width: 0;
}
@media (max-width: 1199px) {
    .bk-carousel-list > *,
    .bk-recent-variant-carousel .bk-recent-section-list > * { flex-basis: calc((100% - 14px * 3) / 4); }
}
@media (max-width: 992px) {
    .bk-carousel-list > *,
    .bk-recent-variant-carousel .bk-recent-section-list > * { flex-basis: calc((100% - 14px * 2) / 3); }
}
@media (max-width: 576px) {
    .bk-carousel-list > *,
    .bk-recent-variant-carousel .bk-recent-section-list > * { flex-basis: calc((100% - 14px) / 2); }
}

/* Nav overlay buttons — căn giữa dọc 2 bên carousel (Tiki/Amazon style) */
.bk-carousel-nav, .bk-recent-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 38px; height: 38px;
    border: 1px solid rgba(0,0,0,0.06);
    background: rgba(255,255,255,0.96);
    border-radius: 50%;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s, background 0.2s;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.10);
    opacity: 0.85;
}
.bk-carousel-nav.prev, .bk-recent-nav.prev { left: -10px; }
.bk-carousel-nav.next, .bk-recent-nav.next { right: -10px; }
.bk-carousel-wrap:hover .bk-carousel-nav,
.bk-recent-section:hover .bk-recent-nav { opacity: 1; }
.bk-carousel-nav:hover, .bk-recent-nav:hover {
    background: #fff;
    color: #111827;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    transform: translateY(-50%) scale(1.06);
}
.bk-carousel-nav:disabled, .bk-recent-nav:disabled { opacity: 0.3 !important; cursor: not-allowed; }
.bk-carousel-nav[hidden], .bk-recent-nav[hidden] { display: none; }
/* Legacy: controls container (giờ không dùng nữa trong header) */
.bk-recent-controls, .bk-carousel-controls { display: none; }

.bk-recent-card {
    background: #fff; border: 1px solid #F3F4F6; border-radius: 10px; overflow: hidden;
    text-decoration: none; color: inherit; transition: 0.15s; display: flex; flex-direction: column;
}
.bk-recent-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); border-color: #A7F3D0; transform: translateY(-2px); }
.bk-recent-card-img { aspect-ratio: 16/9; background: #F3F4F6; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.bk-recent-card-img img { width: 100%; height: 100%; object-fit: cover; }
.bk-recent-card-img i { font-size: 24px; color: #9CA3AF; }
.bk-recent-card-body { padding: 8px 10px 10px; }
.bk-recent-card-name { font-size: 13px; line-height: 1.35; color: #27272A; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk-recent-card-price { font-size: 13px; color: #DC2626; font-weight: 700; margin-top: 4px; }
