/**
 * Legacy Stepper Compatibility Bridge
 *
 * Maps legacy stepper classes (.step, .detail-step, .icon-step) to Design System styles
 * This bridge creates a sidebar layout matching the Figma design pattern:
 * - Left sidebar: All step indicators stacked vertically
 * - Main content: Active step's content fills the area
 * - Uses display: contents to flatten list items into grid without changing HTML
 *
 * @version 2.0.0
 * @date 2025-11-14
 */

/* ============================================================
   BASE STEPPER STRUCTURE - SIDEBAR LAYOUT
   ============================================================ */

/* Container: Two-column grid (sidebar + main content) */
ul.stepper {
  display: grid;
  grid-template-columns: 272px 1fr;
  column-gap: 32px;
  row-gap: 12px;
  align-items: start;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Flatten list items so children flow directly into grid */
ul.stepper > li.step {
  display: contents;
}

/* ============================================================
   LEFT SIDEBAR - STEP INDICATORS (All stacked vertically)
   ============================================================ */

/* Step indicator cards - all go to column 1 (sidebar) */
ul.stepper .detail-step {
  grid-column: 1;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all 0.3s ease;
  cursor: pointer;
}

ul.stepper .detail-step:hover {
  background: var(--color-bg-secondary);
}

/* Icon (legacy .icon-step) mapped to DS look */
ul.stepper .icon-step {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #E5E7EB;
  color: #8D95A8;
  flex-shrink: 0;
  font-size: 20px;
  transition: all 0.3s ease;
}

/* Active icon (legacy .step-active) = DS active colors (red like Figma) */
ul.stepper .icon-step.step-active {
  background: #DC2626;
  color: var(--color-text-light);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

/* Active step card highlight */
ul.stepper .icon-step.step-active ~ p strong {
  color: var(--color-neutral-800);
  font-weight: 600;
}

/* Step text styling */
ul.stepper .detail-step p {
  margin: 0;
  line-height: 1.4;
  flex: 1;
}

ul.stepper .detail-step strong {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: #5A6478;
  margin-bottom: 4px;
}

ul.stepper .detail-step small {
  display: block;
  font-size: 14px;
  color: #8D95A8;
}

/* ============================================================
   MAIN CONTENT AREA - ACTIVE STEP CONTENT
   ============================================================ */

/* Step content - goes to column 2 (main area) */
ul.stepper .step-content {
  grid-column: 2;
  padding: 8px 0 16px;
  min-height: 400px;
}

/* JS hides non-active content using .hidden */
ul.stepper .step-content.hidden {
  display: none !important;
}

/* Navigation buttons area - sticky at bottom */
ul.stepper .step-action {
  display: flex;
  gap: 12px;
  justify-content: flex-start;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  position: sticky;
  bottom: 0;
  background: transparent;
  z-index: 10;
}

ul.stepper .step-action.step-action--end {
  justify-content: flex-end;
}

/* ============================================================
   MDL BUTTON COMPATIBILITY - Figma Style
   ============================================================ */

/* Legacy MDL button look mapped to DS buttons (robust even if MDL CSS order changes) */
.mdl-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  transition: all 0.2s ease;
}

.mdl-button:hover {
  background: var(--color-bg-secondary);
}

/* "Próximo" button - Red like Figma design */
.mdl-button.prox {
  background: #DC2626;
  border-color: #DC2626;
  color: var(--color-text-light);
  font-weight: 600;
}

.mdl-button.prox:hover {
  background: #B91C1C;
  border-color: #B91C1C;
}

/* "Voltar" and "Cancelar" buttons - Gray outline */
.mdl-button.back,
.mdl-button.cancel {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

.mdl-button.back:hover,
.mdl-button.cancel:hover {
  background: var(--color-bg-secondary);
}

/* ============================================================
   UTILITY FIXES
   ============================================================ */

/* Neutralize leftover Tailwind spacing that doesn't apply to vertical stacks */
ul.stepper.space-x-2 > * { 
  margin-right: 0 !important; 
}

/* ============================================================
   DARK MODE
   ============================================================ */

.dark ul.stepper .detail-step {
  background: var(--color-bg-dark);
  border-color: var(--color-neutral-700);
}

.dark ul.stepper .icon-step {
  background: var(--color-neutral-700);
  color: #707896;
}

.dark ul.stepper .icon-step.step-active {
  background: var(--color-accent-300);
  color: var(--color-text-light);
}

.dark ul.stepper .detail-step strong {
  color: var(--color-neutral-400);
}

.dark ul.stepper .detail-step small {
  color: #707896;
}

.dark ul.stepper > li.step.active .detail-step strong,
.dark ul.stepper .icon-step.step-active ~ p strong {
  color: var(--color-text-light);
}

.dark ul.stepper > li.step:not(:last-child)::before {
  background: var(--color-neutral-700);
}

.dark ul.stepper .step-action {
  border-top-color: var(--color-neutral-700);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  /* Stack sidebar on top of content on mobile */
  ul.stepper {
    grid-template-columns: 1fr;
    row-gap: 16px;
  }
  
  ul.stepper .detail-step,
  ul.stepper .step-content {
    grid-column: 1;
  }
  
  /* Make step action buttons full width on mobile */
  ul.stepper .step-action {
    flex-direction: column;
  }
  
  ul.stepper .step-action .mdl-button {
    width: 100%;
  }
}
