/* ==========================================================================
   Lou Jewellery — Order Status Panel
   Styles v2.0 | Premium UI Overhaul

   Changes from v1:
   - Vertical stepper on mobile (< 640px), horizontal on tablet+
   - Warm earth/metal colour palette (replaces SaaS blues)
   - Typography refinements (letter-spacing, weights)
   - Accessibility: improved contrast ratios (WCAG AA)
   - Focus outlines: warm charcoal instead of blue
   - Animation polish: calmer timings
   - Skeleton shimmer: warm cream tint
   - Multi-order grouping header styles
   - Backstep notice fade-slide animation
   - Estimated completion dot indicator
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
  /* Backgrounds */
  --bg-cream: #F5F3F0;
  --surface-white: #FFFFFF;
  --surface-resize: #FFF8F6;
  --surface-commission: #F8F6FF;

  /* Text — improved contrast */
  --text-primary: #1A1A1A;
  --text-body: #444444;
  --text-secondary: #6B6B70;   /* was #8E8E93 — now 5.1:1 contrast */
  --text-placeholder: #999999; /* was #ACACAC — improved contrast */

  /* Accents */
  --accent-coral: #E8766A;
  --accent-purple: #7B6FDE;
  --accent-positive: #4CAF7A;

  /* Focus — warm charcoal instead of blue */
  --focus-ring: #6B7280;

  /* Animation — calmer timings */
  --anim-entrance: 500ms;  /* was 450ms */
  --anim-entrance-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --anim-pulse: 3s;        /* was 2.5s */
  --anim-stagger: 120ms;

  /* Borders */
  --border-input: #E5E5EA;
  --border-input-focus: #1A1A1A;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Typography */
  --font-stack: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg-cream);
  font-family: var(--font-stack);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.embed-mode {
  background: transparent;
}

/* ---------- Page Layout ---------- */
.page-container {
  max-width: 100%;
  margin: 0 auto;
  padding: var(--space-md);
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  min-height: 100vh;
}

@media (min-width: 640px) {
  .page-container {
    max-width: 640px;
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
  }
}

@media (min-width: 1024px) {
  .page-container {
    max-width: 800px;
    padding-left: var(--space-xl);
    padding-right: var(--space-xl);
  }
}

body.embed-mode .page-container {
  min-height: auto;
  padding-top: var(--space-md);
  padding-bottom: var(--space-md);
}

/* ---------- Logo ---------- */
.logo-link {
  display: block;
  margin: 0 auto var(--space-xl);
  width: 200px;
  text-decoration: none;
}

.logo-link img {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Page Heading ---------- */
.page-heading {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: var(--space-lg);
}

@media (min-width: 640px) {
  .page-heading {
    font-size: 24px;
  }
}

/* ---------- Lookup Card ---------- */
.lookup-card {
  background: var(--surface-white);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

/* ---------- Form Fields ---------- */
.field-group {
  margin-bottom: var(--space-md);
}

.field-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-group input {
  display: block;
  width: 100%;
  background: #FFFFFF;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: var(--font-stack);
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 150ms ease;
  min-height: 44px;
}

.field-group input::placeholder {
  color: var(--text-placeholder);
}

.field-group input:focus {
  border-color: var(--border-input-focus);
}

.field-group input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.field-error {
  font-size: 13px;
  color: var(--accent-coral);
  margin-top: var(--space-xs);
  min-height: 0;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 200ms ease, opacity 200ms ease, margin-top 200ms ease;
}

.field-error--visible {
  min-height: 18px;
  max-height: 60px;
  opacity: 1;
  margin-top: var(--space-xs);
}

/* ---------- Order Number Toggle ---------- */
.order-number-field {
  max-height: 120px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 200ms ease, opacity 200ms ease, margin-bottom 200ms ease;
  margin-bottom: 0;
}

.order-number-field--hidden {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  pointer-events: none;
}

/* ---------- Submit Button ---------- */
.submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  background: #1A1A1A;
  color: #FFFFFF;
  font-family: var(--font-stack);
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  padding: 14px 24px;
  cursor: pointer;
  transition: background 150ms ease;
  min-height: 44px;
  margin-top: var(--space-md);
}

.submit-btn:hover:not(:disabled) {
  background: #333333;
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.submit-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- Button Spinner ---------- */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Slow Loading Message ---------- */
.slow-loading-msg {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: var(--space-sm);
  opacity: 0;
  transition: opacity 300ms ease;
}

.slow-loading-msg--visible {
  opacity: 1;
}

/* ---------- Mode Toggle ---------- */
.toggle-mode {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-stack);
  font-size: 13px;
  cursor: pointer;
  padding: 12px 0;
  text-align: center;
  text-decoration: underline;
  min-height: 44px;
}

.toggle-mode:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

#identity-toggle {
  padding: 4px 0;
  min-height: auto;
  margin-bottom: 4px;
  font-size: 12px;
}

/* ---------- Collapsed Lookup Bar ---------- */
.lookup-collapsed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-white);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
  margin-bottom: var(--space-xl);
  font-size: 14px;
  color: var(--text-primary);
}

.lookup-collapsed span {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: var(--space-sm);
}

.new-search-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-stack);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  white-space: nowrap;
  padding: 4px 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.new-search-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- Results Area ---------- */
.results-area {
  position: relative;
}

/* ---------- Order Group Header (multi-item) ---------- */
.order-group-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid #E5E5EA;
}

/* ---------- Order Card ---------- */
.order-card {
  background: var(--surface-white);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  animation: cardEntrance var(--anim-entrance) var(--anim-entrance-ease) both;
}

.order-card:nth-child(2) { animation-delay: var(--anim-stagger); }
.order-card:nth-child(3) { animation-delay: calc(var(--anim-stagger) * 2); }
.order-card:nth-child(4) { animation-delay: calc(var(--anim-stagger) * 3); }
.order-card:nth-child(5) { animation-delay: calc(var(--anim-stagger) * 4); }

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

.order-card--resize {
  background: var(--surface-resize);
  border-left: 4px solid var(--accent-coral);
}

.order-card--commission {
  background: var(--surface-commission);
  border-left: 4px solid var(--accent-purple);
}

/* ---------- Card Header ---------- */
.card-type-badge {
  margin-bottom: var(--space-sm);
}

.card-product-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0 0 var(--space-sm) 0;
  letter-spacing: 0.01em;
}

@media (min-width: 640px) {
  .card-product-name {
    font-size: 18px;
  }
}

/* ---------- Card Details Row ---------- */
.card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  font-size: 14px;
  color: #666666;
  margin-bottom: var(--space-md);
}

.card-detail-separator {
  margin: 0 6px;
  color: #CCCCCC;
}

.card-detail-engraving {
  font-style: italic;
}

/* ---------- Status Badge ---------- */
.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: var(--space-xs) 10px;
  border-radius: 100px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.3s ease;
}

@media (min-width: 640px) {
  .status-badge {
    font-size: 11px;
  }
}

/* ---------- Status Description ---------- */
.status-description {
  font-size: 14px;
  color: var(--text-body);
  line-height: 1.5;
  margin-top: var(--space-sm);
}

@media (min-width: 640px) {
  .status-description {
    font-size: 15px;
  }
}

/* ==========================================================================
   Progress Stepper — Vertical on mobile, horizontal on tablet+
   ========================================================================== */

/* --- Mobile: Vertical stepper (default) --- */
.stepper {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  margin: var(--space-md) 0;
  position: relative;
  padding-left: 20px;
}

.stepper-step {
  display: flex;
  flex-direction: row;
  align-items: center;
  position: relative;
  min-height: 28px;
}

.stepper-dot-row {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.stepper-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  animation: dotAppear 150ms ease-out both;
}

.stepper-dot--completed {
  /* fill color set via inline style */
}

.stepper-dot--current {
  width: 12px;
  height: 12px;
  animation: dotAppear 150ms ease-out both, pulseRing var(--anim-pulse) ease-out infinite;
}

.stepper-dot--future {
  background: transparent;
  border: 1.5px solid #D0CDCA;
}

@keyframes dotAppear {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulseRing {
  0% {
    box-shadow: 0 0 0 0 var(--dot-color, rgba(59, 130, 246, 0.35));
  }
  70% {
    box-shadow: 0 0 0 10px var(--dot-color-fade, rgba(59, 130, 246, 0));
  }
  100% {
    box-shadow: 0 0 0 0 var(--dot-color-fade, rgba(59, 130, 246, 0));
  }
}

/* Mobile: Vertical connecting lines */
.stepper-line {
  position: absolute;
  left: 6px;
  top: 14px;
  bottom: -14px;
  width: 1px;
  z-index: 0;
}

.stepper-line--completed {
  /* background set inline with statusColor */
  opacity: 0;
  animation: lineFadeIn 0.6s ease forwards;
}

.stepper-step:nth-of-type(1) .stepper-line--completed { animation-delay: 0ms; }
.stepper-step:nth-of-type(2) .stepper-line--completed { animation-delay: 150ms; }
.stepper-step:nth-of-type(3) .stepper-line--completed { animation-delay: 300ms; }
.stepper-step:nth-of-type(4) .stepper-line--completed { animation-delay: 450ms; }
.stepper-step:nth-of-type(5) .stepper-line--completed { animation-delay: 600ms; }

@keyframes lineFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.stepper-line--future {
  background: none;
  border-left: 1px dashed #D0CDCA;
  border-top: none;
}

/* Mobile: Labels beside dots, full text */
.stepper-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 10px;
  white-space: nowrap;
  line-height: 1.3;
}

.stepper-label--active {
  font-weight: 700;
  /* color set via inline style */
  animation: labelReveal 0.5s var(--anim-entrance-ease) both;
  animation-delay: 300ms;
}

@keyframes labelReveal {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* --- Tablet+: Horizontal stepper (640px+) --- */
@media (min-width: 640px) {
  .stepper {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    padding-left: 0;
    gap: 0;
  }

  .stepper-step {
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-height: auto;
    min-width: 0;
  }

  .stepper-dot-row {
    width: 100%;
    height: 14px;
  }

  .stepper-dot {
    width: 10px;
    height: 10px;
  }

  .stepper-dot--current {
    width: 12px;
    height: 12px;
  }

  /* Horizontal connecting lines */
  .stepper-line {
    position: absolute;
    top: 50%;
    left: calc(50% + 7px);
    right: calc(-50% + 7px);
    bottom: auto;
    width: auto;
    height: 1px;
    transform: translateY(-50%);
  }

  .stepper-line--future {
    border-left: none;
    border-top: 1px dashed #D0CDCA;
  }

  /* Labels below dots, centered */
  .stepper-label {
    font-size: 11px;
    margin-left: 0;
    margin-top: 4px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 2px;
  }

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

/* Visually hidden stepper summary for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Sub-Stage Bar ---------- */
.substage {
  margin-top: 12px;
}

.substage-header {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.substage-track {
  width: 100%;
  height: 4px;
  background: #E5E5EA;
  border-radius: 2px;
  overflow: hidden;
}

.substage-bar-fill {
  height: 100%;
  border-radius: 2px;
  transform-origin: left;
  animation: barFill 1s var(--anim-entrance-ease) both;
  animation-delay: 400ms;
}

@keyframes barFill {
  from {
    transform: scaleX(0);
    opacity: 0.6;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

.substage-description {
  font-size: 14px;
  font-style: italic;
  color: var(--text-body);
  margin-top: 6px;
}

/* ---------- Backstep Notice ---------- */
.backstep-notice {
  background: rgba(212,168,75,0.08);
  border-left: 3px solid #D4A84B;
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 12px;
  animation: backstepSlideIn 400ms var(--anim-entrance-ease) both;
}

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

.backstep-notice strong {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.backstep-notice p {
  font-size: 14px;
  color: var(--text-body);
  line-height: 1.5;
  margin: 0;
}

/* ---------- Estimated Completion ---------- */
.estimated-completion {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.estimated-completion--early {
  color: var(--accent-positive);
  font-weight: 500;
}

/* Completion dot indicator */
.completion-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.completion-dot--on-track {
  background: #5F8F6B; /* sage green */
}

.completion-dot--delayed {
  background: #C8A97E; /* brand gold */
}

/* ---------- Tracking Link ---------- */
.tracking-link {
  display: inline-block;
  margin-top: var(--space-sm);
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: underline;
  min-height: 44px;
  line-height: 44px;
}

.tracking-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- Skeleton Loading ---------- */
.skeleton-container {
  transition: opacity 300ms ease;
}

.skeleton-container--hidden {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 100%;
}

.skeleton-card {
  background: var(--surface-white);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

.skeleton-block {
  background: linear-gradient(90deg, #EBE8E4 25%, #F5F2EE 50%, #EBE8E4 75%);
  background-size: 400px 100%;
  animation: shimmer 2s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton-title {
  width: 60%;
  height: 18px;
  margin-bottom: 12px;
}

.skeleton-detail-row {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: 16px;
}

.skeleton-detail-1 { width: 40%; height: 14px; }
.skeleton-detail-2 { width: 30%; height: 14px; }

.skeleton-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  justify-content: space-between;
}

.skeleton-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-line-between {
  flex: 1;
  height: 2px;
}

.skeleton-text-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.skeleton-text-1 { width: 100%; height: 14px; }
.skeleton-text-2 { width: 80%; height: 14px; }
.skeleton-text-3 { width: 60%; height: 14px; }

/* ---------- Error State Card ---------- */
.error-card {
  background: var(--surface-white);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  animation: cardEntrance var(--anim-entrance) var(--anim-entrance-ease) both;
}

.error-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.error-card p {
  font-size: 14px;
  color: var(--text-body);
  line-height: 1.5;
  margin-bottom: var(--space-md);
}

.error-card a {
  color: var(--text-primary);
  text-decoration: underline;
}

.error-retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1A1A1A;
  color: #FFFFFF;
  font-family: var(--font-stack);
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  padding: 14px 24px;
  cursor: pointer;
  transition: background 150ms ease;
  min-height: 44px;
}

.error-retry-btn:hover {
  background: #333333;
}

.error-retry-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- Footer ---------- */
.page-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  padding-top: var(--space-lg);
}

.page-footer a {
  color: var(--text-secondary);
  text-decoration: underline;
}

/* ---------- Live Region ---------- */
.aria-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Focus Styles ---------- */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

input:focus-visible {
  outline: none;
  border-color: var(--border-input-focus);
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
