/* =======================================================
   LAYOUT — Sidebar oscuro forestal + topbar y main claros.
   Responsive: ≥1024px sidebar fija, <1024px drawer.
   ======================================================= */

.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  position: relative;
}

/* ===== Sidebar (verde-forest oscuro, texto blanco) ===== */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: var(--space-6) 0 var(--space-6) var(--space-4);
  background: var(--grad-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: var(--z-sidebar);
  transition: transform var(--dur-base) var(--ease-out);
  /* Scrollbar oculto para que el pill activo llegue al borde derecho sin barrera */
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { width: 0; height: 0; display: none; }

.sidebar__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-5);
  margin-right: var(--space-4);
  border-bottom: 1px solid var(--color-sidebar-border);
  text-decoration: none;
  color: inherit;
}
.sidebar__brand-mark {
  width: 76px; height: 76px;
  border-radius: 50%;
  background: var(--grad-accent);
  display: grid; place-items: center;
  color: #fff;
  font-weight: var(--fw-bold);
  font-size: var(--fs-xl);
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
  flex-shrink: 0;
}
.sidebar__brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.2;
  margin-top: var(--space-2);
}
.sidebar__brand-name {
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  font-size: var(--fs-md);
}
.sidebar__brand-sub {
  font-size: var(--fs-xs);
  color: var(--color-sidebar-muted);
  margin-top: 2px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__brand-version {
  font-size: 10px;
  font-weight: var(--fw-semi);
  letter-spacing: 0.1em;
  color: var(--color-accent);
  margin-top: 4px;
  text-transform: uppercase;
}

.sidebar__section { display: flex; flex-direction: column; gap: 2px; }
.sidebar__section-title {
  padding: var(--space-3) var(--space-4) var(--space-1);
  margin-right: var(--space-4);
  font-size: 10px;
  font-weight: var(--fw-semi);
  color: var(--color-sidebar-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-right: var(--space-4);
  border-radius: var(--radius-md);
  color: var(--color-sidebar-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  cursor: pointer;
  position: relative;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--color-sidebar-active);
  color: #fff;
  text-decoration: none;
}
.nav-item__icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--color-sidebar-muted);
  transition: color var(--dur-fast) var(--ease-out);
}
.nav-item__label { flex: 1; }
.nav-item__badge {
  background: var(--color-accent);
  color: #fff;
  font-size: 10px;
  font-weight: var(--fw-bold);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 22px;
  text-align: center;
}

/* Item activo: pill completo (ambos extremos redondeados).
   Los notches arriba/abajo del pill los dibujan los pseudos
   con el color del SIDEBAR, "comiéndose" las esquinas
   superior-derecha e inferior-derecha del pill para que se
   vean cóncavos (la sidebar wrap alrededor del pill). */
.nav-item.is-active {
  background: var(--color-bg);
  color: var(--color-text-strong);
  border-radius: var(--radius-pill) 0 0 var(--radius-pill);
  margin-right: 0;
  font-weight: var(--fw-semi);
}
.nav-item.is-active:hover { background: var(--color-bg); color: var(--color-text-strong); }
.nav-item.is-active .nav-item__icon { color: var(--color-accent); }

.nav-item.is-active::before,
.nav-item.is-active::after {
  content: '';
  position: absolute;
  right: 0;
  width: 32px;
  height: 32px;
  pointer-events: none;
}
/* Pseudo arriba: replica el "border-bottom-right-radius" cóncavo del item
   dark green superior. Centro del arco en la esquina superior-izquierda del
   pseudo (= esquina interior del item dark green). Dark green dentro del
   radio, mint fuera. */
.nav-item.is-active::before {
  top: -32px;
  background: radial-gradient(circle 32px at 0 0, transparent 32px, var(--color-bg) 33px);
}
.nav-item.is-active::after {
  bottom: -32px;
  background: radial-gradient(circle 32px at 0 100%, transparent 32px, var(--color-bg) 33px);
}

.sidebar__footer {
  margin-top: auto;
  margin-right: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.sidebar__avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--grad-accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: var(--fw-bold);
  flex-shrink: 0;
}
.sidebar__user { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar__user-name { font-size: var(--fs-sm); font-weight: var(--fw-semi); color: #fff; }
.sidebar__user-role { font-size: var(--fs-xs); color: var(--color-sidebar-muted); }

.sidebar__footer .icon-btn {
  background: var(--color-sidebar-active);
  color: var(--color-sidebar-text);
  box-shadow: none;
  border-radius: 50%;
  width: 38px; height: 38px;
}
.sidebar__footer .icon-btn:hover { background: var(--color-accent); color: #fff; }

/* Drawer backdrop — siempre fuera del flujo (fixed) para que NO ocupe celda
   de grid en desktop. Solo se activa visualmente cuando se abre el drawer. */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 28, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: calc(var(--z-drawer) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.admin-shell.is-drawer-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ===== Sidebar mini mode (desktop, colapsado a solo íconos) ===== */
@media (min-width: 1024px) {
  .admin-shell.is-sidebar-mini {
    grid-template-columns: var(--sidebar-w-mini) 1fr;
  }
  .admin-shell.is-sidebar-mini .sidebar {
    padding: var(--space-6) 0;
    align-items: center;
  }
  .admin-shell.is-sidebar-mini .sidebar__brand {
    padding: var(--space-2) 0 var(--space-4);
    margin-right: 0;
    border-bottom: 0;
    width: 100%;
  }
  .admin-shell.is-sidebar-mini .sidebar__brand-text { display: none; }
  .admin-shell.is-sidebar-mini .sidebar__brand-mark {
    width: 48px; height: 48px;
    outline-offset: 2px;
    font-size: var(--fs-md);
  }
  .admin-shell.is-sidebar-mini .sidebar__section-title { display: none; }
  .admin-shell.is-sidebar-mini .sidebar__section {
    width: 100%;
    align-items: center;
    padding: 0 var(--space-2);
  }
  .admin-shell.is-sidebar-mini .nav-item {
    margin-right: 0;
    padding: var(--space-3);
    justify-content: center;
    width: 100%;
    border-radius: var(--radius-md);
  }
  .admin-shell.is-sidebar-mini .nav-item__label,
  .admin-shell.is-sidebar-mini .nav-item__badge { display: none; }
  .admin-shell.is-sidebar-mini .nav-item.is-active {
    background: var(--color-sidebar-active);
    color: #fff;
    border-radius: var(--radius-md);
  }
  /* En mini: sin notches (el pill no sale al main) */
  .admin-shell.is-sidebar-mini .nav-item.is-active::before,
  .admin-shell.is-sidebar-mini .nav-item.is-active::after { display: none; }

  .admin-shell.is-sidebar-mini .sidebar__footer {
    margin-right: 0;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding-top: var(--space-3);
    width: 100%;
  }
  .admin-shell.is-sidebar-mini .sidebar__user { display: none; }
}

/* ===== Main area ===== */
.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-bg);
  background-image: var(--grad-bg);
}

/* ===== Topbar (claro, sin sombra dura) ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: rgba(235, 241, 237, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.topbar__menu-btn { display: grid; }
.topbar__title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.topbar__title h1 { font-size: var(--fs-xl); }
.topbar__crumb { font-size: var(--fs-xs); color: var(--color-text-muted); }

.topbar__search {
  flex: 1;
  max-width: 460px;
  margin-left: var(--space-6);
}

.topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--color-sidebar-bg);
  box-shadow: 0 4px 12px rgba(40, 60, 55, 0.18);
  display: grid; place-items: center;
  color: #fff;
  position: relative;
  transition: box-shadow var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  border: 0;
}
.icon-btn:hover {
  background: var(--color-sidebar-bg-deep);
  color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(40, 60, 55, 0.26);
}
.icon-btn:active { transform: translateY(0); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.30); }
.icon-btn__dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-sidebar-bg);
}

/* ===== Content ===== */
.content {
  padding: var(--space-4) var(--space-6) var(--space-12);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  animation: nm-fade-in var(--dur-base) var(--ease-out);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-header__title { display: flex; flex-direction: column; gap: var(--space-1); }
.page-header__title h2 { font-size: var(--fs-2xl); }
.page-header__subtitle { color: var(--color-text-muted); font-size: var(--fs-sm); }

/* Grid helpers */
.grid {
  display: grid;
  gap: var(--space-5);
}
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--12 { grid-template-columns: repeat(12, 1fr); }

@media (max-width: 1023px) {
  .admin-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    z-index: var(--z-drawer);
  }
  .admin-shell.is-drawer-open .sidebar { transform: translateX(0); }

  .topbar__menu-btn { display: grid; }
  .topbar__search { display: none; }

  .grid--3 { grid-template-columns: 1fr; }
  .grid--2 { grid-template-columns: 1fr; }
  .grid--12 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 var(--space-4); }
  .content { padding: var(--space-3) var(--space-4) var(--space-10); }
  .page-header__title h2 { font-size: var(--fs-xl); }
}

/* ===== Auth shell (login / 2FA, sin sidebar) ===== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--color-sidebar-bg);
  background-image: var(--grad-sidebar);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--color-surface);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35), 0 12px 24px rgba(0, 0, 0, 0.20);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  animation: nm-fade-in var(--dur-base) var(--ease-out);
}
.auth-card__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
.auth-card__brand-mark {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--grad-accent);
  display: grid; place-items: center;
  color: #fff;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}
.auth-card__title { text-align: center; }
.auth-card__title h1 { font-size: var(--fs-2xl); }
.auth-card__title p { color: var(--color-text-muted); font-size: var(--fs-sm); margin-top: var(--space-1); }

.auth-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.auth-card__foot > span { white-space: nowrap; }
@media (max-width: 480px) {
  .auth-card { padding: var(--space-8) var(--space-6); }
  .auth-card__foot {
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    text-align: center;
  }
}
