/* Smart Discounts - Frontend Styles */

/* ====== LOOP BADGE (shop/category pages) ====== */

/* Injected wrapper (fallback method via filter) */
.sd-img-wrap {
    display: block;
    position: relative;
    line-height: 0;
}

.sd-badge--loop {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    display: inline-block;
    padding: 5px 12px;
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.30);
    pointer-events: none;
    white-space: nowrap;
}

/* Stack multiple badges vertically */
.sd-badge--loop ~ .sd-badge--loop {
    top: 38px;
}

/* ── Orchid Store: the card image sits inside .product-thumb-wrap ── */
.woocommerce ul.products li.product,
.woocommerce ul.products li.product .woocommerce-loop-product__link,
.woocommerce ul.products li.product .product-thumb-wrap,
.woocommerce ul.products li.product figure,
.woocommerce ul.products li.product .attachment-woocommerce_thumbnail {
    position: relative;
}

/* Ensure badges always sit on top of the image */
.woocommerce ul.products li.product .sd-badge--loop {
    z-index: 20;
}

/* When badge is rendered via woocommerce_before_shop_loop_item_title
   it sits BELOW the image in DOM, so we use negative margin trick    */
.woocommerce ul.products li.product .woocommerce-loop-product__link + .sd-badge--loop,
.woocommerce ul.products li.product > .sd-badge--loop {
    position: absolute;
    top: 10px;
    left: 10px;
}
.sd-single-badges {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sd-single-badge {
    display: flex;
    align-items: stretch;
    border-radius: 8px;
    border-left: 4px solid var(--sd-color, #e74c3c);
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.sd-single-badge:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    transform: translateX(2px);
}

.sd-single-badge__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    min-width: 52px;
    font-size: 24px;
    background: var(--sd-color, #e74c3c);
}

.sd-single-badge__content {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sd-single-badge__label {
    font-size: 14px;
    font-weight: 800;
    color: var(--sd-color, #e74c3c);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    display: block;
    line-height: 1.2;
}

.sd-single-badge__desc {
    font-size: 13px;
    color: #555;
    line-height: 1.4;
    display: block;
}

/* ====== CART NOTICE ====== */
.sd-cart-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.sd-cart-notice--applied {
    background: #eaffef;
    border: 1px solid #27ae60;
    color: #1a6b3c;
}

.sd-cart-notice__icon {
    font-size: 22px;
    line-height: 1;
}

/* ====== ORCHID STORE COMPATIBILITY ====== */
/* Orchid store uses .product-thumbnail wrapper */
.orchid-store .product-thumbnail {
    position: relative;
}

/* Ensure sale/promo badges don't overlap */
.orchid-store .sd-badge--loop {
    top: 8px;
    left: 8px;
}

/* Orchid Store product card hover compatibility */
.orchid-store ul.products li.product .sd-badge--loop {
    z-index: 5;
}

/* ====== COUNTDOWN TIMER ====== */
.sd-countdown {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(0,0,0,0.04);
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.06);
}

.sd-countdown__clock {
    font-size: 16px;
    line-height: 1;
}

.sd-countdown__label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

.sd-countdown__units {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.sd-countdown__unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--sd-color, #e74c3c);
    border-radius: 6px;
    padding: 4px 8px;
    min-width: 38px;
    color: white;
    transition: background 0.3s;
}

.sd-countdown__num {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
    display: block;
}

.sd-countdown__sub {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    display: block;
    line-height: 1;
}

.sd-countdown__sep {
    font-size: 18px;
    font-weight: 800;
    color: var(--sd-color, #e74c3c);
    line-height: 1;
    padding-bottom: 12px;
    opacity: 0.7;
}

/* Urgent: < 1 hour */
.sd-countdown--urgent .sd-countdown__unit {
    background: #c0392b;
    animation: sd-pulse 1s ease-in-out infinite;
}

.sd-countdown--urgent .sd-countdown__sep {
    color: #c0392b;
}

@keyframes sd-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.75; }
}

.sd-countdown--expired {
    background: #fef0f0;
    border-color: #e74c3c;
    color: #c0392b;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    justify-content: center;
}

.sd-countdown__expired {
    color: #c0392b;
}

/* Responsive */
@media (max-width: 480px) {
    .sd-countdown { gap: 4px; }
    .sd-countdown__num { font-size: 14px; }
    .sd-countdown__unit { min-width: 30px; padding: 3px 5px; }
    .sd-countdown__sub { font-size: 8px; }
}
    .sd-single-badge__label { font-size: 13px; }
    .sd-single-badge__desc  { font-size: 12px; }
    .sd-single-badge__icon  { width: 44px; min-width: 44px; font-size: 20px; }
}

/* ====== CART ITEM BADGE ====== */
.sd-cart-item-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    font-weight: 800;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

/* ====== CATEGORY THUMBNAIL BADGE ====== */
.woocommerce ul.products li.product-category {
    position: relative;
}

/* Injected wrapper via filter */
.sd-cat-img-wrap {
    display: block;
    position: relative;
    line-height: 0;
}

.sd-badge--category {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 20;
    display: inline-block;
    padding: 6px 14px;
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    line-height: 1.4;
    box-shadow: 0 3px 10px rgba(0,0,0,0.35);
    pointer-events: none;
    white-space: nowrap;
}

/* Orchid Store category card wrapper */
.orchid-store .product-category,
.orchid-store ul.products li.product-category,
.woocommerce ul.products li.product-category a {
    position: relative;
    display: block;
}
