/**
 * Cart styles — shared between drawer (footer-new.php) and future cart page.
 * Depends on design-system.css tokens.
 */

/* ── Cart item (charcoal card in drawer) ──────────────── */
.cart-item {
  background: var(--charcoal-elevated);
  border: 1px solid var(--charcoal-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  animation: cartItemFadeIn 0.3s ease both;
}
.cart-item:last-child { margin-bottom: 0; }
.cart-item:nth-child(2) { animation-delay: 0.06s; }
.cart-item:nth-child(3) { animation-delay: 0.1s; }

@keyframes cartItemFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Cart item header ─────────────────────────────────── */
.cart-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}
.cart-item-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: -0.2px;
}
.cart-item-price {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  margin-left: 12px;
}
.cart-item-meta {
  font-size: 12px;
  color: var(--text-light-3);
  font-weight: 500;
  margin-bottom: 12px;
}

/* ── Brick grid ───────────────────────────────────────── */
.brick-grid {
  display: grid;
  gap: 3px;
  margin: 12px 0;
}
.brick-grid-header {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-light-3);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 4px;
}
.brick-row-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-light-3);
  display: flex;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.brick {
  width: 100%;
  height: 14px;
  border-radius: 2px;
}
.brick.diet-traditional { background: var(--diet-traditional); }
.brick.diet-fitness-f   { background: var(--diet-fitness-f); }
.brick.diet-fitness-m   { background: var(--diet-fitness-m); }
.brick.diet-vegetarian  { background: var(--diet-vegetarian); }
.brick.diet-none        { background: var(--diet-none); }
.brick.empty            { background: rgba(255,255,255,0.06); }

/* Expandable detail row below each brick row (shows on hover) */
.brick-row-detail {
  grid-column: 1 / -1;
  display: none;
  font-size: 9px;
  line-height: 1.4;
  color: var(--text-light-2);
  padding: 2px 0 4px 24px;
}
.brick-row-detail.open {
  display: block;
  animation: brickDetailSlide 0.15s ease-out;
}
@keyframes brickDetailSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Week separator */
.brick-week-break {
  grid-column: 1 / -1;
  height: 6px;
}

.brick-grid-scroll {
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.brick-grid-scroll::-webkit-scrollbar { width: 4px; }
.brick-grid-scroll::-webkit-scrollbar-track { background: transparent; }
.brick-grid-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

/* ── Cart item actions ────────────────────────────────── */
.cart-item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--charcoal-border);
}
.cart-item-action {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  transition: color var(--transition);
  font-family: inherit;
  text-decoration: none;
}
.cart-item-action:hover { color: var(--text-light); }
.cart-item-action.remove:hover { color: #ff6b6b; }

/* ── Quantity stepper ─────────────────────────────────── */
.cart-item-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border-radius: 6px;
  border: 1px solid var(--charcoal-border);
  overflow: hidden;
}
.cart-item-stepper button {
  width: 28px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border: none;
  color: var(--text-light-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.cart-item-stepper button:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-light);
}
.cart-item-stepper .stepper-value {
  width: 28px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  border-left: 1px solid var(--charcoal-border);
  border-right: 1px solid var(--charcoal-border);
}

/* ── Drawer empty state ───────────────────────────────── */
.drawer-empty {
  color: var(--text-light-3);
  padding: 40px 20px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Drawer footer totals ─────────────────────────────── */
.drawer-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-light-3);
}
.drawer-grand-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--charcoal-border);
  margin-bottom: 16px;
}
.drawer-grand-total span:first-child {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.drawer-grand-total span:last-child {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

/* ── Drawer CTA ───────────────────────────────────────── */
.drawer-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--orange);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.drawer-cta:hover {
  background: var(--orange-hover);
  transform: translateY(-1px);
}
.drawer-cta svg { width: 16px; height: 16px; }

/* ── Drawer continue button (ghost) ───────────────────── */
.drawer-continue {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  margin-top: 8px;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-light-3);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
}
.drawer-continue:hover { color: var(--text-light); }

/* ── Mobile (drawer) ─────────────────────────────────── */
@media (max-width: 768px) {
  .cart-item { padding: 16px; }
  .brick { height: 12px; }
}


/* =====================================================
   CART PAGE (full page, not drawer)
   ===================================================== */

/* ── Cart page layout ────────────────────────────────── */
.cart-page { padding: 32px 0 80px; min-height: 60vh; }
.cart-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 32px;
  align-items: start;
}
.cart-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.cart-page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}
.cart-count {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-gray);
  margin-left: 8px;
}
.cart-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--orange);
  text-decoration: none;
  font-weight: 500;
}
.cart-back-link:hover { text-decoration: underline; }
.cart-items-col { min-width: 0; }   /* allow grid child to shrink below content size */

/* ── Plan cards ──────────────────────────────────────── */
.plan-card {
  background: var(--charcoal);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  min-width: 0;            /* prevent grid blowout from day-scroller */
  overflow: hidden;
}
.plan-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.plan-icon svg { flex-shrink: 0; }
.plan-body { flex: 1; }
.plan-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-light);
}
.plan-meta {
  font-size: 13px;
  color: var(--text-light-3);
  margin-top: 4px;
}
.plan-price-area { text-align: right; }
.plan-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-light);
}

/* ── Day scroller ────────────────────────────────────── */
.day-scroller-wrap { margin-top: 16px; }
.day-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.day-scroller::-webkit-scrollbar { height: 4px; }
.day-scroller::-webkit-scrollbar-track { background: transparent; }
.day-scroller::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}
.day-scroller::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.35);
}
.day-card {
  flex: 0 0 130px;
  scroll-snap-align: start;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
  min-width: 0;
}
.day-card-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--orange);
  margin-bottom: 6px;
  text-transform: capitalize;
  letter-spacing: 0.3px;
}
.day-card-meal {
  font-size: 10px;
  line-height: 1.45;
  color: var(--text-light-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Plan footer ─────────────────────────────────────── */
.plan-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--charcoal-border);
}
.plan-actions { display: flex; gap: 16px; }
.plan-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--cyan);
  text-decoration: none;
  font-weight: 500;
}
.plan-edit:hover { text-decoration: underline; }
.plan-remove {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--text-light-3);
  cursor: pointer;
  font-family: inherit;
}
.plan-remove:hover { color: #ff4444; }

.qty-control {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
}
.qty-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--text-light-2);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.qty-btn:hover { color: var(--text-light); }
.qty-value {
  width: 32px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
}

/* ── Summary panel ───────────────────────────────────── */
.summary-panel {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 80px;
}
.summary-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 20px;
}
.summary-rows { margin-bottom: 16px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}
.summary-label { color: var(--text-gray); }
.summary-value { font-weight: 600; color: var(--text-dark); }
.summary-row.discount .summary-value { color: var(--success, #22c55e); }
.summary-divider { height: 1px; background: var(--card-border); margin: 8px 0; }
.summary-total {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
}
.checkout-cta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}
.secure-note {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 12px;
}

/* ── Coupon section ──────────────────────────────────── */
.coupon-section { margin-top: 24px; }
.coupon-toggle {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.coupon-toggle svg { transition: transform var(--transition); }
.coupon-section.open .coupon-toggle svg { transform: rotate(180deg); }
.coupon-form {
  display: none;
  margin-top: 12px;
  gap: 8px;
}
.coupon-section.open .coupon-form { display: flex; }
.coupon-input { flex: 1; }
.coupon-btn { white-space: nowrap; }

/* ── Cart page mobile ────────────────────────────────── */
@media (max-width: 768px) {
  .cart-page { padding: 20px 0 160px; }
  .cart-layout { grid-template-columns: 1fr; }
  .cart-page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .plan-card { padding: 20px; }

  .summary-col { order: -1; }
  .summary-panel {
    position: fixed;
    top: auto;                /* reset desktop sticky top */
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    z-index: 90;
    padding: 20px 24px calc(20px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  }

  /* Collapsed: show only total + CTA */
  .summary-panel .summary-title,
  .summary-panel .summary-rows,
  .summary-panel .summary-divider,
  .summary-panel .secure-note {
    display: none;
  }

  /* Expanded: show everything */
  .summary-panel.expanded .summary-title,
  .summary-panel.expanded .summary-rows,
  .summary-panel.expanded .summary-divider,
  .summary-panel.expanded .secure-note {
    display: block;
  }
  .summary-panel.expanded .summary-rows {
    display: block;
  }

  .summary-total {
    cursor: pointer;
    user-select: none;
  }
  .summary-total::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid var(--text-gray);
    margin-left: 8px;
    align-self: center;
    transition: transform var(--transition);
  }
  .summary-panel.expanded .summary-total::after {
    transform: rotate(180deg);
  }
}
