/**
 * Affiliate Product Box - Elite Aurora Glow & Linear Bento Design System
 * Inspired by Linear.app, Copilot Money, and Modern E-Commerce Cards
 */

:root {
    --apb-bg: #ffffff;
    --apb-bg-gradient: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    --apb-border: #e2e8f0;
    --apb-border-hover: #cbd5e1;
    --apb-card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --apb-card-shadow-hover: 0 20px 35px -10px rgba(0, 0, 0, 0.14), 0 10px 15px -5px rgba(0, 0, 0, 0.06);

    /* Product Showcase Pedestal */
    --apb-img-bg: #ffffff;
    --apb-img-border: #e2e8f0;
    --apb-img-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);

    --apb-text-main: #0f172a;
    --apb-text-muted: #64748b;
    --apb-price: #059669;
    --apb-star: #f59e0b;
    --apb-star-empty: #e2e8f0;

    /* Badge */
    --apb-badge-bg: rgba(99, 102, 241, 0.1);
    --apb-badge-border: rgba(99, 102, 241, 0.25);
    --apb-badge-text: #4f46e5;
    --apb-badge-dot: #10b981;

    /* Store Buttons */
    --apb-amazon-bg: linear-gradient(135deg, #ffaa00 0%, #ff9900 100%);
    --apb-amazon-hover: linear-gradient(135deg, #f59500 0%, #e68a00 100%);
    --apb-amazon-text: #111827;
    --apb-amazon-glow: rgba(255, 153, 0, 0.35);

    --apb-aliexpress-bg: linear-gradient(135deg, #ff3b30 0%, #e62e04 100%);
    --apb-aliexpress-hover: linear-gradient(135deg, #e62e04 0%, #c41e00 100%);
    --apb-aliexpress-text: #ffffff;
    --apb-aliexpress-glow: rgba(230, 46, 4, 0.35);

    --apb-official-bg: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --apb-official-hover: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    --apb-official-text: #ffffff;
    --apb-official-glow: rgba(37, 99, 235, 0.35);

    --apb-radius-card: 22px;
    --apb-radius-img: 16px;
    --apb-radius-btn: 12px;
    --apb-transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Adaptive Dark Mode (Aurora Glow / Deep Space Canvas)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --apb-bg: #0f131f;
        --apb-bg-gradient: linear-gradient(145deg, #151b2a 0%, #0d111b 100%);
        --apb-border: rgba(255, 255, 255, 0.08);
        --apb-border-hover: rgba(99, 102, 241, 0.35);
        --apb-card-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.1), 0 12px 36px -8px rgba(0, 0, 0, 0.6);
        --apb-card-shadow-hover: inset 0 1px 1px 0 rgba(255, 255, 255, 0.16), 0 24px 48px -12px rgba(0, 0, 0, 0.75), 0 0 35px -10px rgba(99, 102, 241, 0.25);

        --apb-img-bg: #ffffff; /* Clean luminous pedestal so product photos shine without harsh dark cutoffs */
        --apb-img-border: rgba(255, 255, 255, 0.15);
        --apb-img-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);

        --apb-text-main: #f8fafc;
        --apb-text-muted: #94a3b8;
        --apb-price: #10b981;
        --apb-star-empty: #334155;

        --apb-badge-bg: rgba(99, 102, 241, 0.16);
        --apb-badge-border: rgba(129, 140, 248, 0.35);
        --apb-badge-text: #c7d2fe;
        --apb-badge-dot: #10b981;
    }
}

/* Explicit Dark Theme Classes Support */
body.dark :root,
body[class*="dark"] .apb-product-card,
[data-theme="dark"] .apb-product-card,
.dark .apb-product-card,
.theme-dark .apb-product-card {
    --apb-bg: #0f131f !important;
    --apb-bg-gradient: linear-gradient(145deg, #151b2a 0%, #0d111b 100%) !important;
    --apb-border: rgba(255, 255, 255, 0.08) !important;
    --apb-border-hover: rgba(99, 102, 241, 0.35) !important;
    --apb-card-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.1), 0 12px 36px -8px rgba(0, 0, 0, 0.6) !important;
    --apb-card-shadow-hover: inset 0 1px 1px 0 rgba(255, 255, 255, 0.16), 0 24px 48px -12px rgba(0, 0, 0, 0.75), 0 0 35px -10px rgba(99, 102, 241, 0.25) !important;

    --apb-img-bg: #ffffff !important;
    --apb-img-border: rgba(255, 255, 255, 0.15) !important;
    --apb-img-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;

    --apb-text-main: #f8fafc !important;
    --apb-text-muted: #94a3b8 !important;
    --apb-price: #10b981 !important;
    --apb-star-empty: #334155 !important;

    --apb-badge-bg: rgba(99, 102, 241, 0.16) !important;
    --apb-badge-border: rgba(129, 140, 248, 0.35) !important;
    --apb-badge-text: #c7d2fe !important;
    --apb-badge-dot: #10b981 !important;
}

/* ==========================================================================
   Main Product Card Component
   ========================================================================== */
.apb-product-card {
    position: relative;
    background-color: var(--apb-bg);
    background-image: var(--apb-bg-gradient);
    border: 1px solid var(--apb-border);
    border-radius: var(--apb-radius-card);
    padding: 26px;
    margin: 36px 0;
    box-shadow: var(--apb-card-shadow);
    transition: var(--apb-transition);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
    text-align: left;
    direction: ltr;
    line-height: 1.5;
}

.apb-product-card *,
.apb-product-card *::before,
.apb-product-card *::after {
    box-sizing: border-box;
}

.apb-product-card:hover {
    border-color: var(--apb-border-hover);
    box-shadow: var(--apb-card-shadow-hover);
    transform: translateY(-2px);
}

/* ==========================================================================
   Floating Frosted Badge (Pill with Neon Dot)
   ========================================================================== */
.apb-badge {
    position: absolute;
    top: 18px;
    right: 18px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--apb-badge-bg);
    border: 1px solid var(--apb-badge-border);
    color: var(--apb-badge-text);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 9999px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.15);
    z-index: 2;
    line-height: 1.3;
}

.apb-badge-dot {
    width: 7px;
    height: 7px;
    background-color: var(--apb-badge-dot);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--apb-badge-dot);
    animation: apb-breathing-pulse 2.2s infinite;
}

@keyframes apb-breathing-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 8px var(--apb-badge-dot);
    }
    50% {
        transform: scale(1.35);
        opacity: 0.65;
        box-shadow: 0 0 14px var(--apb-badge-dot);
    }
}

/* ==========================================================================
   Inner Bento Grid Layout
   ========================================================================== */
.apb-card-inner {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 28px;
    align-items: center;
}

/* ==========================================================================
   Product Image Showcase Gallery Pedestal
   ========================================================================== */
.apb-image-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #ffffff !important;
    border-radius: var(--apb-radius-img) !important;
    padding: 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
    transition: var(--apb-transition) !important;
}

.apb-image-box {
    width: 100%;
    height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.apb-product-img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    transition: var(--apb-transition);
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    display: block;
}

.apb-product-card:hover .apb-product-img {
    transform: scale(1.05);
}

/* ==========================================================================
   Content Details Section
   ========================================================================== */
.apb-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.apb-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Rating Stars */
.apb-rating {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--apb-text-muted);
}

.apb-stars-outer {
    position: relative;
    display: inline-block;
    font-size: 15px;
    line-height: 1;
    color: var(--apb-star-empty);
    letter-spacing: 2px;
}

.apb-stars-outer::before {
    content: "★★★★★";
}

.apb-stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    color: var(--apb-star);
    line-height: 1;
}

.apb-stars-inner::before {
    content: "★★★★★";
}

.apb-rating-score {
    color: var(--apb-text-main);
}

/* Product Title - Monumental Typography */
.apb-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 1.35rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    line-height: 1.35 !important;
    color: var(--apb-text-main) !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Price Tag Component */
.apb-price-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.apb-price-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--apb-text-muted);
}

.apb-price-value {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--apb-price);
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

/* Price Check Radar Tag (When price is not fixed) */
.apb-price-tag-check {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: rgba(16, 185, 129, 0.1) !important;
    border: 1px solid rgba(16, 185, 129, 0.25) !important;
    padding: 5px 14px !important;
    border-radius: 9999px !important;
    width: fit-content !important;
    margin-top: 4px !important;
}

.apb-price-pulse-dot {
    width: 7px !important;
    height: 7px !important;
    background: #10b981 !important;
    border-radius: 50% !important;
    box-shadow: 0 0 8px #10b981 !important;
    animation: apb-breathing-pulse 1.8s infinite !important;
    flex-shrink: 0 !important;
}

.apb-price-label-check {
    font-size: 0.84rem !important;
    font-weight: 700 !important;
    color: #10b981 !important;
    letter-spacing: 0.02em !important;
}
}

/* Description */
.apb-description {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--apb-text-muted);
}

/* Features List */
.apb-features-list {
    list-style: none !important;
    margin: 4px 0 !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.apb-features-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    color: var(--apb-text-main);
    margin: 0 !important;
    padding: 0 !important;
}

.apb-check-icon {
    width: 17px;
    height: 17px;
    color: #10b981;
    flex-shrink: 0;
}

/* ==========================================================================
   Store Action Buttons (High-Conversion Gradient Controls)
   ========================================================================== */
.apb-actions-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.apb-btn {
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 9px !important;
    padding: 12px 20px !important;
    border-radius: var(--apb-radius-btn) !important;
    font-size: 0.94rem !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    text-align: center !important;
    transition: var(--apb-transition) !important;
    border: none !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
    overflow: hidden;
}

.apb-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.apb-btn-arrow {
    font-size: 1.1em;
    line-height: 1;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.75;
}

.apb-btn:hover .apb-btn-arrow {
    transform: translate(2px, -2px);
    opacity: 1;
}

/* Amazon Button */
.apb-btn-amazon {
    background: var(--apb-amazon-bg) !important;
    color: var(--apb-amazon-text) !important;
    box-shadow: 0 4px 14px var(--apb-amazon-glow) !important;
}

.apb-btn-amazon:hover {
    background: var(--apb-amazon-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 153, 0, 0.45) !important;
    color: var(--apb-amazon-text) !important;
}

/* AliExpress Button */
.apb-btn-aliexpress {
    background: var(--apb-aliexpress-bg) !important;
    color: var(--apb-aliexpress-text) !important;
    box-shadow: 0 4px 14px var(--apb-aliexpress-glow) !important;
}

.apb-btn-aliexpress:hover {
    background: var(--apb-aliexpress-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(230, 46, 4, 0.5) !important;
    color: var(--apb-aliexpress-text) !important;
}

/* Official Store Button */
.apb-btn-official {
    background: var(--apb-official-bg) !important;
    color: var(--apb-official-text) !important;
    box-shadow: 0 4px 14px var(--apb-official-glow) !important;
}

.apb-btn-official:hover {
    background: var(--apb-official-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.5) !important;
    color: var(--apb-official-text) !important;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 768px) {
    .apb-product-card {
        padding: 20px;
        margin: 24px 0;
    }

    .apb-card-inner {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .apb-image-wrapper {
        max-width: 280px;
        margin: 0 auto;
        width: 100%;
    }

    .apb-image-box {
        height: 180px;
    }

    .apb-title {
        font-size: 1.2rem !important;
    }

    .apb-actions-group {
        grid-template-columns: 1fr;
    }

    .apb-btn {
        width: 100% !important;
        padding: 13px 20px !important;
    }
}
