/* =====================================================================
   Darkstore-style product card (added 2026-11-12)
   Used by mod/js/product-card.js on the products page, home page,
   recently viewed and best sellers. Light theme first, then dark theme.
   ===================================================================== */

.sac-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    grid-template-columns: none !important;
}

.sac-card {
    position: relative;
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    color: #0f172a;
    animation: sacFade 0.3s ease both;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.25s ease, transform 0.25s ease;
}

.sac-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

@keyframes sacFade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.sac-card.sac-leaving { opacity: 0; transform: scale(0.98); }
.sac-card.sac-oos { opacity: 0.78; }

/* --- left column: image, BESTSELLER, actions --- */
.sac-side {
    flex: 0 0 96px;
    width: 96px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sac-media {
    display: block;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
}

.sac-best {
    display: block;
    padding: 2px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    color: #ffffff;
    background: #f1a63c;
    cursor: help;
}

.sac-imgbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    background: #eef2f7;
    overflow: hidden;
}

.sac-imgbox img.sac-img,
.sac-imgbox > img:not(.sac-cat-icon) {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sac-imgbox img.sac-cat-icon {
    width: 42%;
    height: 42%;
    object-fit: contain;
}

.sac-ph {
    font-size: 26px;
    color: #94a3b8;
}

.sac-actions {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.sac-act {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 13px;
    color: #475569;
    background: #eef2f7;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.sac-act:hover { background: #e0e7ff; color: #4f5bd5; }
.sac-fav.active, .sac-fav:hover { color: #ef4444; }
.sac-hide.active { color: #ffffff; background: #ef4444; }
.sac-info { color: #4f5bd5; }

/* --- right column --- */
.sac-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sac-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 22px;
}

.sac-cat {
    font-size: 11px;
    font-weight: 600;
    color: #5b6cff;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sac-cat:hover { text-decoration: underline; }

.sac-badges,
.sac-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sac-badges { justify-content: flex-end; }

.sac-badge,
.sac-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 7px;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    cursor: help;
    outline: none;
}

.sac-badge { font-weight: 600; }
.sac-badge:focus-visible, .sac-stat:focus-visible, .sac-best:focus-visible { box-shadow: 0 0 0 2px #a5b4fc; }

.sac-defect { color: #4f5bd5; background: #eef2ff; }
.sac-warranty { color: #047857; background: #ecfdf5; }
.sac-video { color: #c2410c; background: #fff7ed; }
.sac-norep { color: #dc2626; background: #fef2f2; }

.sac-stat { color: #334155; background: #f1f5f9; }
.sac-stat i { font-size: 11px; color: #64748b; }
.sac-rating i { color: #f59e0b; }
.sac-reviews i { color: #5b6cff; }
.sac-min { color: #b45309; background: #fffbeb; }
.sac-min i { color: #b45309; }

.sac-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: #0f172a;
    text-decoration: none;
}

.sac-name:hover { color: #4f5bd5; }

.sac-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
}

.sac-buybox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.sac-pricebox {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

.sac-price {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
}

.sac-price-old {
    font-size: 12px;
    color: #94a3b8;
    text-decoration: line-through;
}

.sac-buy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    text-decoration: none;
    background: #5b6cff;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.sac-buy:hover { color: #ffffff; background: #4a5af0; }
.sac-buy.sac-added { background: #16a34a; }
.sac-buy.sac-ghost { color: #4f5bd5; background: transparent; border: 1px solid #c7d2fe; }
.sac-buy.sac-ghost:hover { background: #eef2ff; }

.sac-oos-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #dc2626;
    white-space: nowrap;
}

/* --- tile variant (carousels, grids) --- */
.sac-tile {
    flex-direction: column;
    height: 100%;
    padding: 10px;
    gap: 8px;
}

.sac-tile .sac-side { flex: none; width: auto; }
.sac-tile .sac-imgbox { width: 100%; height: 120px; }
.sac-tile .sac-actions { justify-content: flex-start; }
.sac-tile .sac-head { flex-direction: column; align-items: flex-start; gap: 4px; }
.sac-tile .sac-badges { justify-content: flex-start; }
.sac-tile .sac-foot { flex-direction: column; align-items: stretch; }
.sac-tile .sac-buybox { margin-left: 0; justify-content: space-between; }

/* 2026-11-12 (phone fix): two tiles side by side on a phone are only about
   170 px wide, so the price and "Add to cart" did not fit on one line and the
   button stuck out of the card. In a narrow tile the button now goes under
   the price and fills the width; wider tiles keep one line as before.
   Browsers without container queries still wrap the button (no overflow). */
.sac-tile { container-type: inline-size; }
.sac-tile .sac-buybox { flex-wrap: wrap; row-gap: 8px; }
.sac-tile .sac-buy { margin-left: auto; }
@container (max-width: 210px) {
    .sac-tile .sac-buy { flex: 1 1 100%; padding: 0 10px; }
}

/* 2026-11-12 (card title): in side-by-side cards a long category name ran
   past the card's right edge. It now wraps inside the card: one line when it
   fits, at most two lines ("..." only if it needs more), with the two lines
   set close together. */
.sac-tile .sac-cat {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    line-height: 1.2;
}

/* --- phones: Darkstore mobile card (image left, text right, full-width buy row) --- */
@media (max-width: 640px) {
    .sac-row {
        display: grid;
        grid-template-columns: 84px minmax(0, 1fr);
        grid-template-areas:
            "side head"
            "side name"
            "side stats"
            "buy buy";
        column-gap: 10px;
        row-gap: 6px;
        padding: 10px;
    }

    .sac-row .sac-body,
    .sac-row .sac-foot { display: contents; }
    .sac-row .sac-side { grid-area: side; width: 84px; }
    .sac-row .sac-imgbox { width: 84px; height: 84px; }
    .sac-row .sac-head { grid-area: head; flex-direction: column; align-items: flex-start; gap: 4px; }
    .sac-row .sac-badges { justify-content: flex-start; }
    .sac-row .sac-name { grid-area: name; font-size: 13px; }
    .sac-row .sac-stats { grid-area: stats; }
    .sac-row .sac-buybox { grid-area: buy; margin-left: 0; justify-content: space-between; }
    .sac-row .sac-buy { flex: 1; height: 38px; }
    .sac-price { font-size: 17px; }
    .sac-badge, .sac-stat { height: 21px; padding: 0 6px; font-size: 11px; }
}

/* --- tooltips --- */
.sac-tooltip {
    position: fixed;
    z-index: 100000;
    max-width: 260px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.45;
    color: #ffffff;
    background: #0f172a;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.sac-tooltip.show { opacity: 1; }

/* --- info pop-up --- */
html.sac-modal-open { overflow: hidden; }

.sac-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
}

.sac-modal.open { display: block; }

.sac-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
}

.sac-modal-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(720px, calc(100% - 24px));
    max-height: 90vh;
    margin: 5vh auto 0;
    padding: 0;
    overflow: hidden;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
}

/* 2026-11-12: only the body scrolls; the close button stays above the content */
.sac-modal-body {
    min-height: 0;
    padding: 18px;
    overflow: auto;
    overscroll-behavior: contain;
}

.sac-modal-close {
    position: absolute;
    z-index: 5;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    font-size: 16px;
    color: #475569;
    background: #f1f5f9;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.sac-modal-loading,
.sac-modal-error {
    padding: 40px 0;
    font-size: 15px;
    text-align: center;
    color: #64748b;
}

.sac-modal-card,
.sac-modal-card:hover {
    display: block;
    padding: 0;
    border: 0;
    box-shadow: none;
    animation: none;
}

.sac-modal-head {
    display: flex;
    gap: 14px;
    padding-right: 36px;
}

.sac-modal-head .sac-imgbox {
    flex: 0 0 88px;
    width: 88px;
    height: 88px;
    border-radius: 10px;
}

.sac-modal-title { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sac-modal-title h3 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.35; color: #0f172a; }
.sac-modal-title .sac-badges { justify-content: flex-start; }

.sac-video-box,
.sac-norep-box {
    display: flex;
    gap: 10px;
    margin: 14px 0 0;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 10px;
}

.sac-video-box { color: #9a3412; background: #fff7ed; border: 1px solid #fed7aa; }
.sac-video-box i { margin-top: 3px; }
.sac-video-box p { margin: 4px 0 0; line-height: 1.5; }
.sac-video-box a { font-weight: 600; color: inherit; text-decoration: underline; }
.sac-norep-box { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; }

.sac-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0 18px;
    margin: 12px 0;
}

.sac-info-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 0;
    font-size: 13px;
    border-bottom: 1px dashed #e2e8f0;
}

.sac-info-row span { color: #64748b; }

.sac-attrs { display: flex; flex-wrap: wrap; gap: 6px; }

.sac-attr {
    padding: 4px 8px;
    font-size: 12px;
    color: #334155;
    background: #f1f5f9;
    border-radius: 6px;
}

.sac-section h4 { margin: 16px 0 6px; font-size: 14px; font-weight: 700; color: #0f172a; }
.sac-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    margin: 16px 0 8px;
}
.sac-section-head h4 { margin: 0; }

.sac-translate {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    font-size: 12px;
    color: #475569;
}

.sac-translate label { margin: 0; font-weight: 600; white-space: nowrap; }

.sac-translate-select {
    height: 30px;
    max-width: 210px;
    padding: 0 28px 0 10px;
    font-size: 12px;
    color: #0f172a;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
}

.sac-translate-status { flex-basis: 100%; color: #b45309; }
.sac-translate-status:empty { display: none; }
.sac-rich { font-size: 13px; line-height: 1.6; color: #334155; overflow-wrap: anywhere; }
.sac-rich img { max-width: 100%; height: auto; }
.sac-desc {
    max-height: 260px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.5) transparent;
}

.sac-modal-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.sac-modal-btns { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 640px) {
    .sac-modal-panel {
        width: 100%;
        max-height: 92vh;
        margin: 8vh 0 0;
        border-radius: 14px 14px 0 0;
    }
    .sac-modal-body { padding: 14px; }
    .sac-translate-select { max-width: 100%; }
    .sac-modal-btns, .sac-modal-btns .sac-buy { width: 100%; }
}

/* --- toasts --- */
.sac-toast-box {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: calc(100% - 32px);
}

.sac-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    font-size: 13px;
    color: #ffffff;
    background: #0f172a;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    transition: opacity 0.4s ease;
}

.sac-toast-success { background: #15803d; }
.sac-toast-error { background: #b91c1c; }
.sac-toast-warning { background: #b45309; }
.sac-toast-out { opacity: 0; }

.sac-toast-action {
    padding: 2px 8px;
    font-size: 12px;
    color: #ffffff;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    cursor: pointer;
}

/* --- hidden products page --- */
.sac-hidden-page .sac-hide.active { background: #16a34a; }

.sac-page-head { margin-bottom: 16px; }
.sac-page-head h1 { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.sac-page-head p { margin: 0; color: #64748b; }

.sac-empty {
    padding: 40px 16px;
    text-align: center;
    color: #64748b;
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
}

.sac-empty i { font-size: 32px; margin-bottom: 10px; }
.sac-empty .sac-buy { margin-top: 10px; }

/* --- home carousels: tile inside the existing carousel slot --- */
.rv-product-card.sac-tile-wrap {
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.rv-product-card.sac-tile-wrap:hover { transform: none; }
.rv-product-card.sac-tile-wrap > .sac-card { width: 100%; }

/* --- best sellers: all time / 7 days / 30 days --- */
.bs-period-toggle {
    display: inline-flex;
    gap: 4px;
    margin-top: 8px;
    padding: 3px;
    background: #f1f5f9;
    border-radius: 8px;
}

.bs-period-btn {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.bs-period-btn.active { color: #ffffff; background: #5b6cff; }
.bs-period-empty { padding: 24px; color: #64748b; }
[data-theme="dark"] .bs-period-toggle { background: #273449; }
[data-theme="dark"] .bs-period-btn { color: #cbd5e1; }
[data-theme="dark"] .bs-period-btn.active { color: #ffffff; background: #5b6cff; }
[data-theme="dark"] .sac-page-head p,
[data-theme="dark"] .sac-empty { color: #94a3b8; }
[data-theme="dark"] .sac-empty { background: #1e293b; border-color: #334155; }

/* ===================== dark theme ===================== */
[data-theme="dark"] .sac-card { color: #f1f5f9; background: #1e293b; border-color: #334155; }
[data-theme="dark"] .sac-card:hover { border-color: #4f5bd5; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
[data-theme="dark"] .sac-imgbox { background: #273449; }
[data-theme="dark"] .sac-ph { color: #64748b; }
[data-theme="dark"] .sac-act { color: #cbd5e1; background: #273449; }
[data-theme="dark"] .sac-act:hover { color: #a5b4fc; background: #334155; }
[data-theme="dark"] .sac-info { color: #a5b4fc; }
[data-theme="dark"] .sac-fav.active,
[data-theme="dark"] .sac-fav:hover { color: #f87171; }
[data-theme="dark"] .sac-hide.active { color: #ffffff; background: #ef4444; }
[data-theme="dark"] .sac-hidden-page .sac-hide.active { background: #16a34a; }
[data-theme="dark"] .sac-cat { color: #8b9bff; }
[data-theme="dark"] .sac-name { color: #f1f5f9; }
[data-theme="dark"] .sac-name:hover { color: #a5b4fc; }
[data-theme="dark"] .sac-defect { color: #a5b4fc; background: rgba(99, 102, 241, 0.16); }
[data-theme="dark"] .sac-warranty { color: #34d399; background: rgba(52, 211, 153, 0.14); }
[data-theme="dark"] .sac-video { color: #fdba74; background: rgba(251, 146, 60, 0.15); }
[data-theme="dark"] .sac-norep { color: #fca5a5; background: rgba(248, 113, 113, 0.15); }
[data-theme="dark"] .sac-stat { color: #e2e8f0; background: #273449; }
[data-theme="dark"] .sac-stat i { color: #94a3b8; }
[data-theme="dark"] .sac-rating i { color: #fbbf24; }
[data-theme="dark"] .sac-reviews i { color: #8b9bff; }
[data-theme="dark"] .sac-min { color: #fbbf24; background: rgba(251, 191, 36, 0.14); }
[data-theme="dark"] .sac-min i { color: #fbbf24; }
[data-theme="dark"] .sac-price { color: #f1f5f9; }
[data-theme="dark"] .sac-price-old { color: #64748b; }
[data-theme="dark"] .sac-buy.sac-ghost { color: #a5b4fc; border-color: #4f5bd5; }
[data-theme="dark"] .sac-buy.sac-ghost:hover { background: rgba(99, 102, 241, 0.15); }
[data-theme="dark"] .sac-oos-label { color: #f87171; }
[data-theme="dark"] .sac-modal-panel { background: #1e293b; }
[data-theme="dark"] .sac-modal-close { color: #cbd5e1; background: #273449; }
[data-theme="dark"] .sac-modal-title h3,
[data-theme="dark"] .sac-section h4 { color: #f1f5f9; }
[data-theme="dark"] .sac-modal-card { background: transparent; }
[data-theme="dark"] .sac-info-row { border-color: #334155; }
[data-theme="dark"] .sac-info-row span { color: #94a3b8; }
[data-theme="dark"] .sac-attr { color: #e2e8f0; background: #273449; }
[data-theme="dark"] .sac-rich { color: #cbd5e1; }
[data-theme="dark"] .sac-modal-foot { border-color: #334155; }
[data-theme="dark"] .sac-video-box { color: #fdba74; background: rgba(251, 146, 60, 0.1); border-color: rgba(251, 146, 60, 0.35); }
[data-theme="dark"] .sac-norep-box { color: #fca5a5; background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.35); }
[data-theme="dark"] .sac-tooltip { color: #0f172a; background: #f1f5f9; }

/* ------------------------------------------------------------------
   2026-11-12 (local review): translate box, product page header chips,
   related products grid
   ------------------------------------------------------------------ */
[data-theme="dark"] .sac-translate { color: #cbd5e1; }
[data-theme="dark"] .sac-translate-select { color: #e2e8f0; background-color: #0f172a; border-color: #334155; }
[data-theme="dark"] .sac-translate-status { color: #fbbf24; }
[data-theme="dark"] .sac-desc { scrollbar-color: rgba(148, 163, 184, 0.45) transparent; }

/* Badges and numbers in the product page header (same data as the cards) */
.sac-hero-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.sac-hero-chips:empty { display: none; }

.product-hero-meta .sac-inline .sac-badge,
.product-hero-meta .sac-inline .sac-stat {
    height: auto;
    min-height: 38px;
    gap: 6px;
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.product-hero-meta .sac-inline .sac-badge i,
.product-hero-meta .sac-inline .sac-stat i { font-size: 0.85rem; color: rgba(255, 255, 255, 0.85); }
.product-hero-meta .sac-inline .sac-defect i { color: #c7d2fe; }
.product-hero-meta .sac-inline .sac-warranty i { color: #6ee7b7; }
.product-hero-meta .sac-inline .sac-video { background: rgba(251, 146, 60, 0.25); border-color: rgba(251, 146, 60, 0.45); }
.product-hero-meta .sac-inline .sac-video i { color: #fed7aa; }
.product-hero-meta .sac-inline .sac-norep { background: rgba(239, 68, 68, 0.25); border-color: rgba(239, 68, 68, 0.45); }
.product-hero-meta .sac-inline .sac-norep i { color: #fecaca; }
.product-hero-meta .sac-inline .sac-rating i,
.product-hero-meta .sac-inline .sac-min i { color: #fbbf24; }

@media (max-width: 768px) {
    .sac-hero-chips { gap: 6px; }
    .product-hero-meta .sac-inline .sac-badge,
    .product-hero-meta .sac-inline .sac-stat {
        min-height: 32px;
        padding: 0.3rem 0.65rem;
        font-size: 0.8rem;
    }
}

/* Related products on the product page: tiles in a grid */
.sac-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

@media (max-width: 640px) {
    .sac-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
