/* ============================================================
   IndoCraft · public/css/cart.css
   Phase 5 · Cart + Checkout pages
   Rules: zero inline CSS · mobile-first · ic-* token system
   ============================================================ */

/* ── PAGE BREADCRUMB ───────────────────────────────────────── */
.ic-page-hero {
  background: var(--ic-cream-1);
  border-bottom: 1px solid var(--ic-border);
  padding: 22px 0;
}
.ic-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--ic-muted);
  flex-wrap: wrap;
}
.ic-breadcrumb a { color: var(--ic-muted); transition: color 0.2s; }
.ic-breadcrumb a:hover { color: var(--ic-primary); }
.ic-breadcrumb-sep { color: var(--ic-border); }
.ic-breadcrumb-active { color: var(--ic-primary); font-weight: 600; }
.ic-page-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--ic-ink);
  margin-bottom: 8px;
}

/* ── CART PAGE LAYOUT ──────────────────────────────────────── */
.ic-cart-page { padding: 40px 0 60px; }
.ic-cart-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
}
@media (max-width: 900px) {
  .ic-cart-layout { grid-template-columns: 1fr; }
}

/* Let the grid columns shrink below their content's intrinsic width, so the
   panels never spill past the screen edge (grid items default to
   min-width:auto, which forces horizontal overflow on narrow screens). */
.ic-cart-layout,
.ic-cart-layout > div {
  min-width: 0;
  max-width: 100%;
}
.ic-cart-panel,
.ic-order-summary {
  min-width: 0;
  max-width: 100%;
}
.ic-cart-name,
.ic-summary-item-name {
  overflow-wrap: anywhere;
}

/* ── CART ITEMS TABLE ──────────────────────────────────────── */
.ic-cart-panel {
  background: var(--ic-white);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  overflow: hidden;
}
.ic-cart-panel-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--ic-border);
  background: var(--ic-cream-2);
}
.ic-cart-panel-head h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ic-ink);
}

.ic-cart-table { width: 100%; border-collapse: collapse; }
.ic-cart-table th {
  padding: 12px 16px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ic-muted);
  border-bottom: 1px solid var(--ic-border);
  text-align: left;
  background: var(--ic-cream-1);
}
.ic-cart-table td {
  padding: 16px;
  border-bottom: 1px solid var(--ic-border);
  vertical-align: middle;
}
.ic-cart-table tbody tr:last-child td { border-bottom: none; }
.ic-cart-table tbody tr:hover { background: rgba(249, 244, 232, 0.5); }

.ic-cart-product {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ic-cart-img {
  width: 80px;
  height: 90px;
  border-radius: var(--ic-radius);
  overflow: hidden;
  border: 1px solid var(--ic-border);
  flex-shrink: 0;
}
.ic-cart-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ic-cart-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ic-ink);
  line-height: 1.4;
  transition: color 0.2s;
}
.ic-cart-name:hover { color: var(--ic-primary); }
.ic-cart-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ic-primary);
}
.ic-cart-price-label { font-size: 0.75rem; color: var(--ic-muted); }

/* ── QTY STEPPER ───────────────────────────────────────────── */
.quantity-control {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--ic-border);
  border-radius: var(--ic-radius);
  overflow: hidden;
  background: var(--ic-white);
}
.quantity-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ic-cream-1);
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.quantity-btn:hover { background: var(--ic-cream-2); }
.quantity-btn svg { width: 12px; height: 12px; fill: var(--ic-ink); }
.quantity-input {
  width: 44px;
  text-align: center;
  border: none;
  border-left: 1.5px solid var(--ic-border);
  border-right: 1.5px solid var(--ic-border);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ic-ink);
  padding: 0;
  height: 36px;
  background: var(--ic-white);
  outline: none;
}
.quantity-control.fabric-qty {
  border: none;
  background: transparent;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--ic-muted);
}
.quantity-control.fabric-qty .btn-minus {
  background: none;
  border: 1px solid #e0c0c0;
  border-radius: var(--ic-radius);
  color: var(--ic-primary);
  width: auto;
  padding: 4px 8px;
  height: auto;
}
.quantity-control.fabric-qty .btn-minus:hover { background: #fff0f0; }

/* ── CART FOOTER ACTIONS ───────────────────────────────────── */
.ic-cart-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--ic-cream-2);
  border-top: 1px solid var(--ic-border);
  flex-wrap: wrap;
  gap: 12px;
}

/* ── ORDER SUMMARY SIDEBAR ─────────────────────────────────── */
.ic-order-summary {
  background: var(--ic-white);
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  overflow: hidden;
  position: sticky;
  top: 80px;
}
.ic-order-summary-head {
  padding: 16px 20px;
  background: var(--ic-cream-2);
  border-bottom: 1px solid var(--ic-border);
}
.ic-order-summary-head h4 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ic-ink);
}
.ic-summary-body { padding: 0; }

.ic-summary-items { padding: 12px 16px; max-height: 280px; overflow-y: auto; }
.ic-summary-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ic-border);
}
.ic-summary-item:last-child { border-bottom: none; }
.ic-summary-thumb {
  width: 48px;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--ic-border);
  flex-shrink: 0;
}
.ic-summary-thumb img { width: 100%; height: 100%; object-fit: contain; }
.ic-summary-item-info { flex: 1; min-width: 0; }
.ic-summary-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ic-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ic-summary-item-price { font-size: 0.8rem; color: var(--ic-primary); font-weight: 700; }

.ic-summary-totals { padding: 12px 16px; border-top: 1px solid var(--ic-border); }
.ic-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.84rem;
  color: var(--ic-muted);
}
.ic-summary-row.total {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ic-ink);
  border-top: 1px solid var(--ic-border);
  margin-top: 8px;
  padding-top: 12px;
}

/* ── COUPON BLOCK ──────────────────────────────────────────── */
.ic-coupon {
  padding: 14px 16px;
  border-top: 1px solid var(--ic-border);
}
.ic-coupon-row {
  display: flex;
  gap: 8px;
}
.ic-coupon-row .ic-input {
  flex: 1;
  padding: 9px 12px;
}
.ic-coupon-success { font-size: 0.78rem; color: #2E7D32; margin-top: 6px; }
.ic-coupon-error   { font-size: 0.78rem; color: var(--ic-terra); margin-top: 6px; }

/* ── CART EMPTY STATE ──────────────────────────────────────── */
.ic-cart-empty {
  text-align: center;
  padding: 60px 24px;
}
.ic-cart-empty img {
  width: 200px;
  margin: 0 auto 20px;
  opacity: 0.8;
}
.ic-cart-empty h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--ic-ink);
  margin-bottom: 8px;
}
.ic-cart-empty p { color: var(--ic-muted); margin-bottom: 20px; }

/* ── SKELETON LOADERS ──────────────────────────────────────── */
.ic-skel { background: var(--ic-border); border-radius: 4px; animation: ic-pulse 1.5s ease infinite; }
.ic-skel-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--ic-border);
}
.ic-skel-img { width: 80px; height: 90px; border-radius: var(--ic-radius); flex-shrink: 0; }
.ic-skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ic-skel-line { height: 12px; background: var(--ic-border); border-radius: 4px; animation: ic-pulse 1.5s ease infinite; }
.ic-skel-line.short { width: 40%; }
.ic-skel-line.medium { width: 65%; }

/* ── CHECKOUT PAGE ─────────────────────────────────────────── */
.ic-checkout-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
  padding: 40px 0 60px;
}
@media (max-width: 900px) {
  .ic-checkout-layout { grid-template-columns: 1fr; }
}
.ic-checkout-layout,
.ic-checkout-layout > div,
.ic-checkout-layout > form {
  min-width: 0;
  max-width: 100%;
}

/* Accordion steps */
.ic-checkout-steps { display: flex; flex-direction: column; gap: 0; }
.ic-step {
  border: 1px solid var(--ic-border);
  border-radius: var(--ic-radius);
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--ic-white);
}
.ic-step-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  background: var(--ic-cream-2);
  border-bottom: 1px solid transparent;
  user-select: none;
}
.ic-step.active .ic-step-head { border-bottom-color: var(--ic-border); }
.ic-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ic-primary);
  color: var(--ic-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.ic-step-num.done { background: #2E7D32; }
.ic-step-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ic-ink);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex: 1;
}
.ic-step-body { display: none; padding: 20px; }
.ic-step.active .ic-step-body { display: block; }

/* Address list in checkout */
.ic-address-list { display: flex; flex-direction: column; gap: 12px; }
.ic-address-card {
  border: 1.5px solid var(--ic-border);
  border-radius: var(--ic-radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.ic-address-card:hover { border-color: var(--ic-primary); background: rgba(142,11,11,0.02); }
.ic-address-card.selected { border-color: var(--ic-primary); background: rgba(142,11,11,0.04); }
.ic-address-radio { margin-top: 3px; accent-color: var(--ic-primary); width: 16px; height: 16px; flex-shrink: 0; }
.ic-address-info { flex: 1; }
.ic-address-type {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ic-primary);
  background: rgba(142,11,11,0.08);
  padding: 2px 8px;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 6px;
}
.ic-address-name { font-size: 0.88rem; font-weight: 600; color: var(--ic-ink); }
.ic-address-line { font-size: 0.82rem; color: var(--ic-muted); line-height: 1.5; }

/* Payment methods */
.ic-payment-list { display: flex; flex-direction: column; gap: 10px; }
.ic-payment-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1.5px solid var(--ic-border);
  border-radius: var(--ic-radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.ic-payment-option:hover { border-color: var(--ic-gold); background: rgba(201,148,42,0.03); }
.ic-payment-option input[type="radio"] { margin-top: 2px; accent-color: var(--ic-primary); flex-shrink: 0; }
.ic-payment-label { font-size: 0.88rem; font-weight: 600; color: var(--ic-ink); }
.ic-payment-note { font-size: 0.78rem; color: var(--ic-muted); margin-top: 3px; }

/* Contact info display */
.ic-contact-info-block {
  background: var(--ic-cream-1);
  border-radius: var(--ic-radius);
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--ic-ink);
}
.ic-contact-info-block p { margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.ic-contact-info-block i { color: var(--ic-primary); }

/* Step actions */
.ic-step-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ic-cart-img { width: 64px; height: 74px; }
  .ic-cart-product { gap: 12px; }
  .ic-cart-name { font-size: 0.85rem; }

  /* Items are their own cards now — the panel becomes a plain wrapper so
     nothing (incl. the action buttons) gets clipped by its overflow:hidden. */
  .ic-cart-panel { overflow: visible; border: none; background: transparent; border-radius: 0; }

  .ic-cart-actions {
    padding: 14px;
    margin: 12px;
    flex-direction: column;
    align-items: stretch;
    border: 1px solid var(--ic-border);
    border-radius: var(--ic-radius);
  }
  .ic-cart-actions .ic-btn { width: 100%; justify-content: center; }

  /* Turn the cart table into stacked cards so it doesn't cramp on phones:
     product on its own row, then quantity (left) and total (right) below. */
  .ic-cart-panel-head { padding: 14px 14px; }
  .ic-cart-table thead { display: none; }
  .ic-cart-table,
  .ic-cart-table tbody { display: block; }
  .ic-cart-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 14px;
    margin: 12px;
    border: 1px solid var(--ic-border);
    border-radius: var(--ic-radius);
    background: var(--ic-white);
  }
  .ic-cart-table tbody tr:hover { background: var(--ic-white); }
  .ic-cart-table td { padding: 0; border: none; display: block; }
  .ic-cart-table td:nth-child(1) { flex: 1 1 100%; }        /* product — full width */
  .ic-cart-table td:nth-child(2) { flex: 0 0 auto; }        /* quantity — left */
  .ic-cart-table td:nth-child(3) {                          /* total — pushed right */
    margin-left: auto;
    display: flex;
    align-items: center;
  }
  .ic-cart-table td:nth-child(3)::before {
    content: 'Total:';
    font-size: 0.72rem;
    color: var(--ic-muted);
    font-weight: 600;
    margin-right: 6px;
  }
  .ic-cart-table .ic-cart-price { font-size: 1.05rem; }
}

/* ─── Coupon error: hidden until JS shows it ─── */
.ic-coupon-error { display: none; }

/* ─── Checkout skeleton modifiers ─── */
.ic-skel--circle     { width: 32px; height: 32px; border-radius: 50% !important; }
.ic-skel--cart-thumb { width: 48px; height: 56px; }
.ic-skel-row--sm     { padding: 10px 16px; }

/* ── PROMO CODE ADDITIONS (BUG-INDO-0006) ──────────────────── */
/* Fabric qty: hidden input (replaces inline style="display:none") */
.ic-qty-hidden { display: none; }

/* Fabric trash icon colour (replaces inline style="color:var(--ic-primary)") */
.ic-trash-icon { color: var(--ic-primary); }

/* Discount row — hidden until coupon applied */
.ic-discount-row         { display: none; }
.ic-discount-row span:last-child { color: #2E7D32; font-weight: 700; font-size: 0.84rem; }

/* Input success border */
.ic-input-success { border-color: #2E7D32 !important; }

/* Button loading state (checkout Place Order, etc.) — spinner via ::after */
.ic-btn.is-loading {
  opacity: 0.75;
  cursor: wait;
  pointer-events: none;
}
.ic-btn.is-loading::after {
  content: '';
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 8px;
  animation: ic-btn-spin 0.55s linear infinite;
}
@keyframes ic-btn-spin { to { transform: rotate(360deg); } }
