/* ==========================================================================
   NAVEGACIÓN — 5 destinos planos (barra lateral / barra inferior), pestañas de sección,
   menú de usuario y botón "Añadir". Se carga después de polish.css.
   ========================================================================== */

/* ---------- Barra lateral: buscador, añadir y destinos ---------- */
.rail-search {
  width: 100%; margin-bottom: 0.6rem;
  display: flex; align-items: center; gap: 0.7rem;
  min-height: 2.6rem; padding: 0 0.85rem;
  border-radius: 0.75rem;
  color: var(--muted-foreground); font-size: 0.9rem;
  background: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
  transition-property: background-color, color, box-shadow;
  transition-duration: 0.16s;
}
.rail-search:hover { background: rgba(255, 255, 255, 0.09); color: var(--foreground); }

.rail-add {
  width: 100%;
  display: flex; align-items: center; gap: 0.6rem;
  min-height: 2.6rem; padding: 0 0.85rem;
  border-radius: 0.75rem;
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 0.92rem;
  background: rgb(var(--a-500));
  box-shadow: 0 1px 2px rgb(var(--a-700) / 0.5), 0 8px 18px -8px rgb(var(--a-500) / 0.7), inset 0 1px 0 rgb(255 255 255 / 0.2);
  transition-property: transform, background-color, box-shadow;
  transition-duration: 0.18s;
  transition-timing-function: var(--ease-out);
}
.rail-add > span { flex: 1; text-align: left; }
.rail-add .kbd { color: #fff; background: rgb(0 0 0 / 0.18); border-color: rgb(255 255 255 / 0.22); }
.rail-add:hover { background: rgb(var(--a-400)); }
.rail-add:active { transform: scale(var(--press)); }

.rail-nav { position: relative; display: flex; flex-direction: column; gap: 0.2rem; margin-top: 1.4rem; }
.rail-indicator {
  position: absolute; inset: 0 0 auto 0; height: 2.75rem;
  border-radius: 0.75rem;
  background: rgb(var(--a-500) / 0.16);
  box-shadow: inset 0 0 0 1px rgb(var(--a-500) / 0.22);
  opacity: 0; pointer-events: none; will-change: transform, height;
}
.rail-indicator.is-ready { opacity: 1; }

.rail-link {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 0.8rem;
  min-height: 2.75rem; padding: 0 0.9rem;
  border-radius: 0.75rem;
  color: var(--muted-foreground);
  font-family: var(--font-display); font-weight: 600; font-size: 0.97rem; letter-spacing: -0.005em;
  text-decoration: none;
  transition-property: color, background-color, transform;
  transition-duration: 0.16s;
  transition-timing-function: var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.rail-link svg { flex: none; transition: transform 0.22s var(--ease-out), color 0.16s; }
.rail-link:hover { color: var(--foreground); background: var(--muted); }
.rail-link:hover svg { transform: translateX(2px); }
.rail-link:active { transform: scale(0.98); }
.rail-link.is-active { color: #fff; background: transparent; }
.rail-link.is-active svg { color: rgb(var(--a-400)); }
.rail-link.is-active:hover svg { transform: none; }
.rail-label { flex: 1; }

/* Insignias numéricas */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.25rem; height: 1.25rem; padding: 0 0.35rem;
  border-radius: 9999px;
  font-size: 0.7rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
  color: #fff; background: rgb(var(--a-500));
}

/* ---------- Perfil: abre el menú de usuario ---------- */
.user-trigger {
  width: 100%;
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.45rem; border-radius: 0.85rem; text-align: left;
  color: var(--foreground);
  background: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
  transition-property: background-color, box-shadow;
  transition-duration: 0.16s;
  -webkit-tap-highlight-color: transparent;
}
.user-trigger:hover, .user-trigger[aria-expanded='true'] { background: rgba(255, 255, 255, 0.1); }
.user-trigger.is-active { box-shadow: inset 0 0 0 1px rgb(var(--a-500) / 0.5); }
.user-trigger.is-admin .sidebar-profile-avatar { box-shadow: 0 0 0 2px #0a0c0f, 0 0 0 3.5px rgb(var(--a-400)); }
.user-trigger-chevron { flex: none; color: var(--muted-foreground); transition: transform 0.25s var(--ease-out); }
.user-trigger[aria-expanded='true'] .user-trigger-chevron { transform: rotate(180deg); }
.user-chip { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }
.user-chip > span, .user-chip-img { width: 2.1rem; height: 2.1rem; border-radius: 0.65rem; display: grid; place-items: center; background: rgb(var(--a-500)); color: #fff; object-fit: cover; }

.user-menu {
  position: fixed; z-index: 1400;
  display: flex; flex-direction: column; gap: 0.1rem;
  min-width: 14rem; max-width: calc(100vw - 1rem);
  padding: 0.4rem;
  border-radius: 1rem;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--border-strong), 0 2px 4px rgb(0 0 0 / 0.08), 0 24px 48px -16px rgb(0 0 0 / 0.45);
  will-change: transform, opacity;
}
.user-menu[hidden] { display: none; }
.user-menu-head { display: flex; flex-direction: column; padding: 0.55rem 0.7rem 0.65rem; gap: 0.1rem; }
.user-menu-head strong { font-family: var(--font-display); font-size: 0.95rem; color: var(--foreground); }
.user-menu-head span { font-size: 0.78rem; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-item {
  display: flex; align-items: center; gap: 0.7rem;
  min-height: 2.6rem; padding: 0 0.7rem; width: 100%;
  border-radius: 0.65rem; text-align: left;
  font-size: 0.92rem; font-weight: 600; color: var(--foreground); text-decoration: none;
  transition-property: background-color, color; transition-duration: 0.12s;
}
.user-menu-item svg { color: var(--muted-foreground); flex: none; }
.user-menu-item > span { flex: 1; }
.user-menu-item:hover, .user-menu-item:focus-visible { background: var(--muted); outline: none; }
.user-menu-item.is-active { color: rgb(var(--a-500)); }
.user-menu-item.is-active svg { color: rgb(var(--a-500)); }
.user-menu-item.is-danger, .user-menu-item.is-danger svg { color: var(--gauge-bad); }
.user-menu-item.is-danger:hover { background: rgb(240 68 56 / 0.1); }
.user-menu-sep { height: 1px; margin: 0.3rem 0.5rem; background: var(--border); }
.user-menu-item .kbd { color: var(--muted-foreground); }

/* ---------- Pestañas de sección (páginas hermanas) ---------- */
.section-tabs {
  position: relative;
  display: flex; gap: 0.2rem;
  width: fit-content; max-width: 100%;
  margin-bottom: clamp(1rem, 0.8rem + 1vw, 1.75rem);
  padding: 0.3rem;
  border-radius: 9999px;
  background: var(--card-sunken);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs a {
  position: relative; z-index: 1; flex: none;
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 2.5rem; padding: 0 1rem;
  border-radius: 9999px;
  font-family: var(--font-display); font-weight: 600; font-size: 0.92rem; letter-spacing: -0.005em;
  color: var(--muted-foreground); text-decoration: none; white-space: nowrap;
  transition-property: color, transform; transition-duration: 0.16s; transition-timing-function: var(--ease-out);
}
.section-tabs a:hover { color: var(--foreground); }
.section-tabs a:active { transform: scale(var(--press)); }
.section-tabs a.is-active { color: var(--foreground); }
.section-tabs a.is-active svg { color: rgb(var(--a-500)); }
.section-tabs .tab-indicator { background: var(--card); border-radius: 9999px; box-shadow: 0 0 0 1px var(--border), 0 1px 3px rgb(15 23 42 / 0.12); }
/* Sin JS el indicador no existe: la pestaña activa lleva su propio fondo */
.section-tabs:not(.has-indicator) a.is-active { background: var(--card); box-shadow: 0 0 0 1px var(--border), 0 1px 3px rgb(15 23 42 / 0.12); }

/* ---------- Añadir: modal de elección ---------- */
.quick-add-grid { display: grid; gap: 0.6rem; }
@media (min-width: 40rem) { .quick-add-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.quick-add-item {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.85rem 1rem; border-radius: 1rem;
  background: var(--card-sunken); box-shadow: inset 0 0 0 1px var(--border);
  color: var(--foreground); text-decoration: none;
  transition-property: transform, box-shadow, background-color; transition-duration: 0.18s; transition-timing-function: var(--ease-out);
}
.quick-add-item:hover { background: var(--card); box-shadow: 0 0 0 1px rgb(var(--a-500) / 0.55), var(--lift-1); }
.quick-add-item:active { transform: scale(var(--press)); }
.quick-add-icon { width: 2.6rem; height: 2.6rem; border-radius: 0.75rem; display: grid; place-items: center; flex: none; color: rgb(var(--a-500)); background: rgb(var(--a-500) / 0.12); }
.quick-add-text { display: flex; flex-direction: column; min-width: 0; }
.quick-add-text strong { font-family: var(--font-display); font-size: 1rem; }
.quick-add-text small { font-size: 0.8rem; color: var(--muted-foreground); }

/* ---------- Móvil: barra superior + barra inferior + botón flotante ---------- */
.mobile-bar { grid-template-columns: 1fr auto auto; }
.mobile-bar.is-hidden { transform: none; }

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 60;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom));
  background: rgba(11, 13, 16, 0.92);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.08), 0 -12px 24px -16px rgba(0, 0, 0, 0.6);
}
.bottom-nav-link {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem;
  min-height: 3.4rem; border-radius: 0.8rem;
  color: #8b97a7; font-size: 0.66rem; font-weight: 600; text-decoration: none;
  transition-property: color, transform; transition-duration: 0.16s; transition-timing-function: var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-link::before {
  content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px;
  background: rgb(var(--a-400)); transform: scaleX(0); transition: transform 0.3s var(--ease-out);
}
.bottom-nav-link:active { transform: scale(0.94); }
.bottom-nav-link.is-active { color: #fff; }
.bottom-nav-link.is-active svg { color: rgb(var(--a-400)); }
.bottom-nav-link.is-active::before { transform: scaleX(1); }
.bottom-nav .nav-badge { position: absolute; top: 0.35rem; left: calc(50% + 0.45rem); min-width: 1.05rem; height: 1.05rem; font-size: 0.62rem; }

@media (max-width: 29.99rem) {
  .section-tabs a { padding: 0 0.8rem; gap: 0.4rem; font-size: 0.88rem; }
}
@media (max-width: 767.98px) {
  .app-main { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
}
@media (min-width: 768px) {
  .bottom-nav { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .rail-link:hover svg { transform: none; }
  .bottom-nav-link:active, .rail-link:active { transform: none; }
}

/* ---------- Barra inferior de 5: repostaje central destacado + hoja "Más" ---------- */
.bottom-nav-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; }
.bottom-nav-5 .bottom-nav-link { background: none; border: 0; font-family: inherit; cursor: pointer; }
.bottom-nav-add { position: relative; display: grid; place-items: center; min-height: 3.4rem; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.bottom-nav-add span {
  display: grid; place-items: center; width: 3.3rem; height: 3.3rem; margin-top: -1.1rem; border-radius: 1.15rem; color: #fff;
  background: rgb(var(--a-500));
  box-shadow: 0 0 0 4px rgba(11, 13, 16, 0.92), 0 2px 4px rgb(var(--a-700) / 0.5), 0 12px 24px -8px rgb(var(--a-500) / 0.8), inset 0 1px 0 rgb(255 255 255 / 0.22);
  transition: transform 0.18s var(--ease-out);
}
.bottom-nav-add:active span { transform: scale(var(--press)); }

html.more-lock { overflow: hidden; }
.more-sheet { position: fixed; inset: 0; z-index: 1500; display: grid; align-items: end; }
.more-sheet[hidden] { display: none; }
.more-sheet-backdrop { position: absolute; inset: 0; background: rgb(12 14 18 / 0.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.more-sheet-panel { position: relative; padding: 0.4rem 1rem calc(1rem + env(safe-area-inset-bottom)); background: var(--card); color: var(--foreground); border-radius: 1.6rem 1.6rem 0 0; box-shadow: 0 -1px 0 var(--border), 0 -24px 60px -20px rgb(0 0 0 / 0.45); outline: none; max-height: 88dvh; overflow-y: auto; }
.more-sheet-grab { display: grid; place-items: center; padding: 0.35rem 0 0.7rem; touch-action: none; }
.more-sheet-grab span { width: 2.5rem; height: 0.3rem; border-radius: 9999px; background: var(--border-strong); }
.more-sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.more-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem; min-height: 5.2rem; border-radius: 1.1rem; font-size: 0.82rem; font-weight: 650; text-align: center; background: var(--card-sunken); box-shadow: inset 0 0 0 1px var(--border); color: var(--foreground); transition: transform 0.16s var(--ease-out); }
.more-tile svg { color: rgb(var(--a-500)); }
.more-tile:active { transform: scale(var(--press)); }
.more-tile .nav-badge { position: absolute; top: 0.5rem; right: 0.6rem; min-width: 1.1rem; height: 1.1rem; font-size: 0.65rem; font-style: normal; }
.more-sheet-list { display: grid; margin-top: 0.7rem; border-top: 1px solid var(--border); }
.more-sheet-list a { display: flex; align-items: center; gap: 0.7rem; min-height: 3rem; padding: 0 0.4rem; font-size: 0.92rem; font-weight: 600; color: var(--foreground); border-bottom: 1px solid var(--border); }
.more-sheet-list a:last-child { border-bottom: 0; }
.more-sheet-list svg { color: var(--muted-foreground); }
.more-sheet-list .is-danger { color: var(--gauge-bad); }
@media (min-width: 768px) { .more-sheet { display: none; } }
@media (prefers-reduced-motion: reduce) { .more-sheet-backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* ---------- Avisos en móvil: arriba, bajo la barra superior (no tapan la barra inferior ni el botón +) ---------- */
@keyframes toastInTop { from { opacity: 0; transform: translateY(-0.75rem); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 767.98px) {
  .toast-stack { top: calc(4rem + env(safe-area-inset-top)); bottom: auto; right: 0.75rem; left: 0.75rem; width: auto; z-index: 1300; gap: 0.45rem; }
  .toast { padding: 0.6rem 0.7rem 0.7rem 0.8rem; animation-name: toastInTop; box-shadow: 0 10px 28px -12px rgb(0 0 0 / 0.45); }
  .toast.is-leaving { transform: translateY(-0.75rem); }
  .toast-message { margin-top: 0.2rem; font-size: 0.86rem; }
  .toast-icon { padding: 0.25rem; }
}
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* Variantes de aviso: el CSS compilado de Tailwind no las incluía y todas salían en verde */
.toast-error { --toast-color: var(--gauge-bad); }
.toast-warning { --toast-color: var(--gauge-warn); }
.toast-info { --toast-color: var(--gauge-info); }
