/* ==========================================================================
   Markopedia - Dedicated Cart Page Styles
   Faithful recreation of approved reference design.
   Supports English (LTR) and Arabic (RTL), Desktop, Tablet, and Mobile.
   ========================================================================== */

:root {
    --cp-bg: #f9fafb;
    --cp-card-bg: #ffffff;
    --cp-border: #e5e7eb;
    --cp-divider: #f3f4f6;
    --cp-text-dark: #0f172a;
    --cp-text-muted: #64748b;
    --cp-text-subtle: #94a3b8;
    --cp-brand-purple: #5548d9;
    --cp-brand-purple-hover: #483cc4;
    --cp-accent-purple: #4f46e5;
    --cp-green-bg: #ecfdf5;
    --cp-green-text: #059669;
    --cp-danger: #ef4444;
    --cp-danger-bg: #fee2e2;
    --cp-radius-card: 14px;
    --cp-radius-btn: 10px;
    --cp-radius-stepper: 8px;
    --cp-shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.02);
}

body.markopedia-cart {
    background-color: var(--cp-bg) !important;
    color: var(--cp-text-dark);
    font-family: inherit;
}

.cart-shell {
    width: min(100% - 40px, 1180px);
    margin: 0 auto;
}

/* ── Compact Header (Content only) ───────────────────────────────────────── */
.cart-header {
    background: #ffffff;
    border-bottom: 1px solid var(--cp-divider);
    padding: 150px 0 32px;
    margin-bottom: 32px;
}

.cart-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.86rem;
    color: var(--cp-text-muted);
    margin-bottom: 14px;
}

.cart-breadcrumbs a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
    display: inline-flex;
    align-items: center;
}

.cart-breadcrumbs a:hover {
    color: var(--cp-brand-purple);
}

.cart-breadcrumbs__home {
    color: var(--cp-text-subtle);
}

.cart-breadcrumbs__home:hover {
    color: var(--cp-brand-purple);
}

.cart-breadcrumbs__sep {
    color: #cbd5e1;
    font-size: 0.8rem;
    user-select: none;
}

.cart-breadcrumbs__current {
    color: var(--cp-text-dark);
    font-weight: 600;
}

.cart-title {
    margin: 0 0 6px;
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--cp-text-dark);
    letter-spacing: -0.015em;
    line-height: 1.25;
}

.cart-subtitle {
    margin: 0;
    font-size: 0.94rem;
    color: var(--cp-text-muted);
    line-height: 1.5;
}

/* ── Main Section ───────────────────────────────────────────────────────── */
.cart-main-section {
    padding-bottom: 68px;
}

/* ── Two Column Layout ──────────────────────────────────────────────────── */
.cart-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
    align-items: start;
}

.cart-layout[hidden] {
    display: none !important;
}

/* ── Shared Card Panel ──────────────────────────────────────────────────── */
.cart-panel {
    background: var(--cp-card-bg);
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius-card);
    box-shadow: var(--cp-shadow-subtle);
}

/* ── Left Products Panel ────────────────────────────────────────────────── */
.cart-panel--products {
    padding: 24px;
}

.cart-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--cp-divider);
    margin-bottom: 4px;
}

.cart-panel__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--cp-text-dark);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cart-panel__count {
    color: var(--cp-text-muted);
    font-weight: 600;
}

/* Items List */
.cart-items-list {
    display: flex;
    flex-direction: column;
}

.cart-item {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) auto;
    gap: 20px;
    align-items: center;
    padding: 22px 0;
    border-bottom: 1px solid var(--cp-divider);
    transition: opacity 0.2s ease;
}

.cart-item:last-child {
    border-bottom: none;
    padding-bottom: 4px;
}

.cart-item.is-updating {
    opacity: 0.5;
    pointer-events: none;
}

/* Product Thumbnail */
.cart-item__image-link {
    width: 88px;
    height: 88px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--cp-divider);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-decoration: none;
    flex-shrink: 0;
}

.cart-item__image-link img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
    display: block;
}

/* Product Info */
.cart-item__info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-item__category {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--cp-text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.cart-item__name {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--cp-text-dark);
}

.cart-item__name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.cart-item__name a:hover {
    color: var(--cp-brand-purple);
}

.cart-item__variants {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.cart-item__variants span {
    font-size: 0.72rem;
    font-weight: 600;
    background: #f1f5f9;
    color: var(--cp-text-muted);
    padding: 2px 7px;
    border-radius: 5px;
}

.cart-item__unit-price {
    font-size: 0.82rem;
    color: var(--cp-text-muted);
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 2px;
}

.cart-item__unit-price strong {
    color: var(--cp-text-dark);
    font-weight: 600;
}

/* Stock Status */
.cart-item__stock-status {
    margin-top: 4px;
}

.cart-stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.cart-stock-badge--in {
    background: var(--cp-green-bg);
    color: var(--cp-green-text);
}

.cart-stock-badge--in svg {
    color: var(--cp-green-text);
    flex-shrink: 0;
}

.cart-stock-badge--out {
    background: var(--cp-danger-bg);
    color: var(--cp-danger);
}

/* Product Controls (Right side: Stepper, Line Total, Remove) */
.cart-item__controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    min-width: 140px;
}

/* Stepper Pill */
.cart-stepper {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius-stepper);
    height: 34px;
    overflow: hidden;
}

.cart-stepper__btn {
    width: 30px;
    height: 100%;
    border: none;
    background: transparent;
    color: #475569;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
}

.cart-stepper__btn:hover:not(:disabled) {
    background: #f1f5f9;
    color: var(--cp-text-dark);
}

.cart-stepper__btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.cart-stepper__input {
    width: 36px;
    height: 100%;
    border: none;
    border-inline: 1px solid var(--cp-border);
    background: transparent;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--cp-text-dark);
    padding: 0;
    -moz-appearance: textfield;
}

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

.cart-stepper__input:focus {
    outline: none;
    background: #ffffff;
}

/* Line Total */
.cart-item__line-total {
    font-size: 1rem;
    font-weight: 700;
    color: var(--cp-accent-purple);
    white-space: nowrap;
}

/* Remove Button */
.cart-item__remove {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: var(--cp-text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s ease;
}

.cart-item__remove svg {
    color: inherit;
    flex-shrink: 0;
}

.cart-item__remove:hover {
    color: var(--cp-danger);
}

/* ── Right Order Summary Panel ──────────────────────────────────────────── */
.cart-panel--summary {
    position: sticky;
    top: 24px;
    padding: 24px;
}

.cart-summary__title {
    margin: 0 0 18px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--cp-text-dark);
}

.cart-summary__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 0;
    font-size: 0.92rem;
}

.cart-summary__label {
    color: var(--cp-text-muted);
    font-weight: 500;
}

.cart-summary__value {
    color: var(--cp-text-dark);
    font-weight: 600;
}

.cart-summary__divider {
    height: 1px;
    background: var(--cp-divider);
    margin: 12px 0;
}

.cart-summary__row--shipping {
    align-items: center;
}

.cart-summary__label--shipping {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--cp-text-muted);
}

.cart-summary__note {
    font-size: 0.85rem;
    color: var(--cp-text-muted);
}

.cart-summary__row--total {
    padding: 8px 0 18px;
    align-items: baseline;
}

.cart-summary__label--total {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--cp-text-dark);
}

.cart-summary__total-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--cp-accent-purple);
    letter-spacing: -0.01em;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.cart-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border-radius: var(--cp-radius-btn);
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
}

/* Primary Checkout Button */
.cart-btn--checkout {
    height: 48px;
    background: var(--cp-brand-purple);
    color: #ffffff !important;
    font-size: 0.96rem;
    font-weight: 700;
    border: 1px solid transparent;
    margin-bottom: 10px;
}

.cart-btn--checkout:hover {
    background: var(--cp-brand-purple-hover);
    color: #ffffff !important;
}

.cart-btn__arrow {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

/* RTL Arrow Flipping */
html[dir="rtl"] .cart-btn__arrow {
    transform: scaleX(-1);
}

.cart-btn--checkout:hover .cart-btn__arrow {
    transform: translateX(3px);
}

html[dir="rtl"] .cart-btn--checkout:hover .cart-btn__arrow {
    transform: scaleX(-1) translateX(3px);
}

/* Secondary Continue Shopping Button */
.cart-btn--continue {
    height: 44px;
    background: #ffffff;
    border: 1px solid var(--cp-border);
    color: #1f2937 !important;
    font-size: 0.92rem;
    font-weight: 600;
}

.cart-btn--continue:hover {
    background: #f8fafc;
    border-color: #d1d5db;
    color: var(--cp-text-dark) !important;
}

/* ── Empty State ────────────────────────────────────────────────────────── */
.cart-empty-state {
    background: #ffffff;
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius-card);
    padding: 64px 24px;
    text-align: center;
    max-width: 600px;
    margin: 20px auto 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--cp-shadow-subtle);
}

.cart-empty-state[hidden] {
    display: none !important;
}

.cart-empty-state__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: #f5f3ff;
    color: var(--cp-brand-purple);
    margin-bottom: 20px;
}

.cart-empty-state h2 {
    margin: 0 0 8px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--cp-text-dark);
}

.cart-empty-state p {
    margin: 0 0 24px;
    font-size: 0.94rem;
    color: var(--cp-text-muted);
    max-width: 340px;
    line-height: 1.5;
}

.cart-btn--continue-empty {
    width: auto;
    padding: 12px 28px;
    height: 46px;
    background: var(--cp-brand-purple);
    color: #ffffff !important;
    font-size: 0.94rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.cart-btn--continue-empty:hover {
    background: var(--cp-brand-purple-hover);
    color: #ffffff !important;
}

/* ── Toast Notifications ────────────────────────────────────────────────── */
.shop-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    left: auto;
    transform: translateY(-16px);
    background: #1e2029;
    color: #ffffff;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    z-index: 9999999;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.shop-toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}

[dir="rtl"] .shop-toast {
    right: auto;
    left: 24px;
}

.shop-toast.is-error {
    background: #dc2626;
}

/* ── Responsive Tablet & Mobile ─────────────────────────────────────────── */
@media (max-width: 980px) {
    .cart-header {
        padding: 130px 0 28px;
        margin-bottom: 26px;
    }

    .cart-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

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

@media (max-width: 680px) {
    .cart-shell {
        width: min(100% - 24px, 1180px);
    }

    .cart-header {
        padding: 118px 0 22px;
        margin-bottom: 20px;
    }

    .cart-title {
        font-size: 1.5rem;
    }

    .cart-subtitle {
        font-size: 0.88rem;
    }

    .cart-panel--products {
        padding: 18px 16px;
    }

    .cart-panel--summary {
        padding: 20px 18px;
    }

    .cart-item {
        grid-template-columns: 76px minmax(0, 1fr);
        gap: 14px;
        padding: 16px 0;
    }

    .cart-item__image-link {
        width: 76px;
        height: 76px;
    }

    .cart-item__name {
        font-size: 0.92rem;
    }

    .cart-item__controls {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        margin-top: 6px;
        padding-top: 10px;
        border-top: 1px dashed var(--cp-divider);
    }

    .cart-item__line-total {
        order: 2;
    }

    .cart-item__remove {
        order: 3;
    }

    .cart-stepper {
        order: 1;
        height: 32px;
    }

    .cart-stepper__btn {
        width: 28px;
    }

    .cart-stepper__input {
        width: 32px;
        font-size: 0.82rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cart-item,
    .cart-btn,
    .shop-toast {
        transition: none !important;
    }
}

