/* ============================================================
 * Hub + Login · Apple HIG polish overlay
 * Reusa --accent y el resto de tokens de app.css. Solo aporta
 * nuevos componentes (hub cards, login card) sin tocar el resto.
 * ========================================================== */

:root {
  --hub-spacing: 20px;
  --hub-radius: 16px;
  --hub-shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.06);
  --hub-shadow-md: 0 8px 24px -6px rgba(0,0,0,0.12), 0 2px 6px -1px rgba(0,0,0,0.06);
  --hub-shadow-lg: 0 24px 60px -12px rgba(0,0,0,0.22), 0 8px 20px -4px rgba(0,0,0,0.10);
  --ease-apple: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ==== Shell (shared) ==== */
.hub-body {
  min-height: 100vh;
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  background: var(--bg, #0f0f11);
  color: var(--fg, #f4f4f5);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.hub-body[data-theme="light"] { background: #f5f5f7; color: #1c1c1e; }

/* Aurora background */
.hub-aurora {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.hub-aurora::before, .hub-aurora::after {
  content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%;
  filter: blur(80px); opacity: 0.35;
}
.hub-aurora::before { top: -160px; left: -140px; background: var(--accent, #0A84FF); }
.hub-aurora::after  { bottom: -160px; right: -140px; background: #8E44EC; opacity: 0.25; }

.hub-shell {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ==== Top bar ==== */
.hub-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  background: rgba(15,15,17,0.6);
}
.hub-body[data-theme="light"] .hub-topbar { background: rgba(255,255,255,0.6); border-bottom-color: rgba(0,0,0,0.06); }
.hub-brand {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.hub-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #0A84FF 0%, #003B75 100%);
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px;
  box-shadow: 0 2px 8px rgba(10,132,255,0.35);
}
.hub-title { font-size: 16px; font-weight: 600; letter-spacing: -0.24px; line-height: 1.1; }
.hub-subtitle { font-size: 11px; color: var(--fg-muted, rgba(255,255,255,0.55)); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 2px; }
.hub-spacer { flex: 1; }
.hub-user-chip {
  display: inline-flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 12px 0 6px;
  border-radius: 999px; background: rgba(255,255,255,0.06);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  transition: background 160ms var(--ease-apple);
}
.hub-user-chip:hover { background: rgba(255,255,255,0.12); }
.hub-body[data-theme="light"] .hub-user-chip { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.06); }
.hub-body[data-theme="light"] .hub-user-chip:hover { background: rgba(0,0,0,0.08); }
.hub-user-avatar {
  width: 28px; height: 28px; border-radius: 999px;
  background: linear-gradient(135deg, #5E5CE6, #BF5AF2);
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 12px;
}
.hub-user-name { font-size: 13px; font-weight: 500; line-height: 1; }
.hub-user-role { font-size: 11px; color: var(--fg-muted, rgba(255,255,255,0.55)); line-height: 1; margin-top: 2px; text-transform: capitalize; }
.hub-logout {
  height: 36px; width: 36px; border-radius: 10px;
  background: transparent; border: 1px solid var(--border, rgba(255,255,255,0.08));
  color: var(--fg-muted, rgba(255,255,255,0.55));
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 160ms var(--ease-apple);
}
.hub-logout:hover { background: rgba(255,69,58,0.1); border-color: rgba(255,69,58,0.3); color: #FF453A; }

/* ==== Hero ==== */
.hub-main {
  flex: 1; padding: 56px 24px 48px;
  max-width: 1200px; width: 100%; margin: 0 auto;
}
.hub-hero { margin-bottom: 40px; animation: hub-fade-up 600ms var(--ease-apple) both; }
.hub-eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--accent, #0A84FF); text-transform: uppercase;
  margin-bottom: 10px;
}
.hub-greeting {
  font-size: 40px; font-weight: 700; letter-spacing: -1px; line-height: 1.1;
  margin: 0 0 10px;
}
.hub-lede {
  font-size: 17px; color: var(--fg-muted, rgba(255,255,255,0.65));
  max-width: 640px; margin: 0;
}

/* ==== Tiles grid ==== */
.hub-tiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--hub-spacing);
}
.hub-tile {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 16px;
  padding: 22px; min-height: 180px; border-radius: var(--hub-radius);
  background: var(--bg-elev, rgba(255,255,255,0.04));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  color: inherit; text-decoration: none; cursor: pointer;
  box-shadow: var(--hub-shadow-sm);
  transition: transform 240ms var(--ease-spring), box-shadow 240ms var(--ease-apple);
  animation: hub-fade-up 500ms var(--ease-apple) both;
}
.hub-body[data-theme="light"] .hub-tile {
  background: white; border-color: rgba(0,0,0,0.06);
}
.hub-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--hub-shadow-md);
}
.hub-tile-head { display: flex; align-items: flex-start; justify-content: space-between; }
.hub-tile-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.hub-tile-arrow {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); color: var(--fg-muted, rgba(255,255,255,0.55));
  transition: all 200ms var(--ease-spring);
}
.hub-body[data-theme="light"] .hub-tile-arrow { background: rgba(0,0,0,0.05); }
.hub-tile:hover .hub-tile-arrow {
  background: var(--accent, #0A84FF); color: white; transform: scale(1.1) rotate(-8deg);
}
.hub-tile-title { font-size: 22px; font-weight: 600; letter-spacing: -0.32px; margin: 0; line-height: 1.2; }
.hub-tile-desc { font-size: 14px; color: var(--fg-muted, rgba(255,255,255,0.6)); line-height: 1.5; margin: 0; }

.hub-tile-aurora {
  position: absolute; bottom: -60px; right: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  filter: blur(50px); opacity: 0; transition: opacity 400ms var(--ease-apple);
  pointer-events: none;
}
.hub-tile:hover .hub-tile-aurora { opacity: 0.35; }

/* Tile color variants */
.hub-tile.tone-blue   .hub-tile-icon, .hub-tile.tone-blue   .hub-tile-aurora { background: linear-gradient(135deg, #0A84FF, #5E5CE6); }
.hub-tile.tone-green  .hub-tile-icon, .hub-tile.tone-green  .hub-tile-aurora { background: linear-gradient(135deg, #32D74B, #66D4CF); }
.hub-tile.tone-purple .hub-tile-icon, .hub-tile.tone-purple .hub-tile-aurora { background: linear-gradient(135deg, #BF5AF2, #FF375F); }
.hub-tile.tone-orange .hub-tile-icon, .hub-tile.tone-orange .hub-tile-aurora { background: linear-gradient(135deg, #FF9F0A, #FF453A); }
.hub-tile.tone-teal   .hub-tile-icon, .hub-tile.tone-teal   .hub-tile-aurora { background: linear-gradient(135deg, #6AC4DC, #0A84FF); }
.hub-tile.tone-pink   .hub-tile-icon, .hub-tile.tone-pink   .hub-tile-aurora { background: linear-gradient(135deg, #FF375F, #BF5AF2); }
.hub-tile.tone-cyan   .hub-tile-icon, .hub-tile.tone-cyan   .hub-tile-aurora { background: linear-gradient(135deg, #5AC8FA, #30B0C7); }
.hub-tile.tone-amber  .hub-tile-icon, .hub-tile.tone-amber  .hub-tile-aurora { background: linear-gradient(135deg, #FFD60A, #FF9F0A); }

/* Hub-tile staggered fade */
.hub-tile:nth-child(1) { animation-delay: 60ms; }
.hub-tile:nth-child(2) { animation-delay: 120ms; }
.hub-tile:nth-child(3) { animation-delay: 180ms; }
.hub-tile:nth-child(4) { animation-delay: 240ms; }
.hub-tile:nth-child(5) { animation-delay: 300ms; }
.hub-tile:nth-child(6) { animation-delay: 360ms; }

.hub-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 11px; font-weight: 500; line-height: 1;
  background: rgba(255,159,10,0.15); color: #FF9F0A;
}

/* ==== Login ==== */
.login-center {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; z-index: 1;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-elev, rgba(30,30,32,0.72)); backdrop-filter: blur(30px);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 20px; box-shadow: var(--hub-shadow-lg);
  padding: 36px 32px; animation: hub-sheet-up 420ms var(--ease-apple) both;
}
.hub-body[data-theme="light"] .login-card {
  background: rgba(255,255,255,0.85); border-color: rgba(0,0,0,0.08);
}
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-head h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.24px; margin: 0 0 4px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-label { font-size: 12px; font-weight: 500; color: var(--fg-muted, rgba(255,255,255,0.7)); }
.login-input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 12px;
  background: rgba(255,255,255,0.05); color: inherit;
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  font: inherit; font-size: 15px;
  outline: none; transition: all 160ms var(--ease-apple); box-sizing: border-box;
}
.hub-body[data-theme="light"] .login-input { background: white; border-color: rgba(0,0,0,0.1); }
.login-input:focus {
  border-color: var(--accent, #0A84FF);
  box-shadow: 0 0 0 4px rgba(10,132,255,0.25);
}
.login-submit {
  width: 100%; height: 48px; margin-top: 6px; border-radius: 12px;
  background: var(--accent, #0A84FF); color: white;
  font: inherit; font-size: 15px; font-weight: 600;
  border: 0; cursor: pointer;
  transition: filter 140ms var(--ease-apple), transform 140ms var(--ease-apple);
  box-shadow: 0 6px 18px rgba(10,132,255,0.35);
}
.login-submit:hover { filter: brightness(1.1); }
.login-submit:active { transform: scale(0.98); }
.login-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.login-footer { margin-top: 20px; text-align: center; font-size: 12px; color: var(--fg-muted, rgba(255,255,255,0.55)); }
.login-error {
  margin-top: 6px; padding: 10px 12px; border-radius: 10px;
  background: rgba(255,69,58,0.1); border: 1px solid rgba(255,69,58,0.3);
  color: #FF6B5A; font-size: 13px;
}

/* ==== Back-to-hub button (inyectado en páginas existentes) ==== */
/* Top-right, z-index alto pero no escandaloso. No colisiona con ningún sidebar. */
.back-to-hub {
  position: fixed; top: 10px; right: 16px; z-index: 9999;
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px 0 8px; border-radius: 8px;
  background: rgba(10,132,255,0.14); color: var(--accent, #0A84FF);
  border: 1px solid rgba(10,132,255,0.28);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif;
  font-size: 12px; font-weight: 500; text-decoration: none; line-height: 1;
  cursor: pointer;
  transition: background 140ms var(--ease-apple), transform 140ms var(--ease-apple);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.back-to-hub:hover { background: rgba(10,132,255,0.22); }
.back-to-hub:active { transform: scale(0.97); }
.back-to-hub svg { width: 13px; height: 13px; }

/* En móviles solo icono */
@media (max-width: 640px) {
  .back-to-hub { padding: 0 8px; }
  .back-to-hub span { display: none; }
}

/* ==== Back-to-hub INTEGRADO en sidebar nav (index/compras) ==== */
/* Reutiliza los estilos `.nav-item` existentes + matiz de color para que
 * se sienta como acción de salida y no un item más del menú. */
.nav-item.back-to-hub-nav {
  color: var(--accent, #0A84FF) !important;
  font-weight: 500;
}
.nav-item.back-to-hub-nav:hover {
  background: rgba(10,132,255,0.1) !important;
}
.nav-item.back-to-hub-nav svg {
  flex-shrink: 0;
  width: 18px; height: 18px;
}

/* ==== Back-to-hub como link inline ====
 * Estilo BASE para inyección en novedades (antes del .sidebar-brand).
 * Las páginas con topbar (cruces/audit/dispo) o sidebar (manufacture) añaden
 * además su propia clase (.cruces-back, .mfg-back-hub, …) y se encargan de
 * margins/colores. Aquí solo damos defaults visuales — SIN margin externo
 * para no romper alineación flex de topbars. */
.back-to-hub-inline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(10,132,255,0.1);
  color: var(--accent, #0A84FF);
  text-decoration: none;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', Inter, sans-serif;
  font-size: 12px; font-weight: 500; line-height: 1;
  transition: background 140ms var(--ease-apple);
  width: fit-content;
}
.back-to-hub-inline:hover { background: rgba(10,132,255,0.18); }
.back-to-hub-inline svg { width: 13px; height: 13px; }
/* Solo cuando se inyecta junto al sidebar brand (novedades): márgenes
 * dedicados sin afectar a las páginas con topbar. */
.sidebar-brand + .back-to-hub-inline,
.back-to-hub-inline:has(+ .sidebar-brand) { margin: 12px 16px 0; }

/* ==== Animaciones ==== */
@keyframes hub-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes hub-sheet-up {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .hub-tile, .hub-hero, .login-card { animation: none; }
  .hub-tile:hover { transform: none; }
}
