/* ═══════════════════════════════════════════════
   FBT Upsell — Elite Frontend Styles
   All colors/sizes injected via inline CSS vars
═══════════════════════════════════════════════ */

/* ── Google Fonts (loaded only once) ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800&display=swap');

/* ── Wrapper ─────────────────────────── */
.fbt-wrapper {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--fbt-section-bg, #ffffff);
    border: 1.5px solid var(--fbt-section-border, #e8e8e8);
    border-radius: var(--fbt-section-radius, 16px);
    padding: var(--fbt-section-padding, 28px);
    box-shadow: var(--fbt-section-shadow, 0 4px 24px rgba(0,0,0,.07));
    margin: 28px 0;
    position: relative;
    overflow: hidden;
    animation: fbt-fade-in .5s ease both;
}

.fbt-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0) 60%, rgba(0,0,0,.015) 100%);
    pointer-events: none;
}

@keyframes fbt-fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Heading ─────────────────────────── */
.fbt-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: var(--fbt-heading-color, #0d0d0d);
    font-size: var(--fbt-heading-size, 18px);
    font-weight: var(--fbt-heading-weight, 700);
    letter-spacing: -.3px;
}

.fbt-icon {
    display: inline-flex;
    align-items: center;
    opacity: .85;
}

.fbt-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--fbt-section-border, #e8e8e8), transparent);
    margin-left: 8px;
}

/* ── Grid ────────────────────────────── */
.fbt-grid {
    display: grid;
    gap: 16px;
}

.fbt-cols-2 { grid-template-columns: repeat(2, 1fr); }
.fbt-cols-3 { grid-template-columns: repeat(3, 1fr); }
.fbt-cols-4 { grid-template-columns: repeat(4, 1fr); }
.fbt-cols-5 { grid-template-columns: repeat(5, 1fr); }

/* ── Product card ────────────────────── */
.fbt-card {
    background: var(--fbt-card-bg, #f8f8f8);
    border-radius: var(--fbt-card-radius, 12px);
    padding: 16px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    transition: transform .22s cubic-bezier(.22,1,.36,1),
                box-shadow .22s cubic-bezier(.22,1,.36,1);
    overflow: hidden;
}

/* Subtle shimmer border */
.fbt-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid rgba(0,0,0,.06);
    pointer-events: none;
}

/* ── Badge ───────────────────────────── */
.fbt-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    background: var(--fbt-badge-bg, #111);
    color: var(--fbt-badge-color, #fff);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 20px;
    line-height: 1.6;
    pointer-events: none;
}

/* ── Image ───────────────────────────── */
.fbt-img-wrap {
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--fbt-img-radius, 8px);
    background: #efefef;
}

.fbt-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .35s cubic-bezier(.22,1,.36,1);
}

.fbt-card:hover .fbt-img {
    transform: scale(1.04);
}

/* ── Info ────────────────────────────── */
.fbt-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fbt-title {
    font-size: var(--fbt-title-size, 14px);
    font-weight: var(--fbt-title-weight, 600);
    color: var(--fbt-title-color, #111);
    text-decoration: none;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .15s;
}

.fbt-title:hover {
    color: var(--fbt-btn-bg, #111);
    text-decoration: underline;
}

/* Price — WooCommerce outputs <span class="price"> */
.fbt-price,
.fbt-price .price {
    font-size: var(--fbt-price-size, 15px);
    font-weight: var(--fbt-price-weight, 700);
    color: var(--fbt-price-color, #111);
    line-height: 1.3;
}

.fbt-price ins,
.fbt-price .woocommerce-Price-amount {
    text-decoration: none;
    color: var(--fbt-price-color, #111);
}

.fbt-price del {
    color: #aaa;
    font-weight: 400;
    font-size: .85em;
    margin-right: 4px;
}

.fbt-price .woocommerce-Price-amount.amount:not(:only-child):last-child {
    color: var(--fbt-price-sale, #e53935);
}

/* ── Add to Cart button ──────────────── */
.fbt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--fbt-btn-bg, #111);
    color: var(--fbt-btn-color, #fff);
    border: none;
    border-radius: var(--fbt-btn-radius, 8px);
    padding: 10px 14px;
    font-family: inherit;
    font-size: var(--fbt-btn-size, 13px);
    font-weight: var(--fbt-btn-weight, 600);
    letter-spacing: -.1px;
    cursor: pointer;
    transition: background .18s, transform .15s, box-shadow .15s;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.fbt-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background .2s;
}

.fbt-btn:hover {
    background: var(--fbt-btn-hover-bg, #333);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
}

.fbt-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.fbt-btn.fbt-adding {
    opacity: .7;
    pointer-events: none;
}

.fbt-btn.fbt-added {
    background: #16a34a;
}

.fbt-btn.fbt-added::before {
    content: '✓ ';
}

.fbt-btn--oos {
    background: #ccc !important;
    color: #666 !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ── Add-all bar ─────────────────────── */
.fbt-add-all-wrap {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1.5px dashed var(--fbt-section-border, #e8e8e8);
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.fbt-add-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--fbt-add-all-bg, #111);
    color: var(--fbt-add-all-color, #fff);
    border: none;
    border-radius: 10px;
    padding: 12px 22px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -.1px;
    cursor: pointer;
    transition: background .18s, transform .15s, box-shadow .15s;
}

.fbt-add-all-btn:hover {
    opacity: .88;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,0,0,.16);
}

.fbt-add-all-btn.fbt-adding {
    opacity: .6;
    pointer-events: none;
}

/* ── Toast notification ──────────────── */
.fbt-toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: #111;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
    z-index: 99999;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
}

.fbt-toast.fbt-toast--show {
    opacity: 1;
    transform: translateY(0);
}

/* ── Responsive ──────────────────────── */
@media (max-width: 1024px) {
    .fbt-cols-4 { grid-template-columns: repeat(var(--fbt-cols-tablet, 2), 1fr); }
    .fbt-cols-5 { grid-template-columns: repeat(var(--fbt-cols-tablet, 2), 1fr); }
    .fbt-cols-3 { grid-template-columns: repeat(var(--fbt-cols-tablet, 2), 1fr); }
}

@media (max-width: 768px) {
    .fbt-wrapper {
        padding: 18px;
        margin: 20px 0;
    }
    .fbt-grid {
        grid-template-columns: repeat(var(--fbt-cols-tablet, 2), 1fr) !important;
        gap: 12px;
    }
    .fbt-add-all-wrap {
        justify-content: stretch;
    }
    .fbt-add-all-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .fbt-grid {
        grid-template-columns: repeat(var(--fbt-cols-mobile, 1), 1fr) !important;
    }
    .fbt-wrapper {
        padding: 14px;
        border-radius: 12px;
    }
    .fbt-heading {
        font-size: 15px;
    }
}

/* ── Dark mode support ───────────────── */
@media (prefers-color-scheme: dark) {
    .fbt-wrapper[data-respect-dark="1"] {
        --fbt-section-bg: #1a1a1a;
        --fbt-section-border: #2a2a2a;
        --fbt-card-bg: #222;
        --fbt-heading-color: #f0f0f0;
        --fbt-title-color: #ececec;
        --fbt-price-color: #ececec;
    }
}

/* ── Skeleton loader (while AJAX) ────── */
.fbt-skeleton .fbt-img-wrap {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: fbt-shimmer 1.4s infinite;
}

@keyframes fbt-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
