/**
 * PanelShop Phase C — Prototype UI polish
 * Matches React reference: stepper, cards, thank-you, dashboard, auth blobs
 */

/* Page shells */
.ps-page-shell {
  min-height: 100vh;
  background: var(--ps-surface-50);
  padding-bottom: 48px;
}

.panelshop-dashboard {
  background: transparent;
  min-height: 0;
}

/* Scrollbar (prototype) */
.panelshop-auth::-webkit-scrollbar,
.panelshop-checkout::-webkit-scrollbar,
.panelshop-dashboard::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.panelshop-auth::-webkit-scrollbar-track,
.panelshop-checkout::-webkit-scrollbar-track,
.panelshop-dashboard::-webkit-scrollbar-track {
  background: var(--ps-surface-100);
}
.panelshop-auth::-webkit-scrollbar-thumb,
.panelshop-checkout::-webkit-scrollbar-thumb,
.panelshop-dashboard::-webkit-scrollbar-thumb {
  background: var(--ps-surface-300);
  border-radius: 999px;
}

/* Auth decorative blobs */
.ps-auth-blobs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.ps-auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
}
.ps-auth-blob-1 {
  width: 380px;
  height: 380px;
  background: var(--ps-primary-200);
  top: 20%;
  right: 20%;
}
.ps-auth-blob-2 {
  width: 380px;
  height: 380px;
  background: #ddd6fe;
  bottom: 15%;
  left: 15%;
}

/* Checkout header */
.ps-checkout-header {
  text-align: center;
  max-width: var(--ps-layout-max-width, 1100px);
  margin: 0 auto;
  padding: 32px 16px 8px;
}
.ps-checkout-title {
  font-size: 28px;
  font-weight: var(--ps-fw-heading);
  margin: 0 0 8px;
  color: var(--ps-surface-800);
}
.ps-checkout-subtitle {
  font-size: 14px;
  color: var(--ps-surface-400);
  margin: 0;
}

/* Progress stepper (prototype style) */
.ps-progress-stepper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  max-width: 640px;
  margin: 0 auto 32px;
  padding: 0 16px;
}
.ps-progress-step-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 200px;
}
.ps-progress-step-wrap:last-child {
  flex: 0;
  max-width: none;
}
.ps-progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ps-progress-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--ps-surface-100);
  color: var(--ps-surface-400);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.ps-progress-step.active .ps-progress-icon {
  background: var(--ps-primary-500);
  color: #fff;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
}
.ps-progress-step.active .ps-progress-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid var(--ps-primary-300);
  border-radius: 18px;
}
.ps-progress-step.done .ps-progress-icon {
  background: var(--ps-primary-500);
  color: #fff;
}
.ps-progress-step .ps-icon-check { display: none; }
.ps-progress-step.done .ps-icon-step { display: none; }
.ps-progress-step.done .ps-icon-check { display: block; }
.ps-progress-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ps-surface-400);
  text-align: center;
  white-space: nowrap;
}
.ps-progress-step.active .ps-progress-label,
.ps-progress-step.done .ps-progress-label {
  color: var(--ps-primary-600);
}
.ps-progress-connector {
  flex: 1;
  height: 2px;
  background: var(--ps-surface-200);
  margin: 0 8px;
  margin-top: 24px;
  border-radius: 999px;
  transition: background 0.3s;
  min-width: 24px;
}
.ps-progress-connector.done {
  background: var(--ps-primary-500);
}

/* Card section titles with icon */
.ps-card-title-icon {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--ps-surface-800);
}
.ps-card-title-icon svg {
  color: var(--ps-primary-500);
  flex-shrink: 0;
}

/* Order summary (prototype) */
.ps-order-summary {
  padding: 0;
  overflow: hidden;
  position: sticky;
  top: 24px;
}
.ps-summary-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ps-surface-100);
  font-weight: 700;
  font-size: 15px;
  color: var(--ps-surface-800);
}
.ps-summary-header svg { color: var(--ps-primary-500); }
.ps-summary-body { padding: 20px; }
.ps-summary-items-scroll {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.ps-summary-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.ps-summary-item-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--ps-radius-lg, 12px);
  background: var(--ps-surface-50);
  border: 1px solid var(--ps-surface-100);
  object-fit: cover;
  flex-shrink: 0;
  overflow: hidden;
}

img.ps-summary-item-thumb {
  border-radius: var(--ps-radius-lg, 12px);
}
.ps-summary-item-thumb.ps-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.ps-summary-item-info {
  flex: 1;
  min-width: 0;
}
.ps-summary-item-info strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ps-surface-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ps-summary-item-info span {
  font-size: 11px;
  color: var(--ps-surface-400);
}
.ps-summary-item-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--ps-surface-800);
  white-space: nowrap;
}
.ps-summary-totals {
  border-top: 1px solid var(--ps-surface-100);
  padding-top: 16px;
  margin-top: 8px;
}
.ps-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  color: var(--ps-surface-500);
}
.ps-summary-row.ps-discount span:last-child { color: var(--ps-accent-600); }
.ps-summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--ps-surface-100);
  font-size: 15px;
}
.ps-summary-total span:last-child {
  font-size: 18px;
  font-weight: var(--ps-fw-heading);
  color: var(--ps-primary-600);
}
.ps-coupon-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.ps-coupon-input-wrap {
  position: relative;
  flex: 1;
}
.ps-coupon-input-wrap svg {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ps-surface-400);
  pointer-events: none;
}
.ps-coupon-input-wrap .ps-input {
  height: 48px;
  padding-right: 38px;
}
.ps-security-badge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  background: var(--ps-accent-50);
  border-radius: 12px;
}
.ps-security-badge svg {
  color: var(--ps-accent-600);
  flex-shrink: 0;
  margin-top: 1px;
}
.ps-security-badge p {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  color: #15803d;
}

/* Method cards (prototype) */
.ps-method-card {
  border-radius: 16px;
  padding: 18px 20px;
}
.ps-method-card.selected {
  box-shadow: 0 0 0 1px var(--ps-primary-200);
}
.ps-method-price.is-free {
  color: var(--ps-accent-600);
  font-weight: var(--ps-fw-heading);
}
.ps-method-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ps-surface-400);
  margin-top: 4px;
}

/* Address select cards */
.ps-address-select-card.default::before {
  content: attr(data-badge);
  display: inline-block;
  font-size: 10px;
  background: var(--ps-primary-100);
  color: var(--ps-primary-600);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Checkout step transitions */
.ps-checkout-step {
  animation: ps-fade-slide-in 0.28s ease-out;
}
@keyframes ps-fade-slide-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Empty cart */
.panelshop-checkout-empty {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ps-surface-50);
}
.ps-empty-state-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--ps-surface-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: var(--ps-surface-300);
}

/* Thank you page (prototype) */
.panelshop-thank-you {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--ps-accent-50), #fff, var(--ps-primary-50));
  padding: 48px 16px 64px;
}
.ps-thank-you-wrap {
  max-width: 640px;
  margin: 0 auto;
}
.ps-thank-you-hero {
  text-align: center;
  margin-bottom: 32px;
}
.ps-thank-you-hero .ps-success-icon {
  width: 96px;
  height: 96px;
  font-size: 48px;
  background: var(--ps-accent-100);
  color: var(--ps-accent-600);
}
.ps-thank-you-hero h1 {
  font-size: 28px;
  font-weight: var(--ps-fw-heading);
  margin: 0 0 8px;
}
.ps-thank-you-hero p {
  color: var(--ps-surface-500);
  margin: 0;
}
.ps-thank-you-card {
  background: #fff;
  border-radius: 24px;
  border: 1px solid var(--ps-surface-100);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  margin-bottom: 24px;
  text-align: right;
  max-width: none;
  padding: 0;
}
.ps-thank-you-banner {
  padding: 24px;
  background: linear-gradient(to left, var(--ps-primary-500), var(--ps-primary-600));
  color: #fff;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.ps-thank-you-banner label {
  display: block;
  font-size: 12px;
  opacity: 0.85;
  margin-bottom: 4px;
}
.ps-thank-you-banner strong {
  font-size: 22px;
  font-weight: var(--ps-fw-heading);
}
.ps-thank-you-banner .ps-tracking-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.ps-thank-you-banner .ps-tracking-code {
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  direction: ltr;
}
.ps-copy-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.ps-copy-btn:hover { background: rgba(255, 255, 255, 0.35); }
.ps-thank-you-body { padding: 24px; }
.ps-status-timeline {
  display: flex;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 4px;
}
.ps-status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
}
.ps-status-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ps-surface-100);
  color: var(--ps-surface-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}
.ps-status-step.done .ps-status-dot {
  background: var(--ps-accent-500);
  color: #fff;
}
.ps-status-step.current .ps-status-dot {
  background: var(--ps-primary-500);
  color: #fff;
}
.ps-status-step span {
  font-size: 10px;
  color: var(--ps-surface-400);
  line-height: 1.3;
}
.ps-status-step.done span,
.ps-status-step.current span {
  color: var(--ps-accent-600);
  font-weight: 600;
}
.ps-thank-you-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.ps-detail-box {
  padding: 16px;
  background: var(--ps-surface-50);
  border-radius: 12px;
}
.ps-detail-box label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ps-surface-400);
  margin-bottom: 6px;
}
.ps-detail-box p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ps-surface-800);
  line-height: 1.5;
}
.ps-thank-you-products h4 {
  font-size: 14px;
  margin: 0 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--ps-surface-100);
}
.ps-thank-you-product {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.ps-thank-you-product img,
.ps-thank-you-product .ps-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--ps-surface-100);
  object-fit: cover;
}
.ps-thank-you-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--ps-surface-100);
}
.ps-thank-you-total span:last-child {
  font-size: 20px;
  font-weight: var(--ps-fw-heading);
  color: var(--ps-primary-600);
}
.ps-thank-you-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.ps-thank-you-actions .ps-btn { flex: 1; min-width: 160px; }
.ps-delivery-estimate {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 24px;
  padding: 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
}
.ps-delivery-estimate svg { color: #d97706; flex-shrink: 0; }
.ps-delivery-estimate strong {
  display: block;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 2px;
}
.ps-delivery-estimate p {
  margin: 0;
  font-size: 12px;
  color: #b45309;
}

/* Dashboard welcome */
.ps-welcome-banner {
  background: linear-gradient(135deg, var(--ps-primary-500), var(--ps-primary-700));
  border-radius: var(--ps-radius-lg);
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.ps-welcome-banner::after {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  top: -60px;
  left: -40px;
}
.ps-welcome-banner h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: var(--ps-fw-heading);
  position: relative;
}
.ps-welcome-banner p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
  position: relative;
}
.ps-stat-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.ps-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ps-stat-icon.orders { background: #eff6ff; color: var(--ps-primary-600); }
.ps-stat-icon.pending { background: #fffbeb; color: #d97706; }
.ps-stat-icon.spent { background: var(--ps-accent-50); color: var(--ps-accent-600); }
.ps-stat-icon.wishlist { background: #fdf2f8; color: #db2777; }
.ps-stat-content { flex: 1; }
.ps-order-card {
  transition: transform 0.2s, box-shadow 0.2s;
}
.ps-order-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--ps-shadow-lg);
}
.ps-order-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ps-surface-100);
}
.ps-status-badge.status-processing { background: #fffbeb; color: #d97706; }
.ps-status-badge.status-completed,
.ps-status-badge.status-delivered { background: var(--ps-accent-50); color: var(--ps-accent-600); }
.ps-status-badge.status-shipped { background: #eff6ff; color: var(--ps-primary-600); }
.ps-status-badge.status-cancelled,
.ps-status-badge.status-failed { background: #fef2f2; color: var(--ps-error); }
.ps-status-badge.status-pending,
.ps-status-badge.status-on-hold { background: var(--ps-surface-100); color: var(--ps-surface-600); }

/* Modal polish */
.ps-modal-content {
  border-radius: 20px;
  max-width: 520px;
}
.ps-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--ps-surface-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* Responsive */
@media (max-width: 768px) {
  .ps-progress-label { display: none; }
  .ps-progress-connector { min-width: 16px; margin-top: 24px; }
  .ps-thank-you-banner { grid-template-columns: 1fr; }
  .ps-thank-you-details { grid-template-columns: 1fr; }
  .ps-status-timeline span { font-size: 9px; }
  .ps-thank-you-actions { flex-direction: column; }
}

/* Global containment — prevent horizontal bleed / clipped containers on mobile */
.panelshop-auth,
.panelshop-checkout,
.panelshop-dashboard,
.panelshop-cart,
.panelshop-thank-you {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.panelshop-auth *,
.panelshop-checkout *,
.panelshop-dashboard *,
.panelshop-cart *,
.panelshop-thank-you * {
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .panelshop-auth,
  .panelshop-checkout,
  .panelshop-dashboard,
  .panelshop-cart,
  .panelshop-thank-you {
    overflow-x: clip;
  }

  .panelshop-checkout.ps-page-shell,
  .panelshop-dashboard.ps-page-shell,
  .panelshop-thank-you.ps-page-shell {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    max-width: 100%;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .panelshop-dashboard.ps-page-shell {
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }

  .ps-checkout-layout,
  .ps-checkout-main,
  .ps-checkout-sidebar,
  .ps-dashboard-layout,
  .ps-dashboard-shell,
  .ps-dashboard-inner,
  .ps-dashboard-content,
  .ps-card,
  .ps-order-summary,
  .ps-stepper,
  .ps-progress-stepper {
    min-width: 0;
    max-width: 100%;
  }

  .ps-checkout-layout {
    padding-left: 0;
    padding-right: 0;
  }

  .ps-form-row,
  .ps-review-grid,
  .ps-stats-grid,
  .ps-recent-purchases-grid,
  .ps-addresses-grid,
  .ps-wishlist-grid {
    min-width: 0;
  }

  .ps-form-row > *,
  .ps-review-grid > *,
  .ps-stats-grid > *,
  .ps-recent-purchases-grid > * {
    min-width: 0;
  }

  img,
  video,
  svg,
  iframe {
    max-width: 100%;
    height: auto;
  }
}

@media (max-width: 410px) {
  .panelshop-dashboard.ps-page-shell {
    padding-left: 0;
    padding-right: 0;
  }

  .panelshop-dashboard .ps-dashboard-layout {
    padding-left: max(4px, env(safe-area-inset-left, 0px));
    padding-right: max(4px, env(safe-area-inset-right, 0px));
  }
}
