/* ============================================
   CUSTOM CART PAGE STYLING
   - Shopee-inspired layout
   - Desktop: items left, summary right
   - Mobile: sticky bottom bar
   ============================================ */

/* ============ BREADCRUMB ============ */

/* ============ CART PAGE CONTAINER (Product-detail style) ============ */
.cart-page {
    padding: 20px 0 40px; /* Same padding as .rc-pdp */
    min-height: 60vh;
}

.cart-page .container {
    /* max-width: 1200px; */
}

:root {
    /* Adopt your ecosystem variables (optional) */
    --rc-orange-dark: #ee4d2d;
    --rc-border: #e0e0e0;
    --rc-bg-light: #f8f9fa;
    --rc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --rc-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --rc-radius-md: 12px;
    --rc-radius-sm: 8px;

    /* Cart palette */
    --cart-green: #22c55e; /* utama (hijau checkout) */
    --cart-green-dark: #16a34a;
    --cart-border: #e5e7eb;
    --cart-bg: #ffffff;
    --cart-muted: #f9fafb;
    --cart-text: #111827;
    --cart-text-muted: #6b7280;
    --cart-shadow: 0 8px 22px rgba(17, 24, 39, 0.08);
}

/* Page Header */
.cart-page__header {
    margin: 18px 0 14px;
}

.cart-page__title {
    font-weight: 700;
    color: var(--cart-text);
}

/* Empty state */
.cart-empty {
    background: var(--cart-bg);
    border: 1px solid var(--cart-border);
    border-radius: var(--rc-radius-md);
    padding: 48px 18px;
    text-align: center;
    box-shadow: var(--rc-shadow-sm);
}

/* Layout */
.cart-layout {
    align-items: flex-start;
}

/* Toolbar */
.cart-toolbar {
    background: var(--cart-bg);
    border: 1px solid var(--cart-border);
    border-radius: var(--rc-radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--rc-shadow-sm);
}

.cart-selectall {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--cart-text);
    font-weight: 600;
    user-select: none;
}

.cart-toolbar__hint {
    color: var(--cart-text-muted);
    font-size: 13px;
}

/* Cart list */
.cart-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 14px;
}

/* Card */
.cart-card {
    background: var(--cart-bg);
    border: 1px solid var(--cart-border);
    border-radius: var(--rc-radius-md);
    box-shadow: var(--rc-shadow-sm);
    display: flex;
    gap: 14px;
    padding: 14px;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

.cart-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--cart-shadow);
    border-color: rgba(17, 24, 39, 0.12);
}

/* Media column (checkbox + image) */
.cart-card__media {
    display: flex;
    gap: 12px;
    align-items: center;
    flex: 0 0 auto;
}

.cart-checkwrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Keep Bootstrap checkboxes from stretching inside our flex labels
   - ensures checkbox remains square on mobile when parent becomes full-width */
.cart-selectall .form-check-input,
.cart-checkwrap .form-check-input,
.cart-mobilebar .form-check-input {
    width: 1.05em;
    height: 1.05em;
    min-width: 1.05em;
    min-height: 1.05em;
    flex: 0 0 auto;
    align-self: center;
    margin: 0;
}

.cart-image {
    width: 92px;
    height: 92px;
    background: var(--cart-muted);
    border-radius: var(--rc-radius-sm);
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.cart-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Content column */
.cart-card__content {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.cart-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;

    color: var(--cart-text);
    font-weight: 700;
    text-decoration: none;
    line-height: 1.25;
}

.cart-name:hover {
    color: var(--rc-orange-dark);
}

.cart-meta {
    margin-top: 6px;
    color: var(--cart-text-muted);
    font-size: 13px;
}

/* Remove button */
.cart-remove__btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    color: #111827;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    transition:
        background 0.15s ease,
        transform 0.15s ease,
        border-color 0.15s ease;
}

.cart-remove__btn:hover {
    transform: translateY(-1px);
    border-color: rgba(238, 77, 45, 0.35);
    background: rgba(238, 77, 45, 0.06);
}

/* Bottom row (price/qty/subtotal) */
.cart-card__bottom {
    display: grid;
    grid-template-columns: 1fr 170px 1fr;
    gap: 14px;
    align-items: end;
}

.cart-price__label,
.cart-qty__label,
.cart-subtotal__label {
    color: var(--cart-text-muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.cart-price__value {
    font-weight: 700;
    color: var(--cart-text);
}

/* Harga dengan Diskon */
.cart-price__original {
    font-weight: 400;
    color: #999;
    font-size: 13px;
    text-decoration: line-through;
    margin-bottom: 2px;
}

.cart-price__discounted {
    font-weight: 700;
    color: #dc3545;
    font-size: 16px;
}

.cart-discount-badge {
    display: inline-block;
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Qty control */
.cart-qty__control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--cart-muted);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    padding: 6px 10px;
    justify-content: center;
}

.qty-btn {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    font-weight: 800;
    color: #111827;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        transform 0.15s ease,
        background 0.15s ease,
        border-color 0.15s ease;
}

.qty-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(17, 24, 39, 0.22);
    background: #fff;
}

.qty-input {
    width: 44px;
    text-align: center;
    border: none;
    background: transparent;
    font-weight: 700;
    color: var(--cart-text);
}

/* Subtotal */
.cart-subtotal__value {
    font-weight: 800;
    color: var(--cart-text);
}

/* Summary */
.cart-summary {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    /* Ensure sticky works properly */
    align-self: flex-start;
    width: 100%;
}

.cart-summary__box {
    display: flex;
    flex-direction: column;
    background: var(--cart-bg);
    border: 1px solid var(--cart-border);
    border-radius: var(--rc-radius-md);
    box-shadow: var(--rc-shadow-sm);
    overflow: hidden;
    max-height: calc(100vh - 40px);
}

.cart-summary__tabs {
    display: grid;
    grid-template-columns: 1fr;
    border-bottom: 1px solid var(--cart-border);
    background: #fff;
}

.summary-tab {
    position: relative;
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    font-weight: 700;
    color: var(--cart-text-muted);
    user-select: none;
}

.summary-tab input {
    display: none;
}

/* Simple active look (first default active)
   You can add JS to toggle .is-active; tapi ini sudah oke secara visual */
.summary-tab.is-active {
    color: var(--cart-text);
    background: var(--cart-muted);
}

.cart-summary__rows {
    padding: 14px 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
    color: var(--cart-text);
}

.summary-label {
    color: var(--cart-text-muted);
}

.summary-value {
    font-weight: 700;
}

.summary-divider {
    height: 1px;
    background: var(--cart-border);
    margin: 10px 0;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 6px;
}

.summary-total__label {
    font-weight: 800;
    color: var(--cart-text);
}

.summary-total__value {
    font-size: 20px;
    font-weight: 900;
    color: var(--cart-text);
}

.summary-cta {
    padding: 0 16px 16px 16px;
}

.btn-checkout {
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 14px 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.2px;
    transition:
        transform 0.15s ease,
        background 0.15s ease,
        opacity 0.15s ease;
}

.btn-checkout:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-checkout:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.summary-note {
    margin-top: 10px;
    font-size: 12px;
    color: var(--cart-text-muted);
}

/* Mobile sticky bar */
.cart-mobilebar {
    display: none;
}

/* =========================
   RESPONSIVE: TABLET
   ========================= */
@media (max-width: 991px) {
    .cart-card__bottom {
        grid-template-columns: 1fr 160px 1fr;
    }

    .cart-image {
        width: 84px;
        height: 84px;
    }

    .summary-total__value {
        font-size: 18px;
    }

    /* Keep sticky working on tablet */
    .cart-summary {
        position: sticky;
        top: 10px;
        max-height: calc(100vh - 20px);
    }
}

/* =========================
   DESKTOP OPTIMIZATION
   ========================= */
@media (min-width: 992px) {
    /* Ensure right column maintains sticky behavior */
    .col-lg-4 {
        align-self: flex-start;
        position: sticky;
        top: 20px;
    }

    .cart-summary {
        position: sticky !important;
        top: 20px !important;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        /* Add smooth scrolling inside summary */
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    }

    /* Webkit scrollbar styling */
    .cart-summary::-webkit-scrollbar {
        width: 6px;
    }

    .cart-summary::-webkit-scrollbar-track {
        background: transparent;
    }

    .cart-summary::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 3px;
    }

    .cart-summary::-webkit-scrollbar-thumb:hover {
        background-color: rgba(0, 0, 0, 0.3);
    }
}

/* =========================
   RESPONSIVE: MOBILE
   ========================= */
@media (max-width: 767px) {
    .cart-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .cart-card {
        padding: 12px;
        gap: 12px;
    }

    .cart-card__media {
        align-items: flex-start;
    }

    .cart-image {
        width: 78px;
        height: 78px;
    }

    .cart-card__bottom {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .cart-qty {
        order: 3;
        grid-column: 1 / -1;
    }

    .cart-qty__control {
        width: fit-content;
    }

    .cart-summary {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 1000;
        margin: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        max-height: 50vh;
        transform: translateY(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .cart-summary.collapsed {
        transform: translateY(calc(100% - 60px));
    }

    .cart-summary__box {
        border: none;
        border-radius: 16px 16px 0 0;
        box-shadow: none;
        max-height: 50vh;
        overflow-y: auto;
    }

    /* Handle/indicator untuk swipe up */
    .cart-summary__box::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
        margin: 8px auto 4px;
    }

    /* Hide regular desktop summary elements on mobile */
    .col-lg-4 .cart-summary {
        display: flex;
    }

    /* Hide mobile bar in footer */
    .cart-mobilebar {
        display: none;
    }

    /* Mobile cart page padding adjustment */
    .cart-page {
        padding: 16px 0 60px; /* Space for collapsed bottom sheet */
    }

    /* Make summary tabs smaller on mobile */
    .cart-summary__tabs {
        display: none; /* Hide tabs on mobile for cleaner look */
    }

    /* Make rows more compact */
    .cart-summary__rows {
        padding: 12px 16px;
    }

    .summary-row {
        padding: 6px 0;
        font-size: 13px;
    }

    .summary-total__value {
        font-size: 18px;
    }

    /* Make checkout button full width */
    .summary-cta {
        padding: 12px 16px 16px;
        background: #fff;
        border-top: 1px solid var(--cart-border);
        position: sticky;
        bottom: 0;
    }

    .btn-checkout {
        padding: 12px 16px;
        font-size: 16px;
    }

    .summary-note {
        font-size: 11px;
    }
}

/* Smooth fonts */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
