/* ----------------------------------------------------------------------------
   ACE NUTRITIONS. — Hoja de Componente 24
   Extraida de `tokens.css` en la Iteracion 07.7 (Regla #011).
   El ORDEN de carga en `app-shell.html` reproduce el del archivo original:
   la cascada CSS depende de el y no debe alterarse.
   -------------------------------------------------------------------------- */
/* ============================================================================
   ALINEACION SIMETRICA A ALTURA DE LOS OJOS EN /studio (MISMO ALTO + BODY 3D GRANDE)
   ============================================================================ */
.ace-studio-main-grid {
  grid-template-columns: 1.08fr 0.92fr;
  align-items: stretch;
  gap: 18px;
}

.ace-studio-main-grid > .ace-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px 18px;
}

.ace-studio-3d-controls {
  margin-bottom: 8px;
  gap: 10px;
}

.ace-studio-main-grid .ace-3d-studio-stage {
  flex: 1 1 auto;
  height: auto;
  min-height: 480px;
  margin-top: 6px;
}

.ace-3d-studio-stage.is-results-3d-focus .ace-svg-overlay,
.ace-3d-studio-stage.is-results-3d-focus .ace-3d-floating-inspector {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.ace-3d-floating-inspector {
  padding: 8px 12px;
  border-radius: 14px;
  gap: 10px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ace-site-svg-thumb {
  width: 52px;
  height: 42px;
}

.ace-wizard-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.ace-wizard-pane.is-active {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
}

.ace-wizard-foot {
  margin-top: auto;
  padding-top: 12px;
}

.ace-studio-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-studio);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}

.ace-studio-kpi-strip-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.ace-kpi-box.ace-kpi-compact {
  padding: 10px 11px;
  gap: 2px;
}

.ace-kpi-box.ace-kpi-compact .ace-kpi-label {
  font-size: 10px;
  white-space: nowrap;
}

.ace-kpi-box.ace-kpi-compact .ace-kpi-value {
  font-size: 19px;
  line-height: 1.15;
}

.ace-kpi-box.ace-kpi-compact .ace-kpi-sub {
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ace-future-me-box {
  margin-top: 4px;
  padding: 12px 14px;
  gap: 10px;
}

.ace-card-header.ace-future-head-compact {
  padding-bottom: 8px;
  margin-bottom: 0;
}

.ace-studio-goal-row {
  padding: 8px 10px;
  gap: 8px;
  flex-wrap: nowrap;
}

.ace-studio-goal-chips {
  gap: 4px;
  flex-wrap: nowrap;
}

.ace-studio-goal-chips .ace-btn-sm {
  padding: 5px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.ace-future-deltas.ace-future-deltas-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.ace-future-deltas.ace-future-deltas-4 .ace-future-delta-pill {
  padding: 7px 8px;
}

.ace-future-deltas.ace-future-deltas-4 .ace-future-delta-pill strong {
  font-size: 11.5px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .ace-studio-main-grid {
    grid-template-columns: 1fr;
  }
  .ace-studio-kpi-strip-4,
  .ace-future-deltas.ace-future-deltas-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .ace-studio-goal-row,
  .ace-studio-goal-chips {
    flex-wrap: wrap;
  }
}

/* ============================================================================
   FLUJO DE CONSULTA EN CHEVRON DIRECCIONAL (5 ETAPAS EN FILA HACIA LA DERECHA)
   ============================================================================ */
.ace-happy-path-compact.ace-chevron-flow-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 16px;
}

.ace-happy-path-compact.ace-chevron-flow-bar .ace-happy-path-compact-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ace-chevron-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  width: 100%;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.06));
}

.ace-chevron-step {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px 0 24px;
  margin-left: -10px;
  border: none;
  background: var(--bg-studio);
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%);
  transition: background 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.ace-chevron-step:first-child {
  margin-left: 0;
  padding-left: 16px;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
}

.ace-chevron-step:last-child {
  padding-right: 16px;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 14px 50%);
}

.ace-chevron-step + .ace-chevron-step {
  border-left: 2px solid var(--bg-surface);
}

.ace-chevron-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.ace-chevron-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ace-chevron-step:hover {
  background: var(--border-soft);
  color: var(--ink);
}

.ace-chevron-step.is-done {
  background: var(--jade-soft);
  color: var(--jade-dark);
}

.ace-chevron-step.is-done .ace-chevron-num {
  background: var(--jade);
  color: rgb(255, 255, 255);
}

.ace-chevron-step.is-active,
.ace-chevron-step.ace-btn-primary {
  background: var(--jade);
  color: rgb(255, 255, 255);
  font-weight: 700;
  z-index: 2;
}

.ace-chevron-step.is-active .ace-chevron-num,
.ace-chevron-step.ace-btn-primary .ace-chevron-num {
  background: rgba(255, 255, 255, 0.24);
  color: rgb(255, 255, 255);
}

/* ============================================================================
   SISTEMA 100% MOBILE-FRIENDLY PARA PORTADA (/) Y TODAS SUS SUB-VISTAS
   (/calculadora, /studio, /dashboard, /design-system, /tours, /branding,
    /pricing, /checkout, /faq, /auth/*, Modales y Propuesta Societaria)
   ============================================================================ */

/* 1. Prevención global de desbordamiento horizontal y ajuste de textos largos */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.ace-text-mono,
#patientReferralUrl,
#checkoutClabeInfo {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ace-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 2. Cajón de navegación móvil con scroll vertical garantizado y tema adaptativo */
.ace-mobile-drawer {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 100dvh;
}

.ace-mobile-drawer-nav {
  overflow-y: auto;
  max-height: calc(100dvh - 210px);
  padding-right: 2px;
}

body[data-active-page="landing"] .ace-mobile-drawer,
body[data-active-page="calculator"] .ace-mobile-drawer,
body[data-active-page^="auth"] .ace-mobile-drawer {
  background: rgba(9, 13, 22, 0.98);
  border-left: 1px solid rgba(56, 189, 248, 0.28);
  color: rgb(248, 250, 252);
}

body[data-active-page="landing"] .ace-mobile-drawer-head,
body[data-active-page="calculator"] .ace-mobile-drawer-head,
body[data-active-page^="auth"] .ace-mobile-drawer-head,
body[data-active-page="landing"] .ace-mobile-drawer-foot,
body[data-active-page="calculator"] .ace-mobile-drawer-foot,
body[data-active-page^="auth"] .ace-mobile-drawer-foot {
  border-color: rgba(148, 163, 184, 0.18);
}

body[data-active-page="landing"] .ace-mobile-nav-btn,
body[data-active-page="calculator"] .ace-mobile-nav-btn,
body[data-active-page^="auth"] .ace-mobile-nav-btn {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: rgb(241, 245, 249);
}

body[data-active-page="landing"] .ace-mobile-nav-btn:hover,
body[data-active-page="calculator"] .ace-mobile-nav-btn:hover,
body[data-active-page^="auth"] .ace-mobile-nav-btn:hover {
  border-color: rgb(34, 199, 240);
  color: rgb(34, 199, 240);
}

/* 3. Tablet y Móvil (<= 980px): Topbar unificado, Sidebar Off-Canvas y Sub-navegación */
@media (max-width: 980px) {
  .ace-topbar {
    position: sticky;
    top: 0;
    z-index: 1100;
    min-height: 60px;
    padding: 8px 16px;
    gap: 10px;
  }

  /* Mantener visible .ace-topbar-actions si la página no tiene .ace-mobile-toggle (ej. Propuesta Societaria) */
  .ace-topbar:not(:has(.ace-mobile-toggle)) .ace-topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  body[data-active-page="calculator"] .ace-topbar .ace-mobile-toggle {
    background: rgba(34, 199, 240, 0.15);
    color: rgb(34, 199, 240);
    border: 1px solid rgba(34, 199, 240, 0.45);
  }

  body:not([data-active-page="landing"]):not([data-active-page^="auth"]):not([data-active-page="calculator"]) .ace-topbar .ace-mobile-toggle {
    background: var(--jade-soft);
    color: var(--jade-dark);
    border: 1px solid var(--jade);
  }

  /* App Shell en /studio, /dashboard y /design-system: convertir Sidebar en cajón deslizable Off-Canvas */
  .ace-app-shell,
  .ace-app-shell.is-collapsed {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .ace-app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    max-height: 100dvh;
    min-height: 100dvh;
    overflow-y: auto;
    z-index: 9600;
    border-radius: 0 18px 18px 0;
    padding: 18px 14px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
    transform: translateX(-105%);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .ace-app-shell.is-mobile-sidebar-open .ace-app-sidebar {
    transform: translateX(0);
  }

  /* Asegurar que al abrir el cajón lateral en móvil siempre se lean las etiquetas completas */
  .ace-app-shell.is-collapsed .ace-sidebar-brand-copy,
  .ace-app-shell.is-collapsed .ace-sidebar-group-title,
  .ace-app-shell.is-collapsed .ace-sidebar-label,
  .ace-app-shell.is-collapsed .ace-sidebar-link .ace-badge,
  .ace-app-shell.is-collapsed .ace-sidebar-session-card {
    display: flex;
  }

  .ace-app-shell.is-collapsed .ace-sidebar-link {
    justify-content: flex-start;
    padding: 9px 11px;
  }
}

/* 4. Móvil Estándar y Phablets (<= 860px): Flujo Chevron Horizontal Táctil y Secciones Educativas */
@media (max-width: 860px) {
  /* El Flujo de Consulta mantiene su forma de proceso Chevron en fila horizontal deslizable */
  .ace-chevron-track {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    padding-bottom: 2px;
  }

  .ace-chevron-track::-webkit-scrollbar {
    display: none;
  }

  .ace-chevron-step {
    flex: 0 0 auto;
    min-width: 122px;
    height: 36px;
    padding: 0 14px 0 20px;
    margin-left: -9px;
    font-size: 11.5px;
    clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 50%, calc(100% - 11px) 100%, 0 100%, 11px 50%);
  }

  .ace-chevron-step:first-child {
    margin-left: 0;
    padding-left: 12px;
    clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 50%, calc(100% - 11px) 100%, 0 100%);
  }

  .ace-chevron-step:last-child {
    padding-right: 12px;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 11px 50%);
  }

  /* Secciones educativas de /calculadora */
  .pn-edu-hero-grid,
  .pn-macros-3col-grid,
  .pn-plate-split-grid,
  .pn-hand-pillars-grid,
  .pn-final-cta-banner,
  .pn-hand-atlas-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}
