/* =====================================================
   CUSTOM SINGLE PRODUCT
   File: assets/css/single-product.css
   ===================================================== */

/* ---- CUSTOM GALLERY ---- */
.csp-gallery {
    width: 100%;
    margin-bottom: 12px;
}
.csp-gallery-main {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f5f5;
    margin-bottom: 8px;
}
.csp-gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: opacity 0.15s ease;
}
.csp-gallery-thumbs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.csp-gallery-thumb {
    width: 120px;
    height: 120px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s;
}
.csp-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.csp-gallery-thumb:hover {
    border-color: #999;
}
.csp-gallery-thumb.active {
    border-color: #e53935;
}

/* ---- TITLE ---- */
.csp-title {
    font-size: 26px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
    margin: 0 0 10px;
}

/* ---- RATING ---- */
.csp-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}
.csp-stars {
    --pct: calc( var(--rating) / 5 * 100% );
    display: inline-block;
    color: transparent;
    background: linear-gradient(90deg, #f5a623 var(--pct), #ddd var(--pct));
    -webkit-background-clip: text;
    background-clip: text;
    font-size: 18px;
    letter-spacing: 2px;
}
.csp-rating-num { font-weight: 700; color: #333; font-size: 14px; }
.csp-review-count { color: #777; font-size: 14px; }

/* ---- PRICE ---- */
.csp-price-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.csp-sale-price {
    font-size: 24px;
    font-weight: 700;
    color: #e53935;
}
.csp-regular-price {
    font-size: 16px;
    color: #999;
    text-decoration: line-through;
}
.csp-discount-badge {
    background: #e53935;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

/* ---- ATTR GROUP ---- */
.csp-attr-group {
    margin-bottom: 18px;
}
.csp-attr-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.csp-sizing-chart {
    font-size: 13px;
    font-weight: 400;
    color: #555;
    text-decoration: none;
    border-bottom: 1px dashed #999;
}
.csp-sizing-chart:hover { color: #000; }

/* ---- COLOR SWATCHES ---- */
.csp-swatches {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.csp-swatch {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    padding: 2px;
    cursor: pointer;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.2s;
}
.csp-swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    display: block;
}
.csp-swatch.active,
.csp-swatch:hover {
    border-color: #1a1a1a;
}

/* ---- SIZE BUTTONS ---- */
.csp-size-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.csp-size-btn {
        min-width: 55px;
    height: auto;
    padding: 0 10px;
    border: 1.5px solid #ddd;
    border-radius: 50px;
    background: #fff;
    color: #333;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
}
.csp-size-btn:hover { border-color: #555; }
.csp-size-btn.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}
.csp-size-btn.out-of-stock {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* ---- BUNDLE OPTIONS ---- */
.csp-bundles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.csp-bundle {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    flex-wrap: wrap;
}
.csp-bundle input[type="radio"] {
    accent-color: #e53935;
    margin-top: 3px;
    flex-shrink: 0;
    font-size: 23px;
    width: 18px;
    height: 18px;
    margin: 3px 0 0;
}
.csp-bundle:has(input:checked) {
    border-color: #e53935;
    background: #fff9f9;
}
.csp-bundle.best-choice {
    border-color: #e53935;
}
.csp-bundle-badge {
       position: absolute;
       top: -9px;
       right: 20px;
       background: #af0a0a;
       color: #fff;
       font-size: 10px;
       font-weight: 700;
       padding: 3px 10px;
       border-radius: 0 0 8px 8px;
       letter-spacing: 0.5px;
}

.csp-bundle-badge:before {
    display: block;
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    content: "";
    border-bottom-width: 8px;
    border-bottom-style: solid;
    filter: brightness(.7);
    border-bottom-color: #fa0f0f;
    font-size: 12px;
    font-weight: 700;
    left: -8px;
    border-left: 8px solid transparent;
}


.csp-bundle-badge:after {
    display: block;
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    content: "";
    border-bottom-width: 8px;
    border-bottom-style: solid;
    filter: brightness(.7);
    border-bottom-color: #fa0f0f;
    font-size: 12px;
    font-weight: 700;
    /* left: 0; */
    border-left: 8px solid transparent;
    right: -8px;
    border-right: 8px solid transparent;
}

.csp-bundle-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.csp-bundle-label {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
}
.csp-bundle-save {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
}
.csp-bundle-pct {
    font-size: 12px;
    color: #777;
    font-weight: normal;
    text-transform: uppercase;
}
.csp-bundle-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.csp-bundle-price {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}
.csp-bundle-original {
    font-size: 14px;
    color: #AAA;
    text-decoration: line-through;
    font-weight: normal;
}

/* ---- BUNDLE UNIT ROWS ---- */
.csp-bundle-units {
    display: none; /* ẩn mặc định, JS show khi bundle được chọn */
    width: 100%;
    margin-top: 0;
    padding-top: 10px;
    border-top: 1px solid #eee;
    flex-direction: column;
    gap: 8px;
}
.csp-bundle:has(input:checked) .csp-bundle-units {
    display: flex;
}
.csp-units-header {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.csp-bundle-unit-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.csp-unit-num {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    min-width: 24px;
}
.csp-unit-color,
.csp-unit-size,
.csp-unit-select {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
    margin-bottom: 0;
}
.csp-unit-color:focus,
.csp-unit-size:focus,
.csp-unit-select:focus { outline: none; border-color: #888; }

/* ---- ADD TO CART ---- */
.csp-atc-wrap {
    margin-top: 4px;
}
.csp-atc-btn {
    width: 100%;
    padding: 16px;
    background: #e65100;
    color: #fff;
    font-size: 16px;
    line-height: 1.5;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: background 0.2s, transform 0.1s;
    height: 100%;
    box-sizing: border-box;
    padding: 12px;
    border-radius: 7px;
}
.csp-atc-btn:hover { background: #bf360c; }
.csp-atc-btn:active { transform: scale(0.98); }
.csp-atc-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
    .csp-title { font-size: 20px; }
    .csp-size-buttons { gap: 6px; }
    .csp-size-btn { min-width: 42px; height: 36px; font-size: 13px; }
    .csp-bundle { padding: 12px; }
    .csp-bundle-label { font-size: 14px; }
    .csp-bundle-price { font-size: 16px; }
}

/* ================================================================
   CART DRAWER
   ================================================================ */
.csp-cart-drawer {
    position: fixed;
    inset: 0;
    z-index: 999999;
    pointer-events: none;
}
.csp-cart-drawer.open {
    pointer-events: all;
}
.csp-cart-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s;
}
.csp-cart-drawer.open .csp-cart-overlay {
    opacity: 1;
}
.csp-cart-panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: #fff;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(.4,0,.2,1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.18);
}
.csp-cart-drawer.open .csp-cart-panel {
    transform: translateX(0);
}

/* Header */
.csp-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #111;
    color: #fff;
    flex-shrink: 0;
}
.csp-cart-title {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}
.csp-cart-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.75;
    transition: opacity 0.15s;
}
.csp-cart-close:hover { opacity: 1; }

/* Reserved bar */
.csp-cart-reserved-bar {
    background: #222;
    color: #fff;
    font-size: 13px;
    text-align: center;
    padding: 7px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}
#csp-cart-timer { font-weight: 700; }

/* Items scrollable area */
.csp-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.csp-cart-item {
    display: flex;
    gap: 12px;
    position: relative;
    padding-right: 4px;
}
.csp-item-remove {
    position: absolute;
    top: 0; right: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.4;
    padding: 0;
    transition: opacity 0.15s;
}
.csp-item-remove:hover { opacity: 1; }
.csp-item-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    border: 1px solid #eee;
}
.csp-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 20px;
}
.csp-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
}
.csp-item-variant {
    font-size: 12px;
    color: #777;
}
.csp-item-qty-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0;
}
.csp-qty-btn {
    width: 26px;
    height: 26px;
    border: 1.5px solid #ddd;
    border-radius: 50%;
    background: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: border-color 0.15s;
}
.csp-qty-btn:hover { border-color: #888; }
.csp-item-qty {
    font-size: 14px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}
.csp-item-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.csp-item-regular {
    font-size: 12px;
    color: #bbb;
    text-decoration: line-through;
}
.csp-item-sale {
    font-size: 14px;
    font-weight: 700;
    color: #e53935;
}
.csp-item-savings {
    font-size: 11px;
    color: #e65100;
    font-weight: 600;
}

/* Upsell */
.csp-cart-upsell {
    border-top: 1px solid #f0f0f0;
    padding: 12px 16px;
    flex-shrink: 0;
}
.csp-upsell-item {
    display: flex;
    gap: 12px;
    align-items: center;
}
.csp-upsell-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid #eee;
}
.csp-upsell-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.csp-upsell-name {
    font-size: 12px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
}
.csp-upsell-price-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.csp-upsell-regular {
    font-size: 11px;
    color: #bbb;
    text-decoration: line-through;
}
.csp-upsell-sale {
    font-size: 13px;
    font-weight: 700;
    color: #e53935;
}
.csp-upsell-selects {
    display: flex;
    gap: 6px;
}
.csp-upsell-color,
.csp-upsell-size {
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
    cursor: pointer;
    max-width: 90px;
}
.csp-upsell-add {
    background: #e65100;
    color: #fff;
    border: none;
    padding: 7px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    align-self: flex-end;
    white-space: nowrap;
    transition: background 0.2s;
}
.csp-upsell-add:hover { background: #bf360c; }
.csp-upsell-add.loading { opacity: 0.6; pointer-events: none; }

/* ---- Bundle Group in Cart Drawer ---- */
.csp-cart-bundle-group {
    border: 1.5px solid #f0e6ff;
    border-radius: 10px;
    overflow: hidden;
    background: #fafafa;
}
.csp-bundle-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f3e8ff;
    border-bottom: 1px solid #e8d5ff;
}
.csp-bundle-group-label {
    font-size: 12px;
    font-weight: 700;
    color: #6a1b9a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.csp-bundle-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #999;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
}
.csp-bundle-remove:hover { color: #e53935; }
.csp-bundle-group-items {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 8px 12px;
}
.csp-bundle-group-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed #ebebeb;
}
.csp-bundle-group-item:last-child {
    border-bottom: none;
}
.csp-bundle-group-item .csp-item-img {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #eee;
}
.csp-bundle-group-item .csp-item-info {
    flex: 1;
    padding-right: 0;
    gap: 2px;
}
.csp-bundle-group-price {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 10px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-wrap: wrap;
}
.csp-bundle-group-price .csp-item-regular {
    font-size: 12px;
}
.csp-bundle-group-price .csp-item-sale {
    font-size: 15px;
}
.csp-bundle-group-price .csp-item-savings {
    font-size: 11px;
    margin-left: auto;
}

/* Footer totals */
.csp-cart-footer {
    border-top: 1px solid #eee;
    padding: 14px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}
.csp-cart-totals {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.csp-cart-savings-row,
.csp-cart-subtotal-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}
.csp-cart-savings-row {
    color: #e65100;
    font-weight: 600;
}
.csp-savings-val { font-weight: 700; }
.csp-cart-subtotal-row {
    font-weight: 700;
    font-size: 15px;
    color: #1a1a1a;
}
.csp-checkout-link {
    display: block;
    background: #e65100;
    color: #fff !important;
    text-align: center;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none !important;
    transition: background 0.2s;
}
.csp-checkout-link:hover { background: #bf360c; }
.csp-payment-icons {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}
.csp-payment-icons span {
    font-size: 10px;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 2px 6px;
    background: #fafafa;
}
body.csp-drawer-open { overflow: hidden; }

@media (max-width: 480px) {
    .csp-cart-panel { width: 100vw; }
}
