:root{
  --toolbar-h: 56px;
  --toolbar-px: 18px;
  --toolbar-gap: 16px;
  --toolbar-font: 14px;
}

body.page-chrome{
  background: radial-gradient(circle at top, #f4effc, #ede9fe);
}

/* Barra superior (fondo + sticky) */
body.page-chrome .container-fluid{
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: rgba(245, 243, 255, 0.65) !important;
  border-bottom: 1px solid rgba(59, 26, 74, 0.10);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 1050;
  padding: 0 !important;
  color: #3b1a4a;
}

/* Toolbar: NO overflow aquí (si no, corta el dropdown) */
body.page-chrome .container-fluid > .toolbar{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--toolbar-gap);
  padding: 10px var(--toolbar-px);
  min-height: var(--toolbar-h);
  flex-wrap: nowrap;
  font-size: var(--toolbar-font);
  line-height: 1.2;
  overflow: visible;
}

/* ✅ permite shrink correcto en flex */
body.page-chrome .container-fluid > .toolbar > *{
  min-width: 0;
}

/* Logo */
.logo-header{
  height: 34px;
}

/* Navegación */
body.page-chrome .main-nav{
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: nowrap;

  flex: 1 1 auto;
  min-width: 0;
  max-width: none;

  overflow-x: auto;
  overflow-y: visible;

  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

body.page-chrome .main-nav::-webkit-scrollbar{
  height: 0;
}

body.page-chrome .main-nav .nav-link{
  color: rgba(59, 26, 74, 0.75);
  font-weight: 700;
  text-decoration: none;
  border-radius: 999px;
  white-space: nowrap;

  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 10px;
  flex: 0 0 auto;
}

body.page-chrome .main-nav .nav-link:hover{
  background: rgba(59, 26, 74, 0.06);
  color: #3b1a4a;
}

body.page-chrome .main-nav .nav-link.active{
  background: rgba(59, 26, 74, 0.10);
  color: #3b1a4a;
}

/* ✅ Nuevo: bloque derecho */
body.page-chrome .header-right{
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  min-width: 0;
}

body.page-chrome .actions-container,
body.page-chrome .user-container{
  display: flex;
  align-items: center;
  min-width: 0;
}

/* Usuario */
body.page-chrome #logged-username{
  color: #3b1a4a !important;
  font-weight: 700;
  margin: 0 !important;
  font-size: var(--toolbar-font);
  white-space: nowrap;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Botón logout */
body.page-chrome #logout-button{
  border-radius: 999px !important;
  border: 1px solid rgba(59, 26, 74, 0.35) !important;
  color: #3b1a4a !important;
  background: #fff !important;
  font-weight: 700 !important;
  height: 36px;
  padding: 6px 14px;
  line-height: 1;
  white-space: nowrap;
}

body.page-chrome #logout-button:hover{
  background: rgba(59, 26, 74, 0.06) !important;
}

/* Botón engranaje */
body.page-chrome .btn-gear{
  width: 40px !important;
  height: 36px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(59, 26, 74, 0.18) !important;
  background: rgba(255, 255, 255, 0.65) !important;
  color: #3b1a4a !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  padding: 0 !important;
  line-height: 1 !important;
  font-size: 18px !important;
}

body.page-chrome .btn-gear:hover{
  background: rgba(59, 26, 74, 0.06) !important;
}

body.page-chrome .btn-gear.dropdown-toggle::after{
  display: none;
}

/* Dropdown */
body.page-chrome .dropdown-menu{
  border: 1px solid rgba(59, 26, 74, 0.12);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(59, 26, 74, 0.12);
  padding: 10px;
  z-index: 2000;
}

body.page-chrome .dropdown-item{
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  color: #3b1a4a;
}

body.page-chrome .dropdown-item:hover{
  background: rgba(59, 26, 74, 0.06);
}

/* Checks (modo debug, etc.) */
body.page-chrome .container-fluid .form-check-input:checked{
  background-color: #3b1a4a !important;
  border-color: #3b1a4a !important;
}

/* ✅ Breakpoint intermedio */
@media (max-width: 992px){
  body.page-chrome .container-fluid > .toolbar{
    flex-wrap: wrap;
    row-gap: 10px;
    min-height: auto;
    padding: 10px 12px;
  }

  body.page-chrome .logo-link{ order: 1; }
  body.page-chrome .header-right{ order: 2; margin-left: auto; }
  body.page-chrome .main-nav{
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    margin-left: 0 !important;
    gap: 10px;
  }

  body.page-chrome #logged-username{ max-width: 32vw; }
}

/* ✅ XS real: grid limpio (logo|acciones, nav, usuario|logout) */
@media (max-width: 420px){
  body.page-chrome .container-fluid > .toolbar{
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo actions"
      "nav nav"
      "user user";
    gap: 10px 12px;
    align-items: center;
  }

  body.page-chrome .logo-link{ grid-area: logo; }
  body.page-chrome .actions-container{ grid-area: actions; justify-self: end; }
  body.page-chrome .main-nav{ grid-area: nav; width: 100%; gap: 8px; }
  body.page-chrome .user-container{
    grid-area: user;
    width: 100%;
    justify-content: space-between;
  }

  /* reduce ruido: deja solo el switch */
  body.page-chrome #debug-toggle label{ display: none; }

  /* recortes sanos */
  body.page-chrome #logged-username{
    max-width: 60%;
    margin-left: 0 !important;
    font-size: 13px;
  }

  body.page-chrome #logout-button{
    margin-left: 0 !important;
    height: 34px;
    padding: 6px 12px;
    font-size: 13px;
  }

  body.page-chrome .main-nav .nav-link{
    height: 34px;
    padding: 0 9px;
    font-size: 13px;
  }
  
  body.page-chrome .header-right{
    display: contents; /* el wrapper no ocupa layout, mandan sus hijos */
  }
}

@media (max-width: 360px){
  body.page-chrome .logo-header{ height: 28px; }
  body.page-chrome .btn-gear{ width: 36px !important; }
  body.page-chrome .main-nav .nav-link{ font-size: 12px; padding: 0 8px; }
}

/* Transición de página */
html.is-loading body { opacity: 0 !important; }

body{
  opacity: 1;
  transition: opacity 280ms ease;
}

@media (prefers-reduced-motion: reduce){
  body{ transition: none; }
}

/* Loader */
.custom-loader-wrapper{
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-logo{
  width: 100%;
  height: auto;
  animation: custom-spin 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes custom-spin{
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}