/* =====================================================================
   layout.css — Estructura: menú lateral, barra superior y área de vista
   ===================================================================== */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }

/* ---------- Menú lateral ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 18px 12px;
  background: linear-gradient(180deg, #0B1530 0%, #08101F 100%);
  border-right: 1px solid var(--borde);
  z-index: 40;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 2px 8px; text-decoration: none; }
.marca-logo { width: 44px; height: 44px; flex: none; }
.marca-txt { display: grid; line-height: 1; min-width: 0; }
.marca-nombre { font-family: var(--f-titulo); font-weight: 700; font-style: italic; font-size: 1.28rem; letter-spacing: .05em; }
.marca-sub { font-size: .58rem; font-weight: 600; letter-spacing: .34em; color: var(--azul-claro); margin-top: 5px; }

.nav { display: grid; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--texto-2); text-decoration: none; font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.nav a .ico { width: 21px; height: 21px; flex: none; }
.nav a:hover { background: var(--panel-2); color: var(--texto); }
.nav a[aria-current="page"] {
  background: linear-gradient(90deg, var(--azul), #1452C2);
  color: #fff; border-color: rgba(255, 255, 255, .08);
  box-shadow: 0 8px 22px var(--azul-glow);
}

.sidebar-pie { margin-top: auto; display: grid; gap: 8px; padding: 12px; border: 1px solid var(--borde); border-radius: 12px; background: rgba(15, 23, 42, .6); }
.pie-linea { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--texto-2); }
.pie-linea strong { color: var(--texto); font-weight: 600; }

/* ---------- Barra superior ---------- */
.principal { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: rgba(8, 14, 28, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--borde);
}
.topbar-titulo { display: grid; line-height: 1.25; min-width: 0; }
.topbar-titulo strong { font-family: var(--f-titulo); font-weight: 600; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-titulo span { color: var(--texto-2); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-der { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.reloj { display: flex; align-items: center; gap: 10px; color: var(--texto-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.reloj .ico { width: 18px; height: 18px; }
.reloj #hora { color: var(--texto); font-weight: 600; }
.usuario { display: flex; align-items: center; gap: 8px; color: var(--texto-2); white-space: nowrap; }
.menu-btn { display: none; }

/* Píldora de estado global */
.pill-estado {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  font-weight: 600; font-size: .85rem; white-space: nowrap;
  border: 1px solid currentColor;
  background: rgba(0, 0, 0, .2);
}
.pill-estado i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.pill-estado small { font-weight: 500; opacity: .8; font-size: .72rem; padding: 1px 6px; border-radius: 4px; background: rgba(255, 255, 255, .08); color: var(--texto-2); }
.pill-verde { color: var(--verde); }
.pill-amarillo { color: var(--amarillo); }
.pill-rojo { color: var(--rojo); animation: alarma 1s steps(2) infinite; }
.pill-azul { color: var(--azul-claro); }
.pill-azul i, .pill-amarillo i { animation: parpadeo 1s ease-in-out infinite; }
.pill-gris { color: var(--texto-3); }

/* Botón de paro siempre visible */
.btn-paro-mini {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--rojo); background: var(--rojo-bg); color: #FFB4B4;
  font-weight: 700; font-size: .78rem; letter-spacing: .06em;
}
.btn-paro-mini .ico { width: 16px; height: 16px; }
.btn-paro-mini:hover { background: var(--rojo); color: #fff; }

/* ---------- Área de vistas ---------- */
.vista { padding: 24px; display: grid; gap: 20px; align-content: start; outline: none; }
.vista-cab { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.vista-cab h1 { font-size: 1.45rem; }
.vista-cab p { color: var(--texto-2); margin-top: 2px; }
.vista-cab .acciones { display: flex; flex-wrap: wrap; gap: 10px; }

.velo { position: fixed; inset: 0; background: rgba(2, 6, 15, .6); z-index: 35; }

/* ---------- Responsive ---------- */
@media (min-width: 761px) and (max-width: 1180px) {
  .app { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; align-items: stretch; }
  .marca { justify-content: center; padding: 0; }
  .marca-txt, .nav a span, .pie-linea span { display: none; }
  .nav a { justify-content: center; padding: 12px; }
  .sidebar-pie { padding: 10px; justify-items: center; }
  .reloj #fecha { display: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 270px; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--sombra); }
  .app.menu-abierto .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar-titulo span, .reloj { display: none; }
  .topbar-titulo strong { font-size: 1rem; }
  .vista { padding: 16px; gap: 16px; }
  .vista-cab h1 { font-size: 1.25rem; }
}
@media (max-width: 420px) {
  .pill-estado small { display: none; }
  .btn-paro-mini > span:not(.ico) { display: none; }
  .btn-paro-mini { padding: 7px 9px; }
}

@keyframes parpadeo { 50% { opacity: .35; } }
@keyframes alarma { 50% { background: var(--rojo-bg); } }

/* ---------- Usuario y sesión ---------- */
.usuario-ico .ico { width: 30px; height: 30px; padding: 5px; border-radius: 50%; background: var(--azul-bg); color: var(--azul-claro); }
.usuario-nombre { display: grid; line-height: 1.15; }
.usuario-nombre strong { color: var(--texto); font-size: .88rem; }
.usuario-nombre small { color: var(--texto-2); font-size: .72rem; }
.nav a .nav-candado { width: 15px; height: 15px; margin-left: auto; opacity: .55; }
@media (min-width: 761px) and (max-width: 1180px) { .nav a .nav-candado { display: none; } }
@media (max-width: 760px) {
  .usuario-nombre, .usuario-ico { display: none; }
  .btn-login .btn-txt { display: none; }
  .btn-login { padding: 6px; }
}
