/* ===== Marco de la aplicación: lateral en escritorio, barra inferior en móvil ===== */
.shell {
  min-height: 100dvh;
}

/* ===== Arranque: visible hasta que la aplicación pinta su primer marco ===== */
.boot-splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}

body:has(.shell, .portal, .auth-page) .boot-splash {
  display: none;
}

.boot-slow {
  color: var(--text-muted);
  font-size: 0.9rem;
  opacity: 0;
  animation: fade-to-visible 300ms ease 12s forwards;
}

.boot-slow a {
  color: var(--brand-on-soft);
  font-weight: 600;
}

.boot-noscript {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  margin: 0;
  color: var(--text-muted);
  text-align: center;
}

@keyframes fade-to-visible {
  to {
    opacity: 1;
  }
}

#blazor-error-ui {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 50;
  display: none;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--danger-strong);
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-weight: 600;
  text-align: center;
}

#blazor-error-ui .reload {
  margin-left: 8px;
  color: inherit;
  text-decoration: underline;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text small {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  background: var(--surface);
  border-right: 1px solid var(--outline);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 20;
  transition: width 220ms ease, padding 220ms ease;
}

.sidebar-brand {
  padding: 2px 10px 18px;
  transition: padding 220ms ease;
}

/* Los textos se desvanecen en lugar de desaparecer de golpe cuando el menú se compacta. */
.sidebar .brand-text,
.sidebar .nav-item span:not(.icon) {
  max-width: 190px;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 220ms ease, opacity 150ms ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-exit {
  margin-top: 12px;
}

.nav-group {
  margin: 18px 12px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 150ms ease;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
  transition: background-color 120ms ease, color 120ms ease;
}

.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-on-soft);
}
.topbar {
  display: none;
}

.content {
  margin-left: var(--sidebar-width);
  padding: 32px clamp(20px, 4vw, 48px) 48px;
  max-width: calc(1240px + var(--sidebar-width));
  transition: margin-left 220ms ease;
}

.bottom-nav {
  display: none;
}

/*
  El menú depende del dispositivo, no solo del ancho. Con mouse (una PC aunque la ventana se
  achique) el lateral se compacta a solo iconos con una transición. Con pantalla táctil y poco
  ancho (un celular) pasa a la barra inferior.
*/
@media (max-width: 899.98px) and (pointer: fine) {
  .sidebar {
    width: var(--sidebar-rail-width);
    padding: 20px 12px 14px;
    transition: width 220ms ease, padding 220ms ease, box-shadow 220ms ease;
  }

  .sidebar-brand {
    padding: 2px 4px 18px;
  }

  .sidebar .brand-text,
  .sidebar .nav-item span:not(.icon) {
    max-width: 0;
    opacity: 0;
  }

  .sidebar .nav-item {
    gap: 0;
    padding: 0 14px;
    transition: background-color 120ms ease, color 120ms ease, gap 220ms ease, padding 220ms ease;
  }

  .nav-group {
    height: 1px;
    margin: 14px 8px;
    background: var(--outline);
    opacity: 0.9;
    color: transparent;
  }

  /*
    Con el mouse encima (o al recorrerlo con el teclado) se despliega completo por encima del
    contenido, que no se mueve. La pequeña espera evita que se abra al cruzarlo de paso.
  */
  .sidebar:is(:hover, :has(:focus-visible)) {
    width: var(--sidebar-width);
    padding: 20px 14px 14px;
    box-shadow: var(--shadow-lg);
    transition: width 220ms ease 120ms, padding 220ms ease 120ms, box-shadow 220ms ease 120ms;
  }

  .sidebar:is(:hover, :has(:focus-visible)) .sidebar-brand {
    padding: 2px 10px 18px;
    transition-delay: 120ms;
  }

  .sidebar:is(:hover, :has(:focus-visible)) .brand-text,
  .sidebar:is(:hover, :has(:focus-visible)) .nav-item span:not(.icon) {
    max-width: 190px;
    opacity: 1;
    transition-delay: 120ms;
  }

  .sidebar:is(:hover, :has(:focus-visible)) .nav-item {
    gap: 12px;
    padding: 0 12px;
    transition-delay: 0s, 0s, 120ms, 120ms;
  }

  .sidebar:is(:hover, :has(:focus-visible)) .nav-group {
    height: auto;
    margin: 18px 12px 6px;
    background: none;
    opacity: 1;
    color: var(--text-subtle);
  }

  .content {
    margin-left: var(--sidebar-rail-width);
    max-width: calc(1240px + var(--sidebar-rail-width));
  }
}

@media (max-width: 899.98px) and (pointer: coarse) {
  .sidebar {
    display: none;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 8px 16px;
    padding-top: calc(8px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--outline);
  }

  .content {
    margin-left: 0;
    padding: 20px 16px calc(var(--bottom-nav-height) + 28px + env(safe-area-inset-bottom));
  }

  .bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--outline);
    animation: slide-up 220ms ease;
  }

  .bottom-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: none;
    color: var(--text-subtle);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
  }

  .bottom-item .icon {
    font-size: 22px;
    padding: 2px 14px;
    border-radius: 999px;
    transition: background-color 120ms ease;
  }

  .bottom-item.active {
    color: var(--brand-on-soft);
  }

  .bottom-item.active .icon {
    background: var(--brand-soft);
  }
}

/* ===== Hoja "Más" en móvil ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(6 15 18 / 50%);
  animation: fade-in 140ms ease;
}

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 31;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  animation: slide-up 180ms ease;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: var(--outline-strong);
}

/* ===== Portal público ===== */
.portal {
  min-height: 100dvh;
}

.portal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--outline);
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.portal-nav > a:not(.btn),
.portal-nav > .is-disabled {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
}

.portal-nav > a.active {
  background: var(--brand-soft);
  color: var(--brand-on-soft);
}

.portal-content {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

/* ===== Acceso ===== */
.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(800px 420px at 12% -8%, color-mix(in srgb, var(--brand) 24%, transparent), transparent 70%),
    radial-gradient(640px 360px at 96% 104%, color-mix(in srgb, var(--brand-strong) 18%, transparent), transparent 70%),
    var(--canvas);
}

.auth-card {
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(24px, 5vw, 36px);
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  font-size: 1.45rem;
}

.auth-card p {
  color: var(--text-muted);
}

.auth-links {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-links .is-disabled {
  font-weight: 600;
}

.auth-links a {
  color: var(--brand-on-soft);
  font-weight: 600;
}

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

@keyframes slide-up {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}
