/* =============================
   GLOBAL STYLE - Proyecto HD_Car
   ============================= */

/* --------- Orden de capas --------- */
@layer reset, base, layout, utilities;

/* --------- Reset mínimo --------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { height: 100%; }
  body { margin: 0; }
}

/* --------- Base --------- */
@layer base {
  :root{
    /* Alturas de layout (las actualiza el JS si mide alturas reales) */
    --header-height: 120px;
    --menu-height: 60px;
    --content-gap: 14px;

    /* Barras globales fijas (título / selección) */
    --title-h: 56px;
    --select-h: 48px;

    /* Visibilidad calculada por clases del <body> */
    --visible-title: 0px;
    --visible-select: 0px;
  }

  body {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #222;
    background: url("../img/CartaFondo.jpg") no-repeat center center fixed;
    background-size: cover;
  }

  /* Cuando el JS pinte barras, activamos la visibilidad */
  body.has-title  { --visible-title:  var(--title-h); }
  body.has-select { --visible-select: var(--select-h); }

  /* Offset por defecto bajo header + menú + (barras si existen) */
  .page-content.with-offset{
    padding-top: calc(
      var(--header-height, 120px) +
      var(--menu-height, 60px) +
      var(--visible-title) +
      var(--visible-select) +
      var(--content-gap, 14px)
    ) !important;
  }
}

/* --------- Layout fijo del header y menú --------- */
@layer layout {
  .site-header {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--header-height);
    background: linear-gradient(to right, #e2e5f1, #cbdcf0);
    border-bottom: 2px solid #a0a0a0;
    z-index: 1000;
  }

  .header-bar {
    height: 100%;
    display: grid;
    grid-template-columns: 150px 1fr 220px; /* logo - título - usuario */
    align-items: center;
    gap: 12px;
    padding: 0 20px;
  }

  .site-header .logo img { max-height: 80px; display: block; }

  .site-header .titulo {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: #0a2540;
    letter-spacing: 0.5px;
  }

  /* Menú principal fijo */
  .site-menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    background: #0a2540;
    border-bottom: 2px solid #183d6d;
    z-index: 999;
    height: var(--menu-height);
    display: flex;
    align-items: center;
  }

/* ===== MENÚ MULTINIVEL ===== */

#nav,
#nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  width: 100%;
}

#nav > li {
  position: relative;
}

/* enlaces del primer nivel */
#nav > li > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  border-radius: 6px;
  transition: background .3s;
  white-space: nowrap;
}

#nav > li > a:hover {
  background: #183d6d;
}

/* submenú base */
.submenu {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  position: absolute;
  min-width: 220px;
  background: #f5f7fa;
  border: 1px solid #ccc;
  border-radius: 8px;
  display: none;
  z-index: 2000;
  box-shadow: 0 10px 22px rgba(0,0,0,.12);
  overflow: visible;
}

/* el primer nivel solo abre por click (clase open) */
.has-submenu.open > .submenu {
  display: block;
}

/* primer dropdown: debajo del menú principal */
#nav > li > .submenu {
  top: calc(100% + 6px);
  left: 0;
}

/* items internos */
.submenu li {
  position: relative;
}

.submenu li > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  color: #0a2540;
  text-decoration: none;
  background: #f5f7fa;
  transition: background .25s ease;
  white-space: nowrap;
}

.submenu li > a:hover {
  background: #e2e5f1;
}

/* segundo nivel y siguientes: salen hacia la derecha */
.submenu li > .submenu {
  top: 0;
  left: calc(100% + 4px);
}

/* los subniveles internos sí abren con hover */
.submenu li:hover > .submenu {
  display: block;
}

/* padres con hijos */
.has-submenu > a {
  cursor: pointer;
}

.menu-caret {
  font-size: 12px;
  opacity: .8;
  flex: 0 0 auto;
  transition: transform .2s ease;
}

/* flecha del principal cuando está abierto */
#nav > li.has-submenu.open > a .menu-caret {
  transform: rotate(180deg);
}

/* flecha de submenús internos al pasar el mouse */
.submenu li.has-submenu:hover > a .menu-caret {
  transform: rotate(-90deg);
}

/* opcional: items vacíos */
.menu-link.is-empty {
  opacity: .65;
  pointer-events: none;
}


 

}






/* --------- Utilities (incluye anti-gap y barra mensajes) --------- */
@layer utilities {
  .hidden { display: none !important; }
  .flex { display: flex; gap: .5rem; }
  .grid { display: grid; gap: .5rem; }

  /* Responsivo */
  @media (max-width: 900px){
    .header-bar { grid-template-columns: 120px 1fr 160px; }
    .site-header .logo img { max-height: 64px; }
  }
  @media (max-width: 560px){
    .header-bar { grid-template-columns: 100px 1fr 0; }
    .site-header .usuario { display: none; }
    .site-header .titulo { font-size: 18px; }
  }

  /* ===== Anti-Gap global (bajo el menú) =====
     OJO: esto evita que el primer hijo "colapse" márgenes y cree el hueco raro.
  */
  .page-content > :is(.container, [data-module], [data-module] > .container):first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  .page-content > *:first-child {
    padding-top: 1px;                 /* micro tope anti-colapso */
    border-top: 1px solid transparent;
  }

  .page-content > [data-module] > *:first-child {
    padding-top: 1px;
    border-top: 1px solid transparent;
  }

  .page-content h1:first-child,
  .page-content h2:first-child { margin-top: 0; }

  .page-content :is(h1, .card:first-child) { margin-top: 0 !important; }

  /* Ajustes finos por módulo conocido */
  .page-content > [data-module="menurol"] > .container,
  .page-content > [data-module="asig_sede"] > .container,
  .page-content > #asig-root.asig-container {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  /* ===== Barras globales fijas (título / selección) =====
     Importante: NO se repiten en módulos. Solo existen en cabecera/principal.
  */
  .app-title-shell,
  .app-select-shell{
    position: fixed;
    left: 0;
    width: 100%;
    z-index: 980;
    display: none;      /* aparecen cuando se configuran */
    background: transparent;
  }

  body.has-title  .app-title-shell  { display: flex; }
  body.has-select .app-select-shell { display: flex; }

  .app-title-shell{
    top: calc(var(--header-height) + var(--menu-height));
    height: var(--title-h);
    align-items: center;
    background: #e9f2ff;
    border-top: 1px solid #d8e7ff;
    border-bottom: 1px solid #d8e7ff;
  }

  .app-select-shell{
    top: calc(var(--header-height) + var(--menu-height) + var(--visible-title));
    height: var(--select-h);
    align-items: center;
    background: #f5f7fb;
    border-bottom: 1px solid #e1e7f5;
  }

  /* Contenido centrado igual ancho que el sitio */
  .app-title-shell > *,
  .app-select-shell > *{
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
  }

  #app-title-text{
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: #0b3d91;
  }

  #app-select-content{
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    padding: 6px 0;
  }

  #app-select-content .chip{
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eaf0ff;
    color: #0b3d91;
    font-weight: 600;
    border: 1px solid #d8e7ff;
  }

  /* ===== Barra global de mensajes (ÚNICA) ===== */
  #barra-mensajes{
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    top: calc(
      var(--header-height, 120px) +
      var(--menu-height, 60px) +
      var(--visible-title) +
      var(--visible-select) +
      10px
    );
    z-index: 5000;
    min-width: 60%;
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    text-align: center;
    display: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }

  #barra-mensajes.show { opacity: 1; pointer-events: auto; display: block; }
  #barra-mensajes.success { background:#2ecc71; }
  #barra-mensajes.error   { background:#e74c3c; }
  #barra-mensajes.warning { background:#f39c12; }
  #barra-mensajes.info    { background:#3498db; }

  @media (max-width: 900px){
    #barra-mensajes{
      min-width: 86%;
      max-width: 92%;
    }
  }
}

/* ===== Sticky shells “compat” (si algún módulo usa sticky local) ===== */
.mod-sticky-shell,
.vis-sticky-shell,
.asig-sticky-shell {
  position: sticky;
  top: calc(
    var(--header-height, 120px) +
    var(--menu-height, 60px) +
    var(--content-gap, 14px)
  );
  z-index: 900;
  background: transparent;
}

.mod-sticky-shell + *,
.vis-sticky-shell + *,
.asig-sticky-shell + * { margin-top: 8px; }

/* Evitar que el H1 empuje si aparece el primero en shells locales */
.vis-page-title { padding-top: 1px; border-top: 1px solid transparent; }
.vis-page-title h1 { margin-top: .25rem; margin-bottom: .75rem; }
.usuario{
  display:flex;
  align-items:center;
  gap:14px;
  position:relative;
}

.notif-wrap{
  position:relative;
  display:flex;
  align-items:center;
}

.notif-bell{
  position:relative;
  border:none;
  background:transparent;
  cursor:pointer;
  font-size:22px;
  line-height:1;
  padding:6px 8px;
  border-radius:10px;
  transition:background .2s ease;
}

.notif-bell:hover{
  background:rgba(255,255,255,.12);
}

.notif-bell-icon{
  display:inline-block;
}

.notif-count{
  position:absolute;
  top:0;
  right:0;
  min-width:18px;
  height:18px;
  padding:0 5px;
  border-radius:999px;
  background:#d92d20;
  color:#fff;
  font-size:11px;
  font-weight:700;
  display:flex;
  align-items:center;
  justify-content:center;
}

.notif-dropdown{
  position:absolute;
  top:42px;
  right:0;
  width:360px;
  background:#fff;
  border:1px solid #dfe5ec;
  border-radius:14px;
  box-shadow:0 10px 30px rgba(16,24,40,.18);
  z-index:9999;
  overflow:hidden;
}

.notif-dropdown-head{
  padding:12px 14px;
  border-bottom:1px solid #edf1f5;
  background:#f8fafc;
  color:#163a70;
}

.notif-dropdown-list{
  max-height:320px;
  overflow:auto;
  background:#fff;
}

.notif-item-mini{
  width:100%;
  border:none;
  background:#fff;
  text-align:left;
  padding:12px 14px;
  border-bottom:1px solid #f0f3f7;
  cursor:pointer;
}

.notif-item-mini:hover{
  background:#f8fbff;
}

.notif-item-mini.is-unread{
  border-left:4px solid #215ecf;
  background:#f9fbff;
}

.notif-item-mini-title{
  font-size:12px;
  font-weight:700;
  color:#172b4d;
  margin-bottom:4px;
}

.notif-item-mini-meta{
  font-size:11px;
  color:#667085;
}

.notif-dropdown-actions{
  display:flex;
  gap:8px;
  justify-content:space-between;
  padding:12px 14px;
  border-top:1px solid #edf1f5;
  background:#f8fafc;
}

.notif-link-btn{
  border:none;
  background:#eaf2ff;
  color:#163a70;
  font-size:12px;
  font-weight:700;
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
}

.notif-link-btn:hover{
  background:#dce9ff;
}

.notif-empty{
  padding:16px;
  text-align:center;
  font-size:12px;
  color:#667085;
}

.hidden{
  display:none !important;
}
