/*
 * Alpine Cart Page — Clean Shopify-style design
 * Mobile-first, RTL
 */

/* ── Variables ── */
:root {
    --ac-red: #e0192e;
    --ac-red-dark: #c01729;
    --ac-text: #1a1a1a;
    --ac-text-light: #6b7280;
    --ac-bg: #f5f5f5;
    --ac-white: #fff;
    --ac-border: #e5e7eb;
    --ac-green: #16a34a;
    --ac-radius: 10px;
    --ac-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

/* ── Reset ── */
.alpine-cart-page { margin: 0; padding: 0; background: var(--ac-bg); color: var(--ac-text); font-family: 'Atlas AAA', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 15px; line-height: 1.5; direction: rtl; }
.alpine-cart-page * { box-sizing: border-box; }
.alpine-cart-page #wrapper,
.alpine-cart-page .site-footer { display: none !important; }

/* ── Wrap ── */
.ac-wrap { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header ── */
.ac-header { background: var(--ac-white); border-bottom: 1px solid var(--ac-border); position: sticky; top: 0; z-index: 100; }
.ac-header-inner { max-width: 1100px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; }
.ac-logo img { height: 36px; width: auto; display: block; }
.ac-secure { display: inline-flex; align-items: center; gap: 6px; background: var(--ac-green); color: #fff; padding: 5px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.ac-secure i { font-size: 12px; }

/* ── Steps indicator ── */
.ac-steps { background: var(--ac-white); border-bottom: 1px solid var(--ac-border); padding: 12px 20px; }
.ac-steps-inner { max-width: 360px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 12px; }
.ac-step { font-size: 13px; color: var(--ac-text-light); font-weight: 500; }
.ac-step.active { color: var(--ac-red); font-weight: 700; }
.ac-step-divider { width: 24px; height: 1px; background: var(--ac-border); }

/* ── Main ── */
.ac-main { flex: 1; max-width: 1100px; width: 100%; margin: 0 auto; padding: 24px 20px; }

/* ── Grid ── */
.ac-grid { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }

/* ── Section head ── */
.ac-section-head h1 { font-size: 22px; font-weight: 700; margin: 0 0 16px; }
.ac-count { color: var(--ac-text-light); font-weight: 400; }

/* ── Items ── */
.ac-items { background: var(--ac-white); border-radius: var(--ac-radius); box-shadow: var(--ac-shadow); overflow: hidden; }

.ac-item { display: flex; gap: 16px; padding: 16px; border-bottom: 1px solid var(--ac-border); transition: opacity .2s, transform .2s; }
.ac-item:last-child { border-bottom: none; }
.ac-item.removing { opacity: 0; transform: translateX(-20px); }

.ac-item-img { flex-shrink: 0; width: 90px; height: 90px; overflow: hidden; border-radius: 8px; }
.ac-item-img img { border-radius: 10px; width: 100%; height: 100%; object-fit: scale-down; object-position: center; border: 1px solid var(--ac-border); display: table; aspect-ratio: 1 / 1; }
.ac-item-img a { display: block; }

.ac-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.ac-item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.ac-item-name { font-size: 15px; font-weight: 600; color: var(--ac-text); text-decoration: none; line-height: 1.3; }
.ac-item-name:hover { color: var(--ac-red); }

.ac-item-remove { background: none; border: none; cursor: pointer; color: #9ca3af; padding: 4px; font-size: 14px; line-height: 1; flex-shrink: 0; transition: color .15s; }
.ac-item-remove:hover { color: var(--ac-red); }

.ac-item-meta { font-size: 13px; color: var(--ac-text-light); margin-bottom: 8px; display: flex; gap: 12px; flex-wrap: wrap; }

.ac-item-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.ac-item-price { font-size: 15px; font-weight: 700; color: var(--ac-text); white-space: nowrap; }

/* ── Quantity ── */
.ac-qty { display: inline-flex; align-items: center; border: 1px solid var(--ac-border); border-radius: 6px; overflow: hidden; height: 34px; }
.ac-qty-btn { width: 34px; height: 100%; border: none; background: var(--ac-bg); color: var(--ac-text); font-size: 16px; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.ac-qty-btn:hover { background: var(--ac-red); color: #fff; }
.ac-qty-btn.ac-qty-delete { color: var(--ac-red); font-size: 13px; }
.ac-qty-btn.ac-qty-delete:hover { background: var(--ac-red); color: #fff; }
.ac-qty-input { width: 40px; height: 100%; border: none; border-right: 1px solid var(--ac-border); border-left: 1px solid var(--ac-border); text-align: center; font-size: 14px; font-weight: 600; color: var(--ac-text); background: var(--ac-white); outline: none; -moz-appearance: textfield; }
.ac-qty-input::-webkit-outer-spin-button,
.ac-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Continue shopping ── */
.ac-continue { display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; font-size: 14px; color: var(--ac-text-light); text-decoration: none; font-weight: 500; transition: color .15s; }
.ac-continue:hover { color: var(--ac-red); }

/* ── Summary ── */
.ac-summary-col { position: sticky; top: 80px; }
.ac-summary { background: var(--ac-white); border-radius: var(--ac-radius); box-shadow: var(--ac-shadow); padding: 24px; }
.ac-summary h2 { font-size: 18px; font-weight: 700; margin: 0 0 20px; }

/* Coupon */
.ac-coupon { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--ac-border); }
.ac-coupon-row { display: flex; gap: 0; border: 1px solid var(--ac-border); border-radius: 8px; overflow: hidden; transition: border-color .15s; }
.ac-coupon-row:focus-within { border-color: var(--ac-red); }
.ac-coupon-input { flex: 1; border: none; padding: 10px 14px; font-size: 14px; outline: none; background: transparent; font-family: inherit; }
.ac-coupon-btn { border: none; background: var(--ac-red); color: #fff; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s; font-family: inherit; }
.ac-coupon-btn:hover { background: var(--ac-red-dark); }

.applied-coupons { margin-top: 10px; }
.applied-coupon { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #dcfce7; border-radius: 6px; margin-bottom: 6px; font-size: 13px; color: #166534; }
.applied-coupon .remove-coupon { color: #166534; text-decoration: none; font-size: 18px; line-height: 1; }
.applied-coupon .remove-coupon:hover { color: #991b1b; }

/* Totals */
.ac-totals { margin-bottom: 20px; }
.ac-totals-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 15px; border-bottom: 1px solid #f3f4f6; }
.ac-totals-row:last-child { border-bottom: none; }
.ac-discount { color: var(--ac-green); }
.ac-vat-row { font-size: 13px; color: var(--ac-text-light); }
.ac-total { font-size: 18px; font-weight: 700; border-top: 2px solid var(--ac-text); border-bottom: none; padding-top: 12px; margin-top: 4px; }
.ac-total span:last-child { color: var(--ac-red); }
span.woocommerce-Price-amount.amount bdi { justify-content: end; }

/* Checkout button */
.ac-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 24px; border-radius: 8px; font-size: 16px; font-weight: 700; text-decoration: none; cursor: pointer; transition: all .2s; border: none; font-family: inherit; }
.ac-btn-primary { background: var(--ac-red); color: #fff; }
.ac-btn-primary:hover { background: var(--ac-red-dark); }
.ac-btn-checkout { width: 100%; background: var(--ac-text); color: #fff; border-radius: 8px; font-size: 17px; padding: 16px; letter-spacing: .3px; }
.ac-btn-checkout:hover { background: #000; color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }

/* Trust badges */
.ac-trust { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; justify-content: center; }
.ac-trust span { font-size: 12px; color: var(--ac-text-light); display: inline-flex; align-items: center; gap: 4px; background: var(--ac-bg); padding: 6px 10px; border-radius: 6px; }
.ac-trust i { color: var(--ac-green); font-size: 11px; }

/* Help */
.ac-help { text-align: center; margin-top: 16px; font-size: 13px; color: var(--ac-text-light); }
.ac-help a { color: #25d366; text-decoration: none; font-weight: 600; }
.ac-help a:hover { text-decoration: underline; }

/* ── Empty cart ── */
.ac-empty { text-align: center; padding: 80px 20px; background: var(--ac-white); border-radius: var(--ac-radius); box-shadow: var(--ac-shadow); }
.ac-empty i { font-size: 56px; color: #d1d5db; margin-bottom: 16px; display: block; }
.ac-empty h2 { font-size: 22px; margin: 0 0 8px; }
.ac-empty p { color: var(--ac-text-light); margin: 0 0 24px; }

/* ── Toast ── */
.ac-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); padding: 12px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; color: #fff; z-index: 10000; opacity: 0; transition: all .3s ease; pointer-events: none; white-space: nowrap; }
.ac-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ac-toast-success { background: var(--ac-green); }
.ac-toast-error { background: #dc2626; }

/* ── Popup ── */
.ac-popup { position: fixed; inset: 0; z-index: 99999; display: none; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity .3s; }
.ac-popup.show { opacity: 1; }
.ac-popup-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.75); backdrop-filter: blur(6px); }

.ac-popup-box {
    position: relative;
    background: var(--ac-white);
    border-radius: 18px;
    max-width: 880px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.1);
    display: flex;
    flex-direction: column;
    animation: popupSlideIn .4s cubic-bezier(.16,1,.3,1);
}
@keyframes popupSlideIn { from { transform: translateY(30px) scale(.96); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* Popup header — bold gradient with urgency */
.ac-popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: linear-gradient(135deg, #e0192e 0%, #ff4757 50%, #c01729 100%);
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.ac-popup-head::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,.04) 10px, rgba(255,255,255,.04) 20px);
}
.ac-popup-head-content { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; flex-wrap: wrap; }
.ac-popup-head h3 { margin: 0; font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 3px rgba(0,0,0,.2); }
.ac-popup-head h3 i { animation: fireFlicker 1s ease-in-out infinite alternate; }
@keyframes fireFlicker { 0% { transform: scale(1) rotate(-5deg); } 100% { transform: scale(1.2) rotate(5deg); } }
.ac-popup-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,.2);
    backdrop-filter: blur(4px);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.popup-close { background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 24px; cursor: pointer; padding: 0; line-height: 1; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all .2s; position: relative; z-index: 1; }
.popup-close:hover { background: rgba(255,255,255,.3); transform: rotate(90deg); }

/* Popup body */
.ac-popup-body { padding: 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }
.ac-popup-subtitle {
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 500;
    color: var(--ac-text-light);
    background: linear-gradient(180deg, #fef3f3, var(--ac-white));
    border-bottom: 1px solid var(--ac-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.ac-popup-limited {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--ac-red);
    font-weight: 700;
    font-size: 13px;
    animation: urgencyBlink 2.5s ease-in-out infinite;
}
@keyframes urgencyBlink { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }

/* ── Popup Products Grid — override WooCommerce ── */
#popup-products-grid { padding: 20px; margin: 0; width: 100%; display: block !important; grid-template: initial !important; }

#popup-products-grid ul.products,
#popup-products-grid .products {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    float: none !important;
}

/* Limit to 8 products (2 rows × 4) */
#popup-products-grid ul.products li.product:nth-child(n+9),
#popup-products-grid .products li.product:nth-child(n+9) { display: none !important; }

/* Product card */
#popup-products-grid ul.products li.product,
#popup-products-grid .products li.product {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    clear: none !important;
    position: relative !important;
    background: var(--ac-white);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    overflow: hidden;
    transition: transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s;
    list-style: none;
    border: 1px solid var(--ac-border);
}
#popup-products-grid li.product:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(224,25,46,.12), 0 4px 12px rgba(0,0,0,.08);
    border-color: rgba(224,25,46,.2);
}

/* Product image */
#popup-products-grid li.product a { display: block; text-decoration: none; color: inherit; }
#popup-products-grid li.product a img,
#popup-products-grid li.product > a > img,
#popup-products-grid li.product .attachment-woocommerce_thumbnail,
#popup-products-grid li.product .wp-post-image {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    object-fit: cover !important;
    display: block !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Product title */
#popup-products-grid li.product .woocommerce-loop-product__title,
#popup-products-grid li.product h2 {
    font-size: 13px !important;
    line-height: 1.35 !important;
    padding: 10px 12px 4px !important;
    margin: 0 !important;
    font-weight: 600 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 40px;
    color: var(--ac-text);
    text-align: center;
}

/* Price */
#popup-products-grid li.product .price {
    padding: 0 12px 8px !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    color: var(--ac-red) !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    text-align: center;
}
#popup-products-grid li.product .price del { font-size: 12px; color: #9ca3af; font-weight: 400; order: 1; }
#popup-products-grid li.product .price ins { text-decoration: none; order: 0; }
#popup-products-grid li.product .price .woocommerce-Price-amount { display: inline; }
#popup-products-grid li.product .price bdi { display: inline; justify-content: center; line-height: 1; }

/* Add to cart button */
#popup-products-grid li.product .button,
#popup-products-grid li.product .add_to_cart_button,
#popup-products-grid li.product a.button,
#popup-products-grid li.product a.add_to_cart_button {
    display: block !important;
    margin: 0 10px 10px !important;
    padding: 9px 8px !important;
    background: linear-gradient(135deg, #1a1a1a, #333) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-align: center !important;
    text-decoration: none !important;
    cursor: pointer !important;
    transition: all .2s !important;
    width: calc(100% - 20px) !important;
    box-sizing: border-box !important;
    letter-spacing: .3px;
}
#popup-products-grid li.product .button:hover,
#popup-products-grid li.product a.button:hover {
    background: linear-gradient(135deg, var(--ac-red), var(--ac-red-dark)) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(224,25,46,.3) !important;
}
#popup-products-grid li.product .added_to_cart {
    display: block !important;
    margin: 4px 10px 10px !important;
    padding: 7px !important;
    background: var(--ac-green) !important;
    color: #fff !important;
    border-radius: 8px !important;
    font-size: 11px !important;
    text-align: center !important;
    text-decoration: none !important;
    font-weight: 600;
}

/* Sale badge — prominent */
#popup-products-grid li.product .onsale {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    left: auto !important;
    background: var(--ac-red) !important;
    color: #fff !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    line-height: 1 !important;
    margin: 0 !important;
    z-index: 3 !important;
    box-shadow: 0 2px 8px rgba(224,25,46,.3);
}

/* Hide extra elements inside popup product cards */
#popup-products-grid li.product .star-rating,
#popup-products-grid li.product .alpine-product-gallery,
#popup-products-grid li.product .alpine-brand-name,
#popup-products-grid li.product .alpine-brand-logo-overlay,
#popup-products-grid li.product .tinv-wraper.tinv-wishlist { display: none !important; }

/* Hide brand overlays in popup */
.ac-popup .alpine-brand-name,
.ac-popup .alpine-brand-logo-overlay.alpine-brand-name-overlay { display: none !important; }

/* Hide brand overlays */
.alpine-brand-name,
.alpine-brand-logo-overlay.alpine-brand-name-overlay { display: none !important; }

/* ── Responsive ── */

@media (max-width: 1024px) {
    .ac-grid { grid-template-columns: 1fr 340px; gap: 20px; }
}

@media (max-width: 768px) {
    .ac-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .ac-summary-col {
        position: static;
    }
    .ac-main { padding: 16px 12px; }
    .ac-section-head h1 { font-size: 20px; }
    .ac-item { padding: 14px 12px; gap: 12px; }
    .ac-item-img { width: 80px; height: 80px; }
    .ac-item-name { font-size: 14px; }
    .ac-item-price { font-size: 14px; }
    .ac-summary { padding: 18px 14px; }
    .ac-summary h2 { font-size: 16px; margin-bottom: 16px; }
    .ac-btn-checkout { font-size: 16px; padding: 14px; }
    .ac-steps { padding: 10px 16px; }
    .ac-popup { padding: 10px; }
    .ac-popup-box { max-height: 95vh; border-radius: 14px; }
    .ac-popup-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .ac-popup-head { padding: 14px 18px; }
    .ac-popup-head h3 { font-size: 18px; }
    .ac-popup-badge { font-size: 11px; padding: 4px 10px; }
    .ac-popup-subtitle { padding: 10px 18px; font-size: 13px; }
    #popup-products-grid { padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    #popup-products-grid ul.products,
    #popup-products-grid .products { grid-template-columns: repeat(3, 1fr) !important; gap: 12px !important; }
    /* Show max 6 on tablet */
    #popup-products-grid ul.products li.product:nth-child(n+7),
    #popup-products-grid .products li.product:nth-child(n+7) { display: none !important; }
}

@media (max-width: 480px) {
    .ac-header-inner { padding: 8px 12px; }
    .ac-logo img { height: 30px; }
    .ac-secure { font-size: 11px; padding: 4px 10px; }
    .ac-main { padding: 12px 8px; }
    .ac-item { padding: 12px 10px; gap: 10px; }
    .ac-item-img { width: 72px; height: 72px; }
    .ac-item-name { font-size: 13px; }
    .ac-item-meta { font-size: 12px; }
    .ac-item-price { font-size: 13px; }
    .ac-qty { height: 30px; }
    .ac-qty-btn { width: 30px; font-size: 14px; }
    .ac-qty-input { width: 34px; font-size: 13px; }
    .ac-summary { padding: 14px 12px; }
    .ac-trust span { font-size: 11px; padding: 4px 8px; }
    .ac-popup { padding: 6px; }
    .ac-popup-box { border-radius: 12px; max-height: 92vh; }
    .ac-popup-head { padding: 12px 14px; }
    .ac-popup-head h3 { font-size: 16px; }
    .ac-popup-badge { display: none; }
    .ac-popup-subtitle { padding: 8px 14px; font-size: 12px; flex-direction: column; align-items: flex-start; gap: 4px; }
    #popup-products-grid { padding: 10px; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    #popup-products-grid ul.products,
    #popup-products-grid .products { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    #popup-products-grid li.product .woocommerce-loop-product__title,
    #popup-products-grid li.product h2 { font-size: 12px !important; padding: 8px 8px 3px !important; min-height: 36px; }
    #popup-products-grid li.product .price { font-size: 13px !important; padding: 0 8px 6px !important; }
    #popup-products-grid li.product .button,
    #popup-products-grid li.product a.button { margin: 0 8px 8px !important; padding: 7px !important; font-size: 11px !important; width: calc(100% - 16px) !important; }
}

/* ── Print ── */
@media print {
    .ac-header, .ac-steps, .ac-popup, .ac-help, .ac-trust, .ac-continue { display: none !important; }
    .ac-grid { display: block; }
    .ac-summary-col { position: static; }
    .ac-items, .ac-summary { box-shadow: none; border: 1px solid #ddd; }
}