/* ==========================================================================
   MicroSIS.ai · Stacked Dialog (vanilla port of components/ui/stacked-dialog.tsx)
   Multi-step dialog stack: previous cards peek above (translateY -offset),
   upcoming cards are hidden, only the active card's content is interactive.
   ========================================================================== */

.sd-trigger {
  margin-top: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 0.375rem;
  background: var(--ink-primary, #1d1d1f);
  color: var(--surface-card, #fff);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 150ms ease, transform 150ms ease;
}

.sd-trigger:hover { opacity: 0.9; }
.sd-trigger:focus-visible { outline: 2px solid var(--accent, #0071e3); outline-offset: 2px; }
.sd-trigger svg { width: 16px; height: 16px; fill: currentColor; }

.sd-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.18);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: sd-fade-in 200ms ease both;
}

.sd-body {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1201;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 32rem;
  padding: 0 1rem;
  box-sizing: border-box;
}

.sd-stack {
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.sd-card {
  box-sizing: border-box;
  border-radius: 22px;
  border: 2px solid rgba(0, 0, 0, 0.05);
  background: var(--surface-card, #fff);
  padding: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  transition: all 300ms ease;
  color: var(--ink-primary);
}

html[data-theme="dark"] .sd-card { border-color: rgba(255, 255, 255, 0.2); }

.sd-card-inner {
  box-sizing: border-box;
  height: 100%;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(38, 38, 38, 0.1);
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 300ms ease;
}

html[data-theme="dark"] .sd-card-inner { background: rgba(255, 255, 255, 0.05); }

.sd-card:not(.is-active) .sd-card-inner {
  pointer-events: none;
  user-select: none;
  opacity: 0;
}

.sd-header {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.sd-avatar {
  position: relative;
  display: flex;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  border-radius: 9999px;
}

.sd-avatar img { width: 100%; height: 100%; aspect-ratio: 1 / 1; object-fit: cover; }

.sd-eyebrow {
  display: block;
  margin-bottom: 0.3rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent, #0071e3);
}

.sd-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
}

.sd-desc {
  margin: 0.35rem 0 0;
  color: rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .sd-desc { color: rgba(255, 255, 255, 0.5); }

.sd-content {
  min-height: 50px;
  margin-top: 0.85rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.sd-content ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.35rem; }

.sd-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
  height: 2.25rem;
  padding: 0 0.95rem;
  border-radius: 999px;
  background: var(--accent, #0071e3);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.sd-cta:hover { color: #fff; opacity: 0.92; }

.sd-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 1rem;
}

.sd-step {
  margin-right: auto;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  color: var(--ink-tertiary, rgba(0, 0, 0, 0.45));
}

.sd-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--ink-primary);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.sd-nav:hover:not(:disabled) { background: rgba(0, 0, 0, 0.05); }
html[data-theme="dark"] .sd-nav:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.sd-nav:disabled { pointer-events: none; opacity: 0.5; }
.sd-nav:focus-visible { outline: 2px solid var(--accent, #0071e3); outline-offset: 2px; }
.sd-nav svg path { fill: currentColor; }
.sd-nav .sd-flip { transform: rotate(180deg); }

@keyframes sd-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sd-card, .sd-card-inner, .sd-overlay { transition: none; animation: none; }
}
