/* =========================================================================
   Shell: navegación, hero, workspace (stepper + panel) y cadena inferior.
   Escritorio primero (≥1280 = prototipo); reflujo en tablet (≤1024) y móvil (≤640).
   ========================================================================= */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Navegación superior ---------- */
.app-nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-5);
  height: var(--nav-h); padding: 0 var(--gutter);
  background: var(--nav-bg); border-bottom: 1px solid var(--nav-border);
  transition: background-color var(--transition), border-color var(--transition);
}
.app-nav__brand { display: flex; align-items: center; min-width: 0; }
.app-nav__brand .logo { height: 46px; width: auto; }
.logo--dark { display: none !important; }
:root[data-theme="dark"] .logo--light { display: none !important; }
:root[data-theme="dark"] .logo--dark { display: block !important; }

.app-nav__menu { display: flex; align-items: center; gap: 6px; min-width: 0; }
.app-nav__item {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 50px; padding: 0 14px;
  border-radius: var(--radius-sm); color: var(--nav-item); font-size: var(--fs-md); font-weight: var(--fw-bold);
  text-decoration: none; white-space: nowrap; border: 0; background: transparent;
  transition: background-color var(--transition), color var(--transition);
}
.app-nav__item:hover { background: var(--nav-item-hover-bg); color: var(--nav-item-hover); }
.app-nav__item[aria-current="page"], .app-nav__item.is-active {
  background: var(--nav-active-bg); color: var(--nav-active-fg); box-shadow: 0 6px 16px rgba(8, 42, 71, .16);
}
.app-nav__item .ico { font-size: 12px; line-height: 1; }
.app-nav__menu { justify-content: center; }

.app-nav__actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); }
.app-nav__burger { display: none; }

/* Interruptor de tema (único control real: role=switch). */
.theme-switch {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface);
  color: var(--text); font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
.theme-switch__icon { font-size: 16px; line-height: 1; }
.theme-switch__track {
  position: relative; width: 42px; height: 24px; border-radius: var(--radius-pill);
  background: var(--surface-3); border: 1px solid var(--border-strong); transition: background-color var(--transition);
}
.theme-switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-xs); transition: transform var(--transition);
}
.theme-switch[aria-checked="true"] .theme-switch__track { background: var(--brand-blue); border-color: var(--brand-blue); }
.theme-switch[aria-checked="true"] .theme-switch__track::after { transform: translateX(18px); background: #fff; }

/* Usuario */
.user-menu { position: relative; }
.user-box {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 0; background: transparent;
  border-radius: var(--radius-pill); text-align: left; color: var(--text);
}
.user-box:hover { background: var(--surface-hover); }
.avatar {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-navy); color: #fff; font-size: var(--fs-sm); font-weight: var(--fw-heavy);
}
.user-meta { display: grid; line-height: 1.15; }
.user-meta b { font-size: var(--fs-md); }
.user-meta small { color: var(--text-muted); font-size: var(--fs-xs); }
.user-menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--z-dropdown); min-width: 230px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: var(--space-2);
}
.user-menu__panel .menu-info { padding: 8px 10px 10px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 6px; }
.user-menu__panel .menu-info small { display: block; color: var(--text-muted); }
.user-menu__item {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 9px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); text-decoration: none; font-weight: var(--fw-semibold); text-align: left;
}
.user-menu__item:hover { background: var(--surface-hover); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff; background: var(--gradient-hero);
  padding: 18px var(--gutter);
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 42px 42px; -webkit-mask-image: linear-gradient(90deg, transparent 20%, #000); mask-image: linear-gradient(90deg, transparent 20%, #000);
}
.hero__wrap {
  position: relative; display: grid; grid-template-columns: 34% minmax(0, 43%) minmax(0, 23%); align-items: center; gap: 0;
  min-height: 122px;
}
.hero h1 { font-size: var(--fs-hero); font-weight: var(--fw-black); line-height: .92; letter-spacing: -.04em; }
.hero h1 span { color: var(--hero-highlight); }
.hero__lead { margin-top: 10px; font-size: var(--fs-base); line-height: 1.32; color: #dcebf7; }
.hero__lead b { color: #fff; }
.journey { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 0 15px; list-style: none; }
.journey li { display: grid; justify-items: center; text-align: center; gap: 3px; }
.journey .ico { font-size: 22px; line-height: 1; }
.journey li:last-child .ico { color: var(--hero-ai); }
.journey b { font-size: var(--fs-2xs); font-weight: var(--fw-heavy); }
.journey small { font-size: var(--fs-2xs); color: #c7dcec; line-height: 1.15; }
.hero__panel {
  margin-left: 18px; padding: 15px 17px; border-radius: var(--radius-md);
  background: var(--glass-bg); border: 1px solid var(--glass-border);
}
.hero__panel h2 { font-size: 17px; font-weight: var(--fw-heavy); }
.hero__panel p { margin-top: 6px; font-size: var(--fs-xs); color: #d3e5f3; line-height: 1.4; }

/* ---------- Workspace ---------- */
.app-main { flex: 1; padding: 18px var(--gutter) 24px; }
.workspace { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); gap: 30px; align-items: start; }
.workspace--full { grid-template-columns: minmax(0, 1fr); }

.stepper { position: sticky; top: calc(var(--nav-h) + 16px); padding-top: 16px; }
.stepper ol { list-style: none; display: grid; gap: 8px; }
.step {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 9px 13px;
  border-radius: var(--radius-md); background: var(--step-bg); color: var(--text); text-decoration: none;
  border: 1px solid transparent; transition: background-color var(--transition), box-shadow var(--transition);
}
.step:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
.step__num {
  flex: 0 0 34px; width: 34px; min-width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--step-num-bg); color: var(--step-num-fg); font-weight: var(--fw-heavy);
}
.step__text { display: grid; line-height: 1.2; min-width: 0; }
.step__text b { font-size: var(--fs-md); }
.step__text small { font-size: var(--fs-xs); color: var(--step-small); }
.step.is-done .step__num { background: var(--success); color: #fff; }
.step[aria-current="step"] {
  background: var(--gradient-step-active); color: #fff; box-shadow: 0 6px 14px rgba(8, 118, 231, .22);
}
.step[aria-current="step"] .step__num { background: #12afea; color: #fff; }
.step[aria-current="step"] .step__text small { color: #dcefff; }
.step[aria-current="step"]::after {
  content: "›"; position: absolute; right: 14px; font-size: 20px; color: rgba(255, 255, 255, .8);
}

.panel { min-width: 0; }

/* ---------- Pantallas ---------- */
.screen { display: none; animation: screen-in .28s ease backwards; }
.screen.is-active { display: block; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen-head {
  display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: var(--space-5); align-items: end;
  margin: 12px 0 16px;
}
.screen-title { font-size: var(--fs-3xl); font-weight: var(--fw-heavy); line-height: 1.08; letter-spacing: -.035em; }
.screen-sub { margin-top: 6px; color: var(--text-muted); font-size: var(--fs-md); }
.step-progress__label { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-bold); margin-bottom: 6px; }
.step-progress__bar { height: 6px; border-radius: var(--radius-pill); background: var(--chart-track); overflow: hidden; }
.step-progress__bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand-blue); transition: width .3s ease; }

.screen-actions {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  margin-top: var(--space-5);
}

/* ---------- Cadena inferior ---------- */
.footer-chain {
  position: sticky; bottom: 0; z-index: var(--z-footer);
  padding: 7px var(--gutter) 8px; background: var(--gradient-footer); color: #fff;
  border-top: 1px solid #0c456f; box-shadow: 0 -8px 24px rgba(7, 26, 43, .11);
}
.footer-chain__title { display: block; font-size: var(--fs-2xs); font-weight: var(--fw-heavy); letter-spacing: .08em; margin-bottom: 5px; }
.chain { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; list-style: none; max-width: 1580px; margin: 0 auto; }
.chain li {
  display: grid; align-content: center; justify-items: center; text-align: center; min-height: 46px; padding: 4px 18px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%);
  font-size: var(--fs-2xs); font-weight: var(--fw-black); letter-spacing: .02em;
}
.chain li:first-child { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%); }
.chain li small { font-size: var(--fs-2xs); font-weight: var(--fw-medium); color: #e9f4ff; }
.chain li:nth-child(1) { background: var(--chain-0); }
.chain li:nth-child(2) { background: var(--chain-1); }
.chain li:nth-child(3) { background: var(--chain-2); }
.chain li:nth-child(4) { background: var(--chain-3); }
.chain li:nth-child(5) { background: var(--chain-4); }
.chain li:nth-child(6) { background: var(--chain-5); }
.chain li:nth-child(7) { background: var(--chain-6); }
.chain li:nth-child(8) { background: var(--chain-7); }

/* ---------- Página de acceso ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.auth-hero { position: relative; overflow: hidden; background: var(--gradient-hero); color: #fff; padding: 48px var(--gutter); display: grid; align-content: center; gap: 22px; }
.auth-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 42px 42px;
}
.auth-hero > * { position: relative; }
.auth-hero h1 { font-size: clamp(34px, 4vw, 58px); font-weight: var(--fw-black); line-height: .92; letter-spacing: -.045em; }
.auth-hero h1 span { color: var(--hero-highlight); display: block; }
.auth-hero p { color: #d3e5f3; font-size: var(--fs-lg); max-width: 520px; }
.auth-form-wrap { display: grid; align-content: center; padding: 40px var(--gutter); background: var(--surface); }
.auth-card { width: min(420px, 100%); margin: 0 auto; display: grid; gap: var(--space-4); }
.auth-card .logo { height: 54px; width: auto; }
.auth-card h2 { font-size: var(--fs-2xl); font-weight: var(--fw-heavy); }
.auth-theme { position: absolute; top: 16px; right: 16px; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1320px) {
  :root { --sidebar-w: 225px; }
  .app-nav__item { padding: 0 10px; }
  .user-meta { display: none; }
  .workspace { gap: 22px; }
}

@media (max-width: 1500px) {
  .theme-switch__label { display: none; }
}

@media (max-width: 1279px) {
  .hero__wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
  .hero__panel { display: none; }
  .theme-switch__label { display: none; }
}

@media (max-width: 1100px) {
  .app-nav { grid-template-columns: auto 1fr auto; }
  .app-nav__burger {
    display: inline-grid; place-items: center; width: var(--hit); height: var(--hit); border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 20px;
  }
  .app-nav__menu {
    position: fixed; z-index: var(--z-drawer); top: var(--nav-h); right: 0; bottom: 0; width: min(320px, 86vw);
    flex-direction: column; align-items: stretch; gap: 4px; padding: var(--space-4);
    background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
    transform: translateX(105%); transition: transform .22s ease; overflow-y: auto;
  }
  .app-nav__menu.is-open { transform: none; }
  .app-nav__item { flex-direction: row; justify-content: flex-start; gap: 10px; height: 46px; padding: 0 14px; font-size: var(--fs-base); }
  .app-nav__item .ico { font-size: 15px; }
  /* El menú vive dentro del header sticky (contexto de apilamiento z = --z-nav): el scrim debe quedar debajo. */
  .nav-scrim { position: fixed; inset: var(--nav-h) 0 0 0; z-index: calc(var(--z-nav) - 1); background: var(--overlay); }
}

@media (max-width: 1024px) {
  :root { --nav-h: 62px; --stepper-h: 64px; }
  .hero { padding-top: 22px; padding-bottom: 22px; }
  .hero__wrap { grid-template-columns: 1fr; gap: 16px; min-height: 0; }
  .journey {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 88px; overflow-x: auto; padding: 0 0 4px;
    scroll-snap-type: x mandatory;
  }
  .journey li { scroll-snap-align: start; }

  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .stepper {
    position: sticky; top: var(--nav-h); z-index: var(--z-sticky); margin: 0 calc(var(--gutter) * -1); padding: 8px var(--gutter);
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
  }
  .stepper ol { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 2px; }
  .step { min-height: 46px; padding: 6px 12px 6px 6px; gap: 8px; scroll-snap-align: center; }
  .step__num { flex-basis: 30px; width: 30px; min-width: 30px; height: 30px; font-size: var(--fs-sm); }
  .step__text small { display: none; }
  .step[aria-current="step"]::after { display: none; }

  .screen-head { grid-template-columns: 1fr; align-items: start; gap: 12px; }
  .screen-title { font-size: var(--fs-2xl); }

  .footer-chain { position: static; }
  .chain { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .chain li, .chain li:first-child { clip-path: none; border-radius: var(--radius-sm); padding: 6px 8px; }

  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { padding-top: 36px; padding-bottom: 36px; }
}

@media (max-width: 640px) {
  :root { --nav-h: 56px; --stepper-h: 58px; }
  .app-nav { gap: var(--space-2); }
  .app-nav__brand .logo { height: 34px; }
  .theme-switch { padding: 0 4px 0 8px; }
  .btn-demo-guide .label { display: none; }
  .hero h1 { font-size: 30px; }
  .hero__lead { font-size: var(--fs-md); }
  .journey { grid-auto-columns: 70px; }
  .journey small { display: none; }

  .step__text { display: none; }
  .step[aria-current="step"] .step__text { display: grid; }
  .step { padding: 5px; min-height: 42px; }
  .step[aria-current="step"] { padding-right: 12px; }

  .screen-title { font-size: 22px; }
  .chain { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-main { padding-top: 12px; }
}
