/* ===================================================================
   Cart Page — PixRemix v2.1
   Full cart view with shipping progress, quantity controls, undo,
   trust badges, bundle prompts, and sticky mobile checkout bar.
   =================================================================== */

@layer pages {

  /* --- Page Header --- */
  .cart-page-header {
    text-align: center;
    margin-bottom: var(--space-6);
  }

  .cart-page-header h1 {
    font-family: var(--font-heading);
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
    margin: 0 0 var(--space-2);
  }

  .cart-page-header .cart-item-count {
    font-size: var(--text-base);
    color: var(--neutral-600);
    font-weight: var(--weight-regular);
  }

  /* --- Empty Cart State --- */
  .cart-empty {
    text-align: center;
    padding: var(--space-16) var(--space-6);
    max-width: 480px;
    margin: 0 auto;
  }

  .cart-empty-icon {
    width: 96px;
    height: 96px;
    margin: 0 auto var(--space-6);
    background: var(--neutral-50);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cart-empty-icon svg {
    width: 48px;
    height: 48px;
    stroke: var(--neutral-400);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .cart-empty h2 {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
    margin: 0 0 var(--space-2);
  }

  .cart-empty p {
    color: var(--neutral-600);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    margin: 0 0 var(--space-6);
  }

  .cart-empty .btn {
    min-width: 220px;
  }

  /* --- Free Shipping Progress --- */
  .shipping-progress {
    background: var(--surface-white);
    border: 1px solid var(--neutral-100);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-6);
  }

  .shipping-progress-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--neutral-900);
    margin-bottom: var(--space-3);
  }

  .shipping-progress-label svg {
    width: 18px;
    height: 18px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  .shipping-progress .progress-bar-track {
    height: 8px;
    margin-bottom: var(--space-2);
  }

  .shipping-progress-hint {
    font-size: var(--text-xs);
    color: var(--neutral-600);
  }

  .shipping-progress.complete .shipping-progress-label {
    color: var(--success);
  }

  .shipping-progress.complete .shipping-progress-label svg {
    stroke: var(--success);
  }

  .shipping-progress.complete .progress-bar-fill {
    background: var(--success);
  }

  /* --- Cart Layout --- */
  .cart-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--space-8);
    align-items: start;
  }

  /* --- Cart Items Section --- */
  .cart-items-section {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  /* --- Single Cart Item --- */
  .cart-item {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-5) 0;
    border-bottom: 1px solid var(--neutral-100);
    align-items: flex-start;
    transition: opacity var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out);
  }

  .cart-item:first-child {
    padding-top: 0;
  }

  .cart-item.removing {
    opacity: 0;
    transform: translateX(-20px);
    max-height: 0;
    padding: 0;
    overflow: hidden;
  }

  /* Thumbnail */
  .cart-item-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
  }

  .cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    background: var(--neutral-50);
  }

  .cart-item-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--neutral-50);
    border-radius: var(--radius-md);
    color: var(--neutral-400);
    font-size: var(--text-xs);
  }

  /* Details */
  .cart-item-details {
    flex: 1;
    min-width: 0;
  }

  .cart-item-name {
    margin: 0 0 var(--space-1);
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--neutral-900);
  }

  .cart-item-style {
    margin: 0 0 var(--space-3);
    color: var(--neutral-600);
    font-size: var(--text-sm);
  }

  /* Plus/Minus Quantity Controls */
  .cart-item-controls {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .qty-stepper {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-white);
  }

  .qty-stepper button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--neutral-600);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    transition: background var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out);
    -webkit-tap-highlight-color: transparent;
  }

  .qty-stepper button:hover {
    background: var(--neutral-50);
    color: var(--neutral-900);
  }

  .qty-stepper button:disabled {
    color: var(--neutral-200);
    cursor: not-allowed;
  }

  .qty-stepper button:disabled:hover {
    background: transparent;
  }

  .qty-stepper .qty-value {
    width: 36px;
    text-align: center;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--neutral-900);
    border-left: 1.5px solid var(--neutral-200);
    border-right: 1.5px solid var(--neutral-200);
    line-height: 36px;
    font-variant-numeric: tabular-nums;
  }

  .cart-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--neutral-400);
    transition: background var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out);
    -webkit-tap-highlight-color: transparent;
  }

  .cart-item-remove svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .cart-item-remove:hover {
    background: var(--color-alert-error-bg);
    color: var(--error);
  }

  /* Price */
  .cart-item-price {
    font-family: var(--font-heading);
    font-weight: var(--weight-bold);
    font-size: var(--text-base);
    color: var(--neutral-900);
    white-space: nowrap;
    text-align: right;
    min-width: 64px;
  }

  /* Bundle badge on item */
  .cart-item-bundle-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    background: #F0FDF4;
    color: #166534;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    margin-left: var(--space-2);
  }

  /* --- Create Another CTA --- */
  .cart-create-cta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) 0;
  }

  .cart-create-cta .btn {
    gap: var(--space-2);
  }

  .cart-create-cta .btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* --- Bundle Conversion Prompt --- */
  .bundle-prompt {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-warm);
    border-radius: var(--radius-md);
    margin-top: var(--space-4);
    font-size: var(--text-sm);
  }

  .bundle-prompt svg {
    width: 20px;
    height: 20px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  .bundle-prompt-text {
    flex: 1;
    color: var(--neutral-900);
    font-weight: var(--weight-medium);
  }

  .bundle-prompt-text strong {
    font-weight: var(--weight-bold);
    color: var(--accent-hover);
  }

  /* --- Pack nudge (per sticker item) --- */
  .cart-pack-nudge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    margin: calc(-1 * var(--space-2)) 0 0;
    background: #FFFBEB;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-size: var(--text-sm);
    color: var(--neutral-700);
    font-weight: var(--weight-medium);
  }

  .cart-pack-nudge svg {
    stroke: #D97706;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  /* --- Card upsell prompt --- */
  .cart-card-upsell {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface-warm);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 140, 0, 0.15);
    text-decoration: none;
    color: inherit;
    transition: all var(--duration-fast);
    margin-top: var(--space-3);
  }

  .cart-card-upsell:hover {
    border-color: var(--accent);
    background: rgba(255, 140, 0, 0.08);
  }

  .cart-card-upsell-icon {
    font-size: var(--text-2xl);
    flex-shrink: 0;
  }

  .cart-card-upsell-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .cart-card-upsell-text strong {
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
  }

  .cart-card-upsell-text span {
    font-size: var(--text-xs);
    color: var(--neutral-600);
  }

  .cart-card-upsell-arrow {
    font-size: var(--text-xl);
    color: var(--accent);
    font-weight: var(--weight-bold);
    flex-shrink: 0;
  }

  /* --- Card item styles --- */
  .cart-item-message {
    font-style: italic;
    color: var(--neutral-600);
  }

  .cart-item-qty-label {
    font-size: var(--text-sm);
    color: var(--neutral-600);
  }

  /* --- Order Summary --- */
  .cart-summary {
    background: var(--surface-white);
    border: 1.5px solid var(--neutral-100);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
  }

  .cart-summary h2 {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
    margin: 0 0 var(--space-5);
  }

  .cart-summary-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--neutral-600);
  }

  .cart-summary-row span:last-child {
    font-weight: var(--weight-semibold);
    color: var(--neutral-900);
  }

  .cart-savings-row {
    color: var(--success);
  }

  .cart-savings-row span:last-child {
    color: var(--success);
    font-weight: var(--weight-semibold);
  }

  .cart-discount-row {
    color: var(--success);
  }

  .cart-discount-row span:last-child {
    color: var(--success);
  }

  .cart-total-row {
    border-top: 1.5px solid var(--neutral-200);
    margin-top: var(--space-3);
    padding-top: var(--space-4);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
  }

  .cart-total-row span:last-child {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
  }

  .free-shipping {
    color: var(--success);
    font-weight: var(--weight-bold);
  }

  /* Shipping estimate text */
  .cart-shipping-estimate {
    font-size: var(--text-xs);
    color: var(--neutral-400);
    margin-top: var(--space-1);
    text-align: right;
  }

  /* --- Discount Section --- */
  .cart-discount-section {
    margin: var(--space-5) 0;
    padding-top: var(--space-4);
    border-top: 1px solid var(--neutral-100);
  }

  .cart-discount-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--neutral-600);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: 100%;
    text-align: left;
  }

  .cart-discount-toggle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform var(--duration-fast) var(--ease-out);
  }

  .cart-discount-toggle.open svg {
    transform: rotate(90deg);
  }

  .cart-discount-form {
    margin-top: var(--space-3);
  }

  .cart-discount-input {
    display: flex;
    gap: var(--space-2);
  }

  .cart-discount-input input {
    flex: 1;
    min-width: 0;
  }

  .cart-discount-input .btn {
    flex-shrink: 0;
  }

  #cart-discount-message {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
  }

  .discount-success { color: var(--success); font-weight: var(--weight-semibold); }
  .discount-error { color: var(--error); font-weight: var(--weight-semibold); }
  .discount-warning { color: var(--accent); font-weight: var(--weight-semibold); }

  /* --- Checkout Button --- */
  .cart-checkout-btn {
    width: 100%;
    margin-top: var(--space-4);
    font-size: var(--text-lg);
    min-height: 52px;
  }

  .cart-checkout-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* --- Design Expiry Notice --- */
  .cart-expiry-notice {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: #FEF3C7;
    color: #92400E;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
  }

  .cart-expiry-notice svg {
    flex-shrink: 0;
    stroke: #92400E;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* --- Trust Section (always visible) --- */
  .cart-trust-section {
    max-width: 640px;
    margin: var(--space-10) auto var(--space-6);
    padding: var(--space-6) var(--space-6) var(--space-5);
    background: var(--surface-cream);
    border: 1px solid var(--neutral-100);
    border-radius: var(--radius-lg);
  }

  .cart-trust-badges {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
  }

  .cart-trust-badge {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    flex: 1;
  }

  .cart-trust-badge-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(21, 128, 61, 0.1);
    border-radius: var(--radius-md);
    flex-shrink: 0;
  }

  .cart-trust-badge-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--success);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .cart-trust-badge-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .cart-trust-badge-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--neutral-900);
    line-height: var(--leading-tight);
  }

  .cart-trust-badge-desc {
    font-size: var(--text-xs);
    color: var(--neutral-400);
    line-height: var(--leading-normal);
  }

  .cart-trust-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-5);
    padding-top: var(--space-5);
    border-top: 1px solid var(--neutral-200);
  }

  .cart-payment-logos {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .payment-logo {
    width: 38px;
    height: 24px;
    border-radius: 3px;
    flex-shrink: 0;
  }

  .cart-trust-divider {
    width: 1px;
    height: 16px;
    background: var(--neutral-200);
    flex-shrink: 0;
  }

  .cart-support-link {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    color: var(--neutral-400);
    text-decoration: none;
    transition: color var(--duration-fast) ease;
    white-space: nowrap;
  }

  .cart-support-link:hover {
    color: var(--accent);
  }

  .cart-support-link svg {
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  @media (max-width: 600px) {
    .cart-trust-section {
      padding: var(--space-5) var(--space-4) var(--space-4);
      margin: var(--space-8) var(--space-2) var(--space-4);
    }

    .cart-trust-badges {
      flex-direction: column;
      gap: var(--space-4);
    }

    .cart-trust-footer {
      flex-wrap: wrap;
      gap: var(--space-3);
    }
  }

  /* --- Shipping Form --- */
  #cart-shipping-form {
    margin-top: var(--space-5);
    padding-top: var(--space-5);
    border-top: 1.5px solid var(--neutral-200);
  }

  #cart-shipping-form h3 {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--neutral-900);
    margin: 0 0 var(--space-4);
  }

  #cart-shipping-form .btn {
    width: 100%;
    margin-top: var(--space-2);
  }

  #cart-shipping-info {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    margin: var(--space-3) 0;
    padding: var(--space-3) var(--space-4);
    background: var(--neutral-50);
    border-radius: var(--radius-sm);
  }

  #cart-shipping-info:empty {
    display: none;
  }

  /* --- Responsive --- */
  @media (max-width: 900px) {
    .cart-layout {
      grid-template-columns: 1fr;
      gap: var(--space-6);
    }

    .cart-summary {
      position: static;
    }
  }

  @media (max-width: 768px) {
    .cart-page-header h1 {
      font-size: var(--text-2xl);
    }

    .cart-item-image {
      width: 64px;
      height: 64px;
    }

    .cart-item {
      gap: var(--space-3);
      padding: var(--space-4) 0;
    }

    .cart-item-name {
      font-size: var(--text-sm);
    }

    .cart-item-price {
      font-size: var(--text-sm);
      min-width: auto;
    }

    .cart-summary {
      padding: var(--space-4);
    }

    .cart-trust-badges {
      gap: var(--space-3);
    }

    /* Sticky mobile checkout bar */
    .cart-mobile-bar {
      display: flex;
      position: fixed;
      bottom: var(--tab-bar-height);
      left: 0;
      right: 0;
      background: var(--surface-white);
      border-top: 1px solid var(--neutral-100);
      padding: var(--space-3) var(--space-4);
      padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
      z-index: var(--z-sticky);
      align-items: center;
      justify-content: space-between;
      gap: var(--space-3);
      box-shadow: 0 -4px 12px rgba(28, 25, 23, 0.08);
    }

    .cart-mobile-bar-total {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .cart-mobile-bar-total .label {
      font-size: var(--text-xs);
      color: var(--neutral-600);
    }

    .cart-mobile-bar-total .amount {
      font-family: var(--font-heading);
      font-size: var(--text-xl);
      font-weight: var(--weight-bold);
      color: var(--neutral-900);
    }

    .cart-mobile-bar .btn {
      flex-shrink: 0;
    }

    /* Add bottom padding so content isn't hidden behind sticky bar */
    .cart-layout {
      padding-bottom: 80px;
    }
  }

  /* Hide mobile bar on desktop */
  @media (min-width: 769px) {
    .cart-mobile-bar {
      display: none;
    }
  }
}
