/* Mumona: cart.css es carrega a tot el web pel drawer; les regles globals (focus, input:read-only,
   .white-popup, .val-errors, .loading) es limiten a les pàgines del carro per no tocar el web. */
/* ══════════════════════════════════════════════════════════════
   Cart — shared components + cart page
   Matches the visual design from the old cart_page.css / cart.css
   ══════════════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────────────── */
:root {
    --cart-radius: 8px;
    --cart-border: #e5e7eb;
    --cart-bg: #fff;
    --cart-muted: #6b7280;
    --cart-accent: var(--bs-primary, #111);
    --cart-success: #16a34a;
    --cart-danger: #e53e3e;
    --cart-gap: 16px;
    --cart-cream: #faf9f7;
    --cart-soft: #f5f5f5;
}

/* ── Reset helpers ────────────────────────────────────────────── */
body.page-checkout a:focus, body.page-cart a:focus { outline: 0; }
body.page-checkout a:focus-visible, body.page-cart a:focus-visible { outline: 2px solid var(--bs-primary, #111111); outline-offset: 2px; }

body.page-checkout input:read-only, body.page-cart input:read-only {
    background: rgba(206, 206, 206, 0.5);
    cursor: default;
}

/* ══════════════════════════════════════════════════════════════
   SHARED: Line item (.cart-item)
   ══════════════════════════════════════════════════════════════ */
.cart-item {
    display: flex;
    gap: var(--cart-gap);
    padding: 16px 0;
    border-bottom: 1px solid var(--cart-border);
    position: relative;
    transition: background 0.15s ease;
}

.cart-item__img {
    flex-shrink: 0;
}
.cart-item__img img {
    border-radius: var(--cart-radius);
    object-fit: cover;
    display: block;
}

.cart-item__badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--cart-accent);
    color: #fff;
    font-size: 11px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    line-height: 1;
}

.cart-item__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-item__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--cart-accent);
    text-decoration: none;
    margin: 0;
    line-height: 1.3;
    display: block;
}
a.cart-item__name:hover { text-decoration: underline; }

.cart-item__variant {
    font-size: 12px;
    color: var(--cart-muted);
    margin: 0;
}

.cart-item__stock-warn {
    font-size: 12px;
    color: var(--cart-danger);
}

.cart-item__header {
    flex: 1;
    min-width: 0;
}

.cart-item__controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
}

.cart-item__prices {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
    min-width: 70px;
    text-align: right;
}

.cart-item__price {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--cart-accent);
}

.cart-item__old-price {
    font-size: 0.78rem;
    font-weight: 400;
    color: #9ca3af;
    text-decoration: line-through;
}

.cart-item__discount-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cart-item__discount-pill {
    color: var(--cart-success);
    font-weight: 600;
    font-size: 0.72rem;
    line-height: 1.2;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.cart-item__remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--cart-muted);
    padding: 6px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.cart-item__remove:hover {
    color: var(--cart-danger);
    background: #fff1f1;
}
.cart-item__remove:focus-visible {
    outline: 2px solid var(--cart-accent);
    outline-offset: 2px;
}
.cart-item__remove .material-symbols-rounded { font-size: 1.25rem; }

.cart-item__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.cart-item__punts {
    font-size: 12px;
    color: var(--cart-muted);
}

/* ── Resum agrupat per freqüència (checkout, carro mixt) ──────── */
.cart-summary-group__title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--cart-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 16px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--cart-border);
}
.cart-summary-group__title:first-child { margin-top: 0; }
.cart-summary-group__subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--cart-fg, inherit);
    margin: 4px 0 4px;
    padding: 6px 0 10px;
    border-bottom: 1px dashed var(--cart-border);
}

/* ── Freqüència de pagament per línia (carro mixt) ────────────── */
.cart-item__frequency {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}
.cart-item__frequency-label {
    font-size: 0.8rem;
    color: var(--cart-muted);
}
.cart-item__frequency-select {
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--cart-accent);
    background-color: var(--cart-bg);
    border: 1px solid var(--cart-border);
    border-radius: var(--cart-radius);
    padding: 7px 30px 7px 12px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.cart-item__frequency-select:hover { border-color: var(--cart-accent); }
.cart-item__frequency-select:focus-visible {
    outline: none;
    border-color: var(--cart-accent);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

/* ── Mode: full (cart page) ──────────────────────────────────── */
.cart-item--full .cart-item__img { width: 80px; }
.cart-item--full .cart-item__img img { width: 80px; height: 80px; }

/* ── Mode: compact (checkout sidebar) ────────────────────────── */
.cart-item--compact {
    padding: 10px 0;
    gap: 12px;
    align-items: center;
}
.cart-item--compact .cart-item__img { position: relative; }
.cart-item--compact .cart-item__img img { width: 56px; height: 56px; }
.cart-item--compact .cart-item__body {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 0.75rem;
    row-gap: 0.1rem;
    align-items: center;
}
.cart-item--compact .cart-item__name {
    grid-column: 1;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: normal;
    line-height: 1.3;
}
.cart-item--compact .cart-item__variant {
    grid-column: 1;
    font-size: 0.8rem;
}
.cart-item--compact .cart-item__prices {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    line-height: 1.2;
}

/* ── Mode: mini (drawer) ─────────────────────────────────────── */
.cart-item--mini {
    padding: 12px 0;
    gap: 1rem;
}
.cart-item--mini .cart-item__img { width: 64px; }
.cart-item--mini .cart-item__img img { width: 64px; height: 64px; }
.cart-item--mini .cart-item__body {
    gap: 0.5rem;
    justify-content: start;
}
.cart-item--mini .cart-item__name {
    font-size: 14px;
    font-weight: 700;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cart-item--mini .cart-item__price {
    font-size: 16px;
    font-weight: 700;
}
.cart-item--mini .cart-item__remove {
    position: absolute;
    top: 12px;
    right: 0;
    padding: 2px;
}
.cart-item--mini .cart-item__remove .material-symbols-rounded { font-size: 1.1rem; }


/* ══════════════════════════════════════════════════════════════
   SHARED: Qty controls (.cart-qty)
   ══════════════════════════════════════════════════════════════ */
.cart-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--cart-border);
    border-radius: 999px;
    overflow: hidden;
    flex-shrink: 0;
}
.cart-qty:focus-within {
    outline: 2px solid var(--bs-primary, #111111);
    outline-offset: 2px;
}
.cart-qty--full .cart-qty__input {
    width: 36px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    background: transparent;
    padding: 0;
    outline: none;
    -moz-appearance: textfield;
}
.cart-qty--full .cart-qty__input::-webkit-outer-spin-button,
.cart-qty--full .cart-qty__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.cart-qty__btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cart-accent);
    transition: background 0.15s;
}
.cart-qty__btn:hover { background: var(--cart-soft); }
.cart-qty__btn:active { transform: scale(0.9); }
.cart-qty__btn:focus-visible {
    outline: 2px solid var(--cart-accent);
    outline-offset: 2px;
}
.cart-qty__val {
    min-width: 28px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0 4px;
}


/* ══════════════════════════════════════════════════════════════
   SHARED: Totals (.cart-totals)
   ══════════════════════════════════════════════════════════════ */
.cart-totals {
    padding: 1rem 0 0;
    display: flex;
    flex-direction: column;
}
.cart-totals__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    font-size: 0.9rem;
    color: var(--cart-accent);
}
.cart-totals__row--discount {
    color: var(--cart-success);
}
.cart-totals__row--total {
    border-top: 2px solid var(--cart-accent);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
    align-items: center;
}
.cart-totals__row--total strong {
    font-size: 1rem;
    font-weight: 700;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.1;
}
.cart-totals__note {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--cart-muted);
    display: block;
    margin-top: 2px;
}
.cart-totals__note--transport {
    font-style: italic;
    margin: -4px 0 8px;
    line-height: 1.3;
}
.cart-totals__amount {
    font-weight: 700;
    font-size: 30px;
    line-height: 1;
    white-space: nowrap;
    color: var(--cart-accent);
}


/* ══════════════════════════════════════════════════════════════
   SHARED: Promo code (.cart-promo)
   ══════════════════════════════════════════════════════════════ */
.cart-promo {
    border-top: 1px solid #ababab;
}
.cart-promo__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    border-top: none;
    border-bottom: 1px solid #ababab;
    padding: 0.75rem 0;
    cursor: pointer;
    font-size: 0.875rem;
    color: #111;
    text-align: left;
    font-family: inherit;
}
.cart-promo__toggle .material-symbols-rounded {
    font-size: 1.1rem;
    color: var(--cart-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.cart-promo__toggle .material-symbols-rounded.open {
    transform: rotate(180deg);
}
.cart-promo__form {
    display: none;
    padding: 0.75rem 0;
}
.cart-promo__form.open {
    display: block;
}
.cart-promo__input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.cart-promo__input {
    flex: 1;
    border: 1px solid #8a8f98;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: #fff;
    outline: none;
    min-width: 0;
    font-family: inherit;
    transition: border-color 0.2s;
}
.cart-promo__input:focus { border-color: #111; }
.cart-promo__input:focus-visible { outline: 2px solid #111; outline-offset: 1px; }
.cart-promo__submit {
    background: #111;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
    transition: background 0.15s;
}
.cart-promo__submit:hover { background: #333; }

.cart-promo__error {
    color: var(--cart-danger);
    font-size: 0.85rem;
    margin: 0 0 0.5rem;
}

.cart-promo__notice {
    color: var(--cart-muted);
    font-size: 0.85rem;
    margin: 0;
}

.cart-promo__applied {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-top: 1px solid #ababab;
    border-bottom: 1px solid #ababab;
    padding: 0.75rem 0;
    font-size: 0.875rem;
}
.cart-promo__applied .material-symbols-rounded {
    color: #2f855a;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.cart-promo__applied strong { font-weight: 600; }
.cart-promo__remove {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--cart-muted);
    padding: 0 0.25rem;
    transition: color 0.15s;
    flex-shrink: 0;
    margin-left: auto;
}
.cart-promo__remove:hover { color: #111; }


/* ══════════════════════════════════════════════════════════════
   SHARED: Toast notifications (.cart-toast)
   ══════════════════════════════════════════════════════════════ */
.cart-toast {
    display: none;
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 28px;
    border-radius: var(--cart-radius);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.cart-toast--error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.cart-toast--success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}


/* ══════════════════════════════════════════════════════════════
   SHARED: Buttons
   ══════════════════════════════════════════════════════════════ */

/* Primary button */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 1.5rem;
    background: var(--cart-accent);
    color: #fff !important;
    border: 1px solid var(--cart-accent);
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    overflow: hidden;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.btn-primary:hover {
    background: #fff;
    color: var(--cart-accent) !important;
    border-color: var(--cart-accent);
}
.btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transform: skewX(-20deg);
    transition: left 0.5s ease;
    pointer-events: none;
}
.btn-primary:hover::after { left: 150%; }

/* Link button — text with underline */
.btn-link {
    background: none;
    border: none;
    color: var(--cart-muted);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    padding: 0.25rem;
}
.btn-link:hover {
    color: var(--cart-accent);
}

/* Icon-only button */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--cart-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.btn-icon:hover { color: var(--cart-accent); }


/* ══════════════════════════════════════════════════════════════
   CART PAGE
   ══════════════════════════════════════════════════════════════ */
body.page-cart {
    background: #fff;
}
body.page-cart > main {
    padding: 0;
    max-width: 100%;
}

.cart-page {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.cart-page__title {
    font-size: 36px;
    font-weight: 700;
    margin: 0 0 1.5rem;
    color: var(--cart-accent);
}

/* ── Empty state ──────────────────────────────────────────────── */
.cart-page__empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--cart-muted);
}
.cart-page__empty .material-symbols-rounded {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.cart-page__empty p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* ── Shipping badge ───────────────────────────────────────────── */
.cart-page__shipping {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: #f9f9f7;
    border-radius: 50px;
    font-size: 0.82rem;
    color: #111;
    margin-bottom: 0.75rem;
    width: fit-content;
}
.cart-page__shipping .material-symbols-rounded {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.cart-page__shipping--ok {
    background: #f0fdf4;
    color: var(--cart-success);
}

/* ── Items container ──────────────────────────────────────────── */
.cart-page__items {
    margin-bottom: 0.25rem;
}

/* ── Summary ──────────────────────────────────────────────────── */
.cart-page__summary {
    padding: 1rem 0 0;
    display: flex;
    flex-direction: column;
}

/* ── Checkout button ──────────────────────────────────────────── */
.cart-page__checkout {
    width: auto;
    align-self: flex-end;
    padding-left: 2.5rem;
    padding-right: 2.5rem;
    margin-top: 1rem;
}

/* ── Continue shopping ────────────────────────────────────────── */
.cart-page__continue {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: var(--cart-muted);
    text-decoration: none;
    padding: 0.25rem;
    margin-top: 0.5rem;
}
.cart-page__continue:hover {
    color: var(--cart-accent);
    text-decoration: underline;
}


/* ══════════════════════════════════════════════════════════════
   Loading state
   ══════════════════════════════════════════════════════════════ */
body.page-checkout .loading, body.page-cart .loading {
    opacity: 0.5;
    pointer-events: none;
}


/* ══════════════════════════════════════════════════════════════
   Misc: popup, validation, info badge
   ══════════════════════════════════════════════════════════════ */

/* White popup (Magnific-Popup style) */
body.page-checkout .white-popup, body.page-cart .white-popup {
    background: #fff;
    padding: 36px 40px;
    text-align: left;
    max-width: 90%;
    width: 720px;
    margin: 40px auto;
    position: relative;
    max-height: 80vh;
    overflow: auto;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    box-sizing: border-box;
}

/* Magnific popup hide */
.mfp-hide { display: none !important; }

/* Validation errors */
body.page-checkout .val-errors:not(.val-checks), body.page-cart .val-errors:not(.val-checks) {
    position: static;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}
body.page-checkout .val-errors > div, body.page-cart .val-errors > div {
    background: transparent;
    color: #c62828;
    font-size: 0.78rem;
    padding: 3px 0 !important;
}

/* Info badge (cream bg, rounded) */
.osc-info-badge {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #f9f9f7;
    border: 1px solid #ececec;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 12px;
    font-size: 0.875rem;
    color: #4b5563;
    line-height: 1.4;
}
.osc-info-badge .material-symbols-rounded {
    font-size: 1.15rem;
    color: var(--cart-muted);
    flex-shrink: 0;
    margin-top: 1px;
}


/* ══════════════════════════════════════════════════════════════
   Responsive: mobile (<=640px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .cart-page { padding: 1rem; }

    .cart-page__title { font-size: 28px; }

    .cart-item--full {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0.875rem 0;
    }
    .cart-item--full .cart-item__img { width: 64px; }
    .cart-item--full .cart-item__img img { width: 64px; height: 64px; }
    .cart-item--full .cart-item__body { flex: 1; }
    .cart-item--full .cart-item__controls { order: 3; }
    .cart-item--full .cart-item__prices {
        order: 4;
        flex: 1;
        text-align: left;
        align-items: flex-start;
    }
    .cart-item--full .cart-item__remove { order: 5; }

    .cart-page__checkout {
        width: 100%;
        align-self: stretch;
    }
}
