/* cart page (cart.blade.php): item rows and the order summary.
   Cards, buttons, alerts, the empty state and the dialog come from pages/user-profile.css (.up-page). */

.up-cart-page > .container > * + * {
    margin-top: 14px;
}

/* failed cart update: hidden until js/pages/cart.js shows it with its messages */
.up-cart-errors {
    display: none;
    flex-direction: column;
    gap: 2px;
}

.up-cart-errors p {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
}

.up-cart-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: 14px;
}

/* ---------- items ---------- */

.up-cart-items {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.up-cart-item {
    position: relative;
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) auto auto;
    grid-template-areas: 'thumb info qty price';
    align-items: center;
    gap: 14px;
    padding: 42px 12px 12px;
    background: #fafbfc;
    border: 1px solid var(--up-border);
    border-radius: var(--up-r-item);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.up-cart-remove {
    position: absolute;
    top: 8px;
    left: 8px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    color: var(--up-danger);
    background: #fff;
    font-size: 20px;
    cursor: pointer;
}
.up-cart-remove:hover { background: #fff0f0; }
.up-cart-remove:focus-visible, .up-cart-qty input:focus-visible { outline: 2px solid var(--up-brand); outline-offset: 2px; }
.up-cart-qty input[aria-invalid="true"] { outline: 2px solid var(--up-danger); border-radius: 6px; }
.up-cart-rows > [hidden] { display: none; }

.up-cart-item:hover {
    background: #fff;
    border-color: color-mix(in srgb, var(--up-brand) 25%, var(--up-border));
}

.up-cart-item.is-out {
    border-color: #f3caca;
    background: #fffafa;
}

.up-cart-thumb {
    grid-area: thumb;
    width: 84px;
    height: 84px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--up-border);
    border-radius: 12px;
}

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

.up-cart-info {
    grid-area: info;
    min-width: 0;
}

.up-cart-info h3 {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.8;
}

.up-cart-info h3 a {
    color: var(--up-text);
}

.up-cart-info h3 a:hover {
    color: var(--up-brand-dark);
}

.up-cart-stock {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--up-danger);
}

/* quantity: + [n] − (the − turns into a bin at the minimum, see cart.js) */
.up-cart-qty {
    grid-area: qty;
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 3px;
    background: #fff;
    border: 1px solid var(--up-border);
    border-radius: 999px;
}

.up-cart-qty button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 17px;
    color: var(--up-brand-dark);
    background: var(--up-brand-soft);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.up-cart-qty button:hover {
    color: #fff;
    background: var(--up-brand);
}

.up-cart-qty .dec .mdi-delete-outline {
    color: var(--up-danger);
}

.up-cart-qty .dec:hover .mdi-delete-outline {
    color: #fff;
}

.up-cart-qty input {
    width: 40px;
    height: 32px;
    padding: 0;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    color: var(--up-text);
    background: transparent;
    border: 0;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.up-cart-qty input::-webkit-outer-spin-button,
.up-cart-qty input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.up-cart-price {
    grid-area: price;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    text-align: left;
}

.up-cart-price del {
    font-size: 12px;
    color: var(--up-danger);
}

.up-cart-price strong {
    font-size: 16px;
    font-weight: 800;
    color: var(--up-text);
    white-space: nowrap;
}

.up-cart-price small {
    font-size: 11px;
    font-weight: 500;
    color: var(--up-text-3);
}

.up-cart-list-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--up-border);
}

/* cart + checkout: no button keeps the browser's default border (the store-phone card on the
   checkout is a <button> with its own deliberate border, so it is left out) */
.up-cart-page .up-btn,
.up-cart-page button:not(.co-phone),
.up-confirm button {
    border: none !important;
}

/* ---------- summary ---------- */

.up-cart-summary {
    position: sticky;
    top: 16px;
}

/* the «صورت‌حساب» eyebrow sits centred above the summary (cart + checkout) */
.up-cart-summary .up-card-header > div {
    flex: 1 1 auto;
}

.up-cart-summary .up-card-header > div > span {
    text-align: center;
}

.up-cart-rows {
    display: grid;
    gap: 10px;
    margin: 0;
}

.up-cart-rows > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}

.up-cart-rows dt {
    font-weight: 400;
    color: var(--up-text-2);
}

.up-cart-rows dd {
    margin: 0;
    font-weight: 700;
    color: var(--up-text);
}

.up-cart-rows dd small {
    font-weight: 400;
    color: var(--up-text-3);
}

.up-cart-rows .is-discount dd {
    color: var(--up-danger);
}

.up-cart-rows .is-muted dd {
    font-weight: 500;
    color: var(--up-text-3);
}

.up-cart-total {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 14px 0;
    padding: 12px 14px;
    background: var(--up-brand-soft);
    border-radius: var(--up-r-item);
}

.up-cart-total > span {
    font-size: 12px;
    color: var(--up-text-2);
}

.up-cart-total strong {
    /* the amount sits on the left edge (end of the line in RTL) */
    align-self: flex-end;
    font-size: 22px;
    font-weight: 800;
    color: var(--up-brand-dark);
}

.up-cart-total small {
    font-size: 12px;
    font-weight: 500;
    color: var(--up-text-2);
}

.up-cart-checkout {
    width: 100%;
    min-height: 48px;
    font-size: 14px;
}

.up-cart-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 12px 0 0;
    font-size: 11px;
    line-height: 1.9;
    color: var(--up-text-3);
    text-align: justify;
}

.up-cart-note i {
    margin-top: 2px;
    font-size: 14px;
}

/* ---------- responsive ---------- */

@media (max-width: 991.98px) {
    .up-cart-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .up-cart-summary {
        position: static;
    }
}

@media (max-width: 767.98px) {
    /* thumb + title on top, quantity and price side by side underneath */
    .up-cart-item {
        grid-template-columns: 72px minmax(0, 1fr) auto;
        grid-template-areas:
            'thumb info info'
            'thumb qty price';
        gap: 10px 12px;
    }

    .up-cart-thumb {
        width: 72px;
        height: 72px;
    }

    .up-cart-qty {
        justify-self: start;
    }

    .up-cart-price {
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .up-cart-item {
        grid-template-columns: 112px minmax(0, 1fr);
        grid-template-areas:
            'thumb info'
            'qty price';
        gap: 12px 10px;
    }

    .up-cart-thumb {
        width: 64px;
        height: 64px;
    }

    .up-cart-info h3 { overflow-wrap: anywhere; }

    .up-cart-price { max-width: 100%; }

    .up-cart-price strong {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 3px;
        font-size: 15px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .up-cart-price del { overflow-wrap: anywhere; }
}
