/* ================================================
   UNES SHOPPING — Layout: App Shell, Sidebar, Topbar
   ================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-slow), color var(--t-slow);
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── APP SHELL ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-slow);
}

/* ── SIDEBAR — Neumórfica + Cyan Glow ── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: var(--neu-bg);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--t-slow), width var(--t-slow);
  /* Raised con glow cyan sutil en el borde derecho */
  box-shadow:
    4px 0 18px var(--neu-shadow),
    -2px 0 8px var(--neu-light),
    4px 0 28px rgba(0,180,216,.12);
}

/* Sin shimmer glassmorphism — neumorfismo no usa gradientes */
.sidebar::before { display: none; }

/* Sidebar Brand — neumórfica */
.sidebar-brand {
  padding: 22px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--neu-bg);
  box-shadow:
    var(--neu-raised),
    0 0 12px rgba(0,180,216,.22);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transition: var(--neu-t);
}
.sidebar-brand-icon:hover {
  box-shadow:
    var(--neu-raised-hover),
    0 0 20px rgba(0,180,216,.40);
  transform: scale(1.06);
}
.sidebar-brand-icon img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.sidebar-brand-icon .icon { font-size: 24px; color: var(--neu-accent-dark, var(--primary)); }

.sidebar-brand-text h1 {
  font-size: 14.5px; font-weight: 800;
  color: var(--sidebar-text); letter-spacing: .2px; line-height: 1.15;
}
.sidebar-brand-text p {
  font-size: 9.5px; color: var(--sidebar-text-sub);
  margin-top: 2px; font-weight: 600;
  letter-spacing: .5px; text-transform: uppercase;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px;
  border-radius: var(--neu-r-md);
  font-size: 13px; font-weight: 500;
  color: var(--sidebar-text-sub);
  cursor: pointer;
  position: relative;
  overflow: visible;
  transition: var(--neu-t), color var(--t-fast);
  /* Flat por defecto */
  box-shadow: none;
  background: transparent;
}

/* Sin ripple — neumorfismo usa sombras, no overlays */
.nav-item::before { display: none; }

.nav-item:hover {
  color: var(--sidebar-text);
  box-shadow: var(--shadow-sm);
  background: var(--neu-bg);
}

.nav-item.active {
  background: var(--neu-bg);
  color: var(--cyan, #00b4d8);
  font-weight: 700;
  /* Inset con glow cyan — "presionado" + brillo de acento UNES */
  box-shadow:
    inset -4px -4px  9px var(--neu-light),
    inset  4px  4px  9px var(--neu-shadow),
    0 0 10px rgba(0,180,216,.18);
}
.nav-item.active .icon { color: var(--cyan, #00b4d8) !important; }
.nav-item.active::after {
  content: '';
  position: absolute;
  right: -1px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 55%;
  background: var(--cyan, #00b4d8);
  border-radius: 4px 0 0 4px;
  box-shadow: -1px 0 10px rgba(0,180,216,.65);
}
.nav-item .icon { font-size: 18px; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--neu-bg);
  box-shadow: var(--shadow-xs);
  color: var(--primary); font-size: 9px; font-weight: 800;
  padding: 2px 7px; border-radius: var(--r-full);
  animation: badgePulse 2.2s ease-in-out infinite;
}

/* Sidebar Footer — neumórfica */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--neu-r-md);
  cursor: pointer;
  transition: var(--neu-t);
}
.sidebar-user:hover {
  box-shadow: var(--shadow-sm);
  background: var(--neu-bg);
}

.sidebar-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--neu-bg);
  box-shadow: var(--neu-raised);
  color: var(--primary); font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }
.sidebar-user-info strong {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-info span {
  font-size: 10.5px; color: var(--sidebar-text-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}

.sidebar-role-badge {
  display: inline-block; font-size: 8.5px; font-weight: 800;
  padding: 2px 8px; border-radius: var(--r-full);
  letter-spacing: .06em; text-transform: uppercase; margin-top: 3px;
  background: var(--neu-bg);
  box-shadow: var(--shadow-xs);
}
.role-admin    { color: #92640a; }
.role-general  { color: var(--primary); }

.sidebar-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; margin-top: 4px;
  border-radius: var(--neu-r-md); font-size: 12.5px;
  color: var(--sidebar-text-sub); width: 100%;
  transition: var(--neu-t), color var(--t-fast);
}
.sidebar-logout:hover {
  box-shadow: var(--shadow-sm);
  background: var(--neu-bg);
  color: #dc2626;
}
.sidebar-logout .icon { font-size: 17px; }

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: calc(var(--z-sidebar) - 1);
  backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
.sidebar-overlay.active { display: block; }

/* ── TOPBAR — Neumórfica + cyan border ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  height: 68px;
  background: var(--neu-bg);
  border-bottom: 1px solid rgba(0,180,216,.22);
  position: sticky; top: 0;
  z-index: var(--z-topbar);
  /* Raised sutil + glow cyan hacia abajo */
  box-shadow:
    0 4px 12px var(--neu-shadow),
    0 -2px  6px var(--neu-light),
    0 4px 22px rgba(0,180,216,.10);
  transition: background var(--t-slow);
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

.hamburger-btn {
  display: none;
  width: 38px; height: 38px;
  border-radius: var(--neu-r-sm);
  background: var(--neu-bg);
  border: none;
  box-shadow: var(--shadow-sm);
  align-items: center; justify-content: center;
  color: var(--text-2);
  transition: var(--neu-t);
  flex-shrink: 0;
}
.hamburger-btn:hover { box-shadow: var(--shadow-md); color: var(--primary); }
.hamburger-btn:active { box-shadow: var(--neu-inset); color: var(--primary); }

.topbar-back-btn {
  width: 38px; height: 38px;
  border-radius: var(--neu-r-sm);
  background: var(--neu-bg);
  border: none;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: var(--neu-t), color var(--t-fast), transform var(--t-fast);
  flex-shrink: 0;
}
.topbar-back-btn:hover {
  box-shadow: var(--shadow-md);
  color: var(--primary);
  transform: translateX(-2px);
}
.topbar-back-btn:active {
  box-shadow: var(--neu-inset);
  color: var(--primary);
  transform: translateX(-1px);
}

.topbar-titles h2 {
  font-size: 18px; font-weight: 800;
  color: var(--text); letter-spacing: -.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-titles p {
  font-size: 12px; color: var(--text-3); margin-top: 1px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.topbar-icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--neu-r-md);
  border: none;
  background: var(--neu-bg);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  position: relative;
  transition: var(--neu-t), color var(--t-fast);
}
.topbar-icon-btn:hover {
  box-shadow: var(--shadow-md);
  color: var(--primary);
}
.topbar-icon-btn:active {
  box-shadow: var(--neu-inset);
  color: var(--primary);
}
.topbar-icon-btn .icon { font-size: 19px; }

/* Botón de ayuda/tutorial en topbar */
.topbar-help-btn {
  border-color: color-mix(in srgb, var(--help-color, var(--primary)) 35%, transparent) !important;
  position: relative;
  overflow: visible;
}
.topbar-help-btn:hover {
  border-color: var(--help-color, var(--primary)) !important;
  background: color-mix(in srgb, var(--help-color, var(--primary)) 10%, transparent) !important;
  transform: scale(1.08);
}
/* Pulso sutil para indicar que hay tutorial disponible */
.topbar-help-btn::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--help-color, var(--primary));
  opacity: 0;
  animation: helpPulse 3s ease-in-out 1.5s infinite;
  pointer-events: none;
}
@keyframes helpPulse {
  0%,70%,100% { opacity: 0; transform: scale(1); }
  35%          { opacity: .45; transform: scale(1.18); }
}

.notif-badge {
  position: absolute; top: -5px; right: -5px;
  background: #dc2626; color: #fff;
  font-size: 9px; font-weight: 800;
  min-width: 17px; height: 17px;
  border-radius: var(--r-full);
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-xs);
  animation: badgePulse 2.2s ease-in-out infinite;
}

/* ── PAGE CANVAS ── */
.page-canvas {
  flex: 1;
  padding: 28px 28px;
  overflow-x: hidden;
  animation: fadeIn .3s ease;
}

.page-centered {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    /* Garantiza que el sidebar esté encima del overlay */
    z-index: calc(var(--z-sidebar) + 1);
  }
  .sidebar.open {
    transform: translateX(0);
    animation: sidebarIn var(--t-slow) both;
    box-shadow: 4px 0 40px rgba(0,0,0,.35);
  }
  .main-area { margin-left: 0 !important; }
  .hamburger-btn { display: flex; }
  .page-canvas { padding: 20px 16px; }
  .topbar { padding: 0 16px; height: 60px; }
}

/* Formulario de 2 columnas → 1 columna en mobile */
@media (max-width: 960px) {
  .form-2col { grid-template-columns: 1fr !important; }
}
