/* ===========================================================
   Protocol's Pizza & Restaurant — Cart
   Palette: Cream #FBF3E7 · Charcoal #2B211C · Protocol Red #D53749
            Red Dark #A62A3A · Card White #FFFFFF · Green #3FA34D · Gold #B9791C
   =========================================================== */

:root {
    --cream: #fdf8f2;
    --charcoal: #2b2320;
    --charcoal-soft: #7d6f62;
    --red: #dc4553;
    --red-dark: #b8323f;
    --card: #ffffff;
    --line: #ddd0bd;
    --green: #3FA34D;
    --gold: #f2c230;
    --radius: 12px;
}
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--cream);
    color: var(--charcoal);
    font-family: 'Poppins', sans-serif;
}

button {
    font-family: inherit;
}

/* ---------- Header ---------- */

#cartHeader {
    display: flex;
    align-items: center;
    gap: 18px;
    background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
    color: #fff;
    padding: 20px 32px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 14px rgba(43, 33, 28, 0.18);
}

#backBtn {
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    opacity: 0.92;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

#backBtn:hover {
    opacity: 1;
    transform: translateX(-2px);
}

#cartHeaderTitle {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.3px;
    flex: 1;
}

#cartHeaderLogo {
    font-family: 'Pacifico', cursive;
    font-size: 20px;
    opacity: 0.9;
}

/* ---------- Page layout ---------- */

#cartPage {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 32px 100px;
}

#cartLayout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 28px;
    align-items: start;
}

#cartMain {
    min-width: 0;
}

/* ---------- Select all row ---------- */

#selectAllRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 16px;
}

#selectAllLabel {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--charcoal-soft);
    cursor: pointer;
    user-select: none;
}

#cartItemCount {
    font-size: 14px;
    font-weight: 600;
    color: var(--charcoal-soft);
}

/* ---------- Checkbox styling (custom, shared) ---------- */

input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
}

.checkboxBox {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    border: 2px solid #D8CBB8;
    background: #fff;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.checkboxBox::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
}

input[type="checkbox"]:checked+.checkboxBox {
    background: var(--green);
    border-color: var(--green);
}

input[type="checkbox"]:checked+.checkboxBox::after {
    opacity: 1;
}

input[type="checkbox"]:focus-visible+.checkboxBox {
    outline: 2px solid var(--red-dark);
    outline-offset: 2px;
}

/* ---------- Cart item cards ---------- */

#cartList {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cartItem {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    overflow: hidden;
    animation: itemIn 0.25s ease;
}

@keyframes itemIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cartItemTop {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.itemCheckboxLabel {
    position: relative;
    display: flex;
}

.cartItemCategory {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.categoryDot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--charcoal);
    flex-shrink: 0;
}

.categoryLabel {
    font-size: 13px;
    font-weight: 600;
    color: var(--charcoal-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cartItemActions {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-shrink: 0;
}

.editBtn,
.removeBtn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 2px;
}

.editBtn {
    color: var(--charcoal);
}

.editBtn:hover {
    color: var(--gold);
}

.removeBtn {
    color: var(--red);
}

.removeBtn:hover {
    color: var(--red-dark);
}

.cartItemBody {
    display: flex;
    gap: 16px;
    padding: 16px;
}

.cartItemImage {
    width: 96px;
    height: 96px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--line);
    flex-shrink: 0;
}

.cartItemDetails {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cartItemName {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.cartItemNotes {
    margin: 0 0 6px;
    font-size: 13px;
    color: var(--charcoal-soft);
}

.cartItemPriceRow {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.qtyStepper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--cream);
    border-radius: 999px;
    padding: 4px 6px;
}

.qtyBtn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--red);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, background 0.12s ease;
}

.qtyBtn:hover {
    background: var(--red-dark);
    transform: scale(1.06);
}

.qtyValue {
    min-width: 14px;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
}

.cartItemUnitPrice {
    font-size: 13px;
    color: var(--charcoal-soft);
    flex: 1;
    text-align: right;
}

.cartItemLineTotal {
    font-size: 17px;
    font-weight: 800;
    color: var(--charcoal);
    min-width: 64px;
    text-align: right;
}

/* ---------- Empty state ---------- */

#emptyCartMessage {
    text-align: center;
    padding: 64px 20px;
    color: var(--charcoal-soft);
}

#emptyCartMessage p {
    margin: 4px 0;
}

.emptyCartSub {
    font-size: 14px;
}

#browseMenuBtn {
    display: inline-block;
    margin-top: 18px;
    background: var(--red);
    color: #fff;
    text-decoration: none;
    padding: 11px 24px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    transition: background 0.15s ease;
}

#browseMenuBtn:hover {
    background: var(--red-dark);
}

/* ---------- Order summary (sticky sidebar) ---------- */

#orderSummary {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    position: sticky;
    top: 96px;
}

#summaryHeading {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 800;
}

.summaryRow {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    color: var(--charcoal-soft);
}

#summaryFootnote {
    margin: 4px 0 0;
    font-size: 11px;
    font-style: italic;
    color: var(--charcoal-soft);
}

#summaryTotalRow {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-top: 1px dashed var(--line);
    margin-top: 14px;
    padding-top: 14px;
    font-size: 15px;
    font-weight: 700;
}

#summaryTotal {
    font-size: 24px;
    color: var(--green);
    font-weight: 800;
}

#checkoutBtn {
    width: 100%;
    margin-top: 18px;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

#checkoutBtn:hover {
    background: var(--red-dark);
}

#checkoutBtn:active {
    transform: scale(0.98);
}

#checkoutBtn:disabled {
    background: #C9BFB2;
    cursor: not-allowed;
}

/* ---------- Mobile checkout bar (hidden on desktop) ---------- */

#mobileCheckoutBar {
    display: none;
}

/* ---------- Focus states ---------- */

.qtyBtn:focus-visible,
.removeBtn:focus-visible,
.editBtn:focus-visible,
#checkoutBtn:focus-visible,
#mobileCheckoutBtn:focus-visible,
#browseMenuBtn:focus-visible,
#backBtn:focus-visible {
    outline: 2px solid var(--red-dark);
    outline-offset: 2px;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    #cartLayout {
        grid-template-columns: 1fr;
    }

    #orderSummary {
        display: none;
    }

    #cartPage {
        padding: 24px 18px 110px;
    }

    #mobileCheckoutBar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--card);
        border-top: 1px solid var(--line);
        padding: 14px 20px;
        box-shadow: 0 -6px 18px rgba(43, 33, 28, 0.1);
        z-index: 10;
    }

    #mobileCheckoutBar>div {
        display: flex;
        flex-direction: column;
        line-height: 1.3;
    }

    #mobileTotalLabel {
        font-size: 11px;
        color: var(--charcoal-soft);
        font-weight: 600;
    }

    #mobileTotalValue {
        font-size: 19px;
        font-weight: 800;
        color: var(--green);
    }

    #mobileCheckoutBtn {
        background: var(--red);
        color: #fff;
        border: none;
        border-radius: 999px;
        padding: 12px 26px;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
        transition: background 0.15s ease;
    }

    #mobileCheckoutBtn:hover {
        background: var(--red-dark);
    }

    #mobileCheckoutBtn:disabled {
        background: #C9BFB2;
        cursor: not-allowed;
    }
}

@media (max-width: 520px) {
    .cartItemBody {
        flex-direction: column;
    }

    .cartItemImage {
        width: 100%;
        height: 140px;
    }

    .cartItemUnitPrice {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cartItem {
        animation: none;
    }

    .qtyBtn,
    #checkoutBtn,
    #mobileCheckoutBtn,
    #backBtn {
        transition: none;
    }
}