/**
 * Build Your Box - Frontend CSS v5.0
 */

:root {
    --anak-primary:       var(--wp--preset--color--primary, #2d7a5e);
    --anak-primary-hover: var(--wp--preset--color--primary-dark, #1a5c45);
    --anak-secondary:     #333;
    --anak-light-bg:      #f8f8f8;
    --anak-border:        #e0e0e0;
    --anak-text-dark:     #333;
    --anak-text-light:    #666;
    --anak-white:         #fff;
    --anak-error:         #dc3545;
    --anak-success:       #28a745;
}

/* ────────────────────────────────────────────────────────────
   LAYOUT
──────────────────────────────────────────────────────────── */
.anak-build-box-container {
    display: flex;
    flex-direction: row;
    gap: 25px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    align-items: flex-start;
}

.anak-box-main {
    flex: 1;
    min-width: 0;
    order: 1;
}

/* FIX 1: Sticky sidebar — stays in place while scrolling */
.anak-box-sidebar {
    width: 280px;
    flex-shrink: 0;
    order: 2;
    position: sticky;
    top: 24px;               /* distance from viewport top */
    align-self: flex-start;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

/* ────────────────────────────────────────────────────────────
   SIDEBAR CARDS
──────────────────────────────────────────────────────────── */
.box-status-card {
    background: var(--anak-white);
    border: 1px solid var(--anak-border);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.box-status-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    margin: 0 0 12px;
    color: var(--anak-text-dark);
    text-transform: uppercase;
}
.box-status-count {
    font-size: 18px;
    font-weight: 600;
    color: var(--anak-primary);
    margin-bottom: 12px;
}
.box-status-count #anak-selected-qty { font-size: 24px; font-weight: 700; }
.box-count-sep { font-size: 18px; margin: 0 2px; }

.progress-bar {
    height: 8px;
    background: var(--anak-border);
    border-radius: 10px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--anak-primary), var(--anak-primary-hover));
    transition: width .4s cubic-bezier(.4,0,.2,1);
    border-radius: 10px;
}

.selected-items-list {
    background: var(--anak-white);
    border: 1px solid var(--anak-border);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    max-height: 260px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.selected-items-list .empty-message {
    text-align: center;
    color: var(--anak-text-light);
    font-size: 13px;
    padding: 20px 10px;
    margin: 0;
}

.selected-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--anak-border);
}
.selected-item:last-child { border-bottom: none; padding-bottom: 0; }
.selected-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--anak-border); }
.selected-item-info { flex: 1; }
.selected-item-name { font-size: 13px; font-weight: 600; margin: 0 0 4px; line-height: 1.3; color: var(--anak-text-dark); }
.selected-item-qty  { font-size: 12px; color: var(--anak-text-light); margin: 0; }
.selected-item-remove {
    background: var(--anak-error); border: none; color: var(--anak-white);
    font-size: 18px; cursor: pointer; width: 24px; height: 24px;
    line-height: 1; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; transition: all .2s;
}
.selected-item-remove:hover { background: #c82333; transform: scale(1.1); }

.box-sidebar-footer {
    background: var(--anak-white);
    border: 1px solid var(--anak-border);
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.estimated-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--anak-border);
    margin-bottom: 15px;
}
.estimated-total .label { font-size: 13px; font-weight: 600; color: var(--anak-text-dark); }
.estimated-total .amount { font-size: 20px; font-weight: 700; color: var(--anak-primary); }

.free-shipping-notice {
    background: #e8f5e9;
    color: var(--anak-primary);
    padding: 10px 12px;
    border-radius: 6px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 15px;
    letter-spacing: .5px;
}

/* ── Build My Box button (Next Item REMOVED — fix #4) ── */
.build-box-btn {
    width: 100%;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all .3s cubic-bezier(.4,0,.2,1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: .5px;
    background: var(--anak-primary);
    color: var(--anak-white);
    padding: 14px;
}
.build-box-btn:not(:disabled):hover {
    background: var(--anak-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,.2);
}
.build-box-btn:disabled {
    opacity: .5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

/* ────────────────────────────────────────────────────────────
   TABS
──────────────────────────────────────────────────────────── */
.step-indicator { display: none !important; }

.product-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--anak-border);
    overflow-x: auto;
}
.tab-btn {
    background: none; border: none; padding: 12px 20px;
    font-size: 13px; font-weight: 600; color: var(--anak-text-light);
    cursor: pointer; white-space: nowrap;
    border-bottom: 3px solid transparent; transition: all .3s;
    position: relative; top: 2px;
}
.tab-btn:hover { color: var(--anak-primary); }
.tab-btn.active { color: var(--anak-primary); border-bottom-color: var(--anak-primary); }

/* ────────────────────────────────────────────────────────────
   PRODUCT GRID
──────────────────────────────────────────────────────────── */
.products-grid { display: grid; gap: 20px; }
.products-grid.columns-2 { grid-template-columns: repeat(2, 1fr); }
.products-grid.columns-3 { grid-template-columns: repeat(3, 1fr); }
.products-grid.columns-4 { grid-template-columns: repeat(4, 1fr); }
.products-grid.columns-5 { grid-template-columns: repeat(5, 1fr); }

/* ── Product Card ── */
.product-card {
    background: var(--anak-white);
    border: 2px solid var(--anak-border);
    border-radius: 12px;
    overflow: hidden;
    transition: all .3s cubic-bezier(.4,0,.2,1);
    position: relative;
    display: flex;
    flex-direction: column;
}
.product-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,.12);
    transform: translateY(-4px);
    border-color: var(--anak-primary);
}
.product-card.has-items {
    border-color: var(--anak-primary);
    border-width: 3px;
    box-shadow: 0 4px 12px rgba(45,122,94,.2);
}

.product-image {
    position: relative;
    background: var(--anak-light-bg);
    aspect-ratio: 1;
    overflow: hidden;
}
.product-image img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.product-card:hover .product-image img { transform: scale(1.04); }

/* Badge overlays */
.product-badge {
    position: absolute; top: 10px; left: 10px; z-index: 2;
    font-size: 10px; font-weight: 800; padding: 4px 8px; border-radius: 5px;
    letter-spacing: .5px; text-transform: uppercase;
}
.badge-sale { background: #ff4d4d; color: #fff; }

.added-badge {
    position: absolute; top: 10px; right: 10px; z-index: 2;
    background: var(--anak-primary); color: #fff;
    font-size: 10px; font-weight: 800; padding: 4px 8px; border-radius: 5px;
    letter-spacing: .5px;
}

.product-info { padding: 12px 15px 8px; flex: 1; display: flex; flex-direction: column; }
.product-title {
    font-size: 15px; font-weight: 700; margin: 0 0 8px; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    color: var(--anak-text-dark);
    transition: color .15s;
}
.product-title:hover { color: var(--anak-primary); }

/* ── FIX 6: Price block — MRP → Sale → % badge ── */
.product-price-block {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-bottom: 2px;
}
.product-mrp {
    font-size: 13px;
    color: var(--anak-text-light);
    text-decoration: line-through;
    font-weight: 500;
}
.product-sale-price {
    font-size: 17px;
    font-weight: 800;
    color: var(--anak-primary);
}
.product-discount-badge {
    background: #ff4d4d;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: .4px;
}

/* ── Product actions ── */
.product-actions { padding: 0 15px 15px; }
.quantity-controls {
    display: flex; align-items: center; justify-content: center; gap: 0;
    margin-bottom: 10px; background: var(--anak-light-bg);
    border-radius: 8px; padding: 4px; border: 2px solid var(--anak-border);
}
.qty-btn {
    background: var(--anak-white); border: none; width: 36px; height: 36px;
    cursor: pointer; font-size: 20px; font-weight: 700; color: var(--anak-text-dark);
    transition: all .2s; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.qty-btn:hover:not(:disabled) { background: var(--anak-primary); color: var(--anak-white); transform: scale(1.1); }
.qty-btn:active:not(:disabled) { transform: scale(.95); }
.qty-btn:disabled { opacity: .3; cursor: not-allowed; }
.qty-input {
    width: 60px; height: 36px; text-align: center; border: none;
    background: var(--anak-white); font-size: 16px; font-weight: 700;
    border-radius: 6px; margin: 0 4px; color: var(--anak-primary); pointer-events: none;
}
.add-to-box-btn {
    width: 100%; background: var(--anak-primary); color: var(--anak-white);
    border: none; border-radius: 8px; padding: 12px; font-size: 13px; font-weight: 700;
    cursor: pointer; transition: all .3s cubic-bezier(.4,0,.2,1);
    letter-spacing: .8px; text-transform: uppercase;
}
.add-to-box-btn:hover { background: var(--anak-primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.2); }

/* ────────────────────────────────────────────────────────────
   FIX 3: QUICK-VIEW MODAL
──────────────────────────────────────────────────────────── */
.anak-qv-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.anak-qv-overlay.open {
    display: flex;
}
/* Prevent body scroll when modal open */
body.anak-qv-open { overflow: hidden; }

.anak-qv-modal {
    background: var(--anak-white);
    border-radius: 16px;
    max-width: 540px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,.25);
    position: relative;
    animation: anakQvSlideIn .22s ease;
}
@keyframes anakQvSlideIn {
    from { opacity:0; transform: translateY(20px) scale(.97); }
    to   { opacity:1; transform: translateY(0)   scale(1); }
}
.anak-qv-close {
    position: absolute; top: 14px; right: 16px;
    background: rgba(0,0,0,.07); border: none; width: 32px; height: 32px;
    border-radius: 50%; font-size: 16px; cursor: pointer; color: #444;
    display: flex; align-items: center; justify-content: center; z-index: 2;
    transition: background .15s;
}
.anak-qv-close:hover { background: rgba(0,0,0,.15); }

.anak-qv-img-wrap {
    position: relative;
    aspect-ratio: 1;
    background: var(--anak-light-bg);
    border-radius: 16px 16px 0 0;
    overflow: hidden;
}
.anak-qv-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.anak-qv-discount-badge {
    display: none;
    position: absolute; top: 14px; left: 14px;
    background: #ff4d4d; color: #fff;
    font-size: 12px; font-weight: 800; padding: 5px 11px; border-radius: 6px;
}
.anak-qv-discount-badge:not(:empty) { display: block; }

.anak-qv-body { padding: 22px 24px 26px; }
.anak-qv-title { font-size: 20px; font-weight: 800; margin: 0 0 12px; color: var(--anak-text-dark); padding-right: 30px; line-height: 1.3; }

/* Price row inside modal (same FIX 6 treatment) */
.anak-qv-price-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.anak-qv-regular   { font-size: 14px; color: var(--anak-text-light); text-decoration: line-through; }
.anak-qv-sale      { font-size: 22px; font-weight: 800; color: var(--anak-primary); }
.anak-qv-pct       { display: none; background: #ff4d4d; color: #fff; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 5px; }
.anak-qv-pct:not(:empty) { display: inline-block; }

.anak-qv-desc {
    font-size: 14px; color: var(--anak-text-light); line-height: 1.65;
    margin-bottom: 18px; border-top: 1px solid var(--anak-border); padding-top: 14px;
}
.anak-qv-add-btn {
    width: 100%; background: var(--anak-primary); color: #fff;
    border: none; border-radius: 10px; padding: 15px; font-size: 15px; font-weight: 800;
    cursor: pointer; transition: background .2s, transform .15s; letter-spacing: .5px;
}
.anak-qv-add-btn:hover { background: var(--anak-primary-hover); transform: translateY(-1px); }

/* ────────────────────────────────────────────────────────────
   CONGRATS RIBBON
──────────────────────────────────────────────────────────── */
.congrats-ribbon {
    position: fixed; top: 20%; left: 50%; transform: translateX(-50%);
    z-index: 10000; animation: ribbonFly 3s ease-out forwards; pointer-events: none;
}
@keyframes ribbonFly {
    0%   { opacity:0; top:-100px; transform: translateX(-50%) rotate(-10deg) scale(.5); }
    20%  { opacity:1; top: 20%;  transform: translateX(-50%) rotate(5deg)   scale(1.1); }
    40%  { transform: translateX(-50%) rotate(-5deg) scale(1); }
    80%  { opacity:1; transform: translateX(-50%) rotate(0deg) scale(1); }
    100% { opacity:0; top: 15%; transform: translateX(-50%) rotate(0deg) scale(.9); }
}
.ribbon-content {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #fff; padding: 20px 40px; border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
    display: flex; align-items: center; gap: 12px;
    font-size: 20px; font-weight: 700;
}
.ribbon-icon { font-size: 28px; animation: iconBounce .6s infinite; }
@keyframes iconBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ────────────────────────────────────────────────────────────
   RESPONSIVE
──────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .products-grid.columns-5 { grid-template-columns: repeat(4, 1fr) !important; }
    .products-grid.columns-4 { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 1024px) {
    .anak-box-sidebar { width: 240px; }
    .products-grid.columns-3,
    .products-grid.columns-4,
    .products-grid.columns-5 { grid-template-columns: repeat(3, 1fr) !important; }
}

/* Tablet/mobile — sidebar hidden, sticky bar shown */
@media (max-width: 768px) {
    .anak-build-box-container {
        flex-direction: column;
        padding: 15px;
        padding-bottom: 148px;
    }
    .anak-box-sidebar { display: none !important; }
    .anak-box-main    { width: 100%; }
    .products-grid.columns-2,
    .products-grid.columns-3,
    .products-grid.columns-4,
    .products-grid.columns-5 { grid-template-columns: repeat(2, 1fr) !important; gap: 15px; }
    .tab-btn { padding: 10px 15px; font-size: 12px; }
}
@media (max-width: 480px) {
    .anak-build-box-container { padding: 10px; padding-bottom: 148px; }
    .products-grid.columns-2,
    .products-grid.columns-3,
    .products-grid.columns-4,
    .products-grid.columns-5 { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }
    .product-title { font-size: 14px; }
    .anak-qv-modal { border-radius: 12px; }
}

/* ────────────────────────────────────────────────────────────
   MOBILE STICKY BAR
──────────────────────────────────────────────────────────── */
.anak-mobile-sticky-bar { display: none; }

@media (max-width: 768px) {
    .anak-mobile-sticky-bar {
        display: flex; align-items: center; justify-content: space-between;
        position: fixed !important; bottom: 60px !important; left: 0 !important; right: 0 !important;
        z-index: 99998; background: var(--anak-white);
        border-top: 2px solid var(--anak-border);
        padding: 10px 16px; box-shadow: 0 -4px 20px rgba(0,0,0,.15);
        gap: 14px; min-height: 68px; margin: 0 !important;
    }
    .anak-sticky-left { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
    .anak-sticky-count { display: flex; align-items: baseline; gap: 3px; font-size: 14px; font-weight: 700; color: var(--anak-text-dark); }
    .anak-sticky-count span:first-child { font-size: 20px; color: var(--anak-primary); }
    .anak-sticky-sep   { color: var(--anak-text-light); font-size: 13px !important; }
    .anak-sticky-label { color: var(--anak-text-light); font-size: 12px !important; font-weight: 500 !important; margin-left: 4px; }
    .anak-sticky-progress { height: 5px; background: var(--anak-border); border-radius: 10px; overflow: hidden; width: 100%; }
    .anak-sticky-progress-fill { height: 100%; background: linear-gradient(90deg, var(--anak-primary), var(--anak-primary-hover)); border-radius: 10px; width: 0%; transition: width .4s cubic-bezier(.4,0,.2,1); }
    .anak-sticky-price { font-size: 13px; font-weight: 600; color: var(--anak-text-light); }
    .anak-sticky-btn {
        background: #111; color: #fff; border: none; border-radius: 50px;
        padding: 13px 20px; font-size: 13px; font-weight: 700; letter-spacing: .5px;
        cursor: pointer; white-space: nowrap; display: flex; align-items: center;
        gap: 6px; transition: all .3s; flex-shrink: 0;
    }
    .anak-sticky-btn:not(:disabled):hover { background: var(--anak-primary); transform: translateY(-1px); }
    .anak-sticky-btn:disabled { opacity: .45; cursor: not-allowed; }
    .anak-sticky-arrow { font-size: 16px; }
    .anak-sticky-btn:disabled,
    .anak-sticky-btn.btn-disabled {
        opacity: .45 !important; cursor: not-allowed !important;
        pointer-events: none !important; transform: none !important; box-shadow: none !important;
    }
}
