/* Geo-Fiber · capa cósmica del panel admin (se aplica sobre Tailwind, sin romper el loader) */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

body.admin-bg { font-family: 'Manrope', system-ui, sans-serif; }
h1, h2, h3, h4 { font-family: 'Space Grotesk', system-ui, sans-serif; letter-spacing: -0.01em; }

/* Fondo deep-space en dark (más profundo y azulado, nunca negro puro) */
.dark .admin-bg {
    background-image:
        radial-gradient(60% 40% at 50% 0%, rgba(110,139,255,0.10) 0%, transparent 60%),
        linear-gradient(to bottom, rgba(6,8,20,0.90), rgba(6,8,20,0.97)),
        url('/assets/img/fondo_login.png');
}
.dark ::-webkit-scrollbar-thumb { background: #2a3354; }
.dark tbody tr:hover, tbody tr:hover { background-color: rgba(110,139,255,0.10); }

/* --- responsive: sidebar off-canvas en mobile/tablet --- */
#mobile-menu-btn { display: none; }
#sidebar-backdrop { display: none; }

@media (max-width: 1024px) {
    #mobile-menu-btn {
        display: inline-flex; align-items: center; justify-content: center;
        width: 40px; height: 40px; border-radius: 12px;
    }
    #sidebar {
        position: fixed; top: 64px; bottom: 0; left: 0;
        transform: translateX(-100%); transition: transform .3s cubic-bezier(.2,.7,.2,1);
        z-index: 60;
    }
    body.sidebar-open #sidebar { transform: none; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
    body.sidebar-open #sidebar-backdrop {
        display: block; position: fixed; inset: 64px 0 0 0;
        background: rgba(6,8,20,.6); backdrop-filter: blur(2px); z-index: 55;
    }
    header h1 { font-size: 1.1rem !important; }
}

/* ===== animación de entrada de vistas (usada como .animate-fade-in) ===== */
@keyframes gf-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.animate-fade-in { animation: gf-fade-in .35s cubic-bezier(.2,.7,.2,1) both; }
@media (prefers-reduced-motion: reduce) { .animate-fade-in { animation: none; } }

/* ===== focus glow cósmico en todos los formularios del admin ===== */
.admin-bg input, .admin-bg select, .admin-bg textarea { transition: border-color .15s, box-shadow .15s; }
.admin-bg input:focus, .admin-bg select:focus, .admin-bg textarea:focus {
    border-color: #6E8BFF !important;
    box-shadow: 0 0 0 3px rgba(110,139,255,.22) !important;
    outline: none !important;
}

/* ===== unificación de acento: cian -> violeta cósmico ===== */
.text-cyan-600 { color: #6E8BFF !important; }
.dark .dark\:text-\[\#38bdf8\] { color: #8FA3FF !important; }
.dark .dark\:text-cyan-400 { color: #8FA3FF !important; }
.bg-cyan-600 { background-color: #6E8BFF !important; }
.dark .dark\:bg-\[\#38bdf8\] { background-color: #6E8BFF !important; }
.hover\:bg-cyan-500:hover { background-color: #8FA3FF !important; }
.border-cyan-500 { border-color: #6E8BFF !important; }
.border-cyan-500\/50 { border-color: rgba(110,139,255,.5) !important; }
.text-cyan-400 { color: #8FA3FF !important; }
.dark .dark\:hover\:text-\[\#38bdf8\]:hover { color: #8FA3FF !important; }
.hover\:text-cyan-600:hover { color: #6E8BFF !important; }
/* botones con texto oscuro sobre acento: mantener legibilidad */
.dark .dark\:text-\[\#0f172a\] { color: #060814 !important; }

/* ===== detalles de tablas/modales ===== */
.admin-bg table thead { letter-spacing: .04em; }
.admin-bg ::selection { background: rgba(110,139,255,.35); color: #fff; }

/* ===== Modales y formularios internos (dark cósmico) ===== */
/* Backdrop más profundo y difuso */
.dark [id^="modal-"] { background: rgba(6, 8, 20, 0.80) !important; backdrop-filter: blur(10px) !important; -webkit-backdrop-filter: blur(10px) !important; }

/* Panel del modal (el form) como superficie glass cósmica */
.dark [id^="modal-"] form {
  background: rgba(17, 23, 41, 0.96) !important;
  border: 1px solid rgba(255, 255, 255, 0.10) !important;
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.12), 0 30px 80px -20px rgba(0, 0, 0, 0.85) !important;
}
/* Título del modal: subrayado hairline */
.dark [id^="modal-"] form h3 { border-bottom-color: rgba(255, 255, 255, 0.10) !important; letter-spacing: -0.01em; }

/* Inputs / selects / textarea dentro de modales: consistentes y profundos */
.dark [id^="modal-"] input,
.dark [id^="modal-"] select,
.dark [id^="modal-"] textarea {
  background: rgba(6, 8, 20, 0.60) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  transition: border-color .15s, box-shadow .15s;
}
.dark [id^="modal-"] input:focus,
.dark [id^="modal-"] select:focus,
.dark [id^="modal-"] textarea:focus {
  border-color: #6E8BFF !important;
  box-shadow: 0 0 0 3px rgba(110, 139, 255, 0.22) !important;
  outline: none !important;
}
/* Sub-tarjetas de sección dentro de los modales (las cajas con rounded-xl + borde).
   :not(button): los botones de acción también llevan rounded-xl + dark:bg- y esta
   regla les pisaba el fondo (texto oscuro sobre fondo oscuro, sin contraste). */
.dark [id^="modal-"] form .rounded-xl[class*="dark:bg-"]:not(button) {
  background: rgba(6, 8, 20, 0.45) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* ===== Densidad adaptativa =====
   El NOC está pensado para ventanas altas (h-screen sin scroll). En ventanas
   más bajas (laptop, barra de marcadores, zoom) se reduce la base rem para que
   TODO compacte proporcionalmente y no se recorte el contenido inferior. */
@media (max-height: 940px) { html { font-size: 14.5px; } }
@media (max-height: 840px) { html { font-size: 13.5px; } }
@media (max-height: 740px) { html { font-size: 12.5px; } }

/* ===== mapa NOC: marcador de falla pulsante + popup oscuro ===== */
.noc-fault { width: 16px; height: 16px; border-radius: 50%; background: #fb7185; border: 2px solid #fff; cursor: pointer; animation: gf-fault 1.3s infinite; }
@keyframes gf-fault { 0% { box-shadow: 0 0 0 0 rgba(251,113,133,.55); } 70% { box-shadow: 0 0 0 14px rgba(251,113,133,0); } 100% { box-shadow: 0 0 0 0 rgba(251,113,133,0); } }
/* degradación: mismo marcador en ámbar (feedback dueño 07-12) */
.noc-fault-warn { background: #fbbf24; animation-name: gf-fault-warn; }
@keyframes gf-fault-warn { 0% { box-shadow: 0 0 0 0 rgba(251,191,36,.55); } 70% { box-shadow: 0 0 0 14px rgba(251,191,36,0); } 100% { box-shadow: 0 0 0 0 rgba(251,191,36,0); } }
/* !important: leaflet.css puede cargarse DESPUÉS de este archivo (los mapas se
   inicializan por vista) y su fondo blanco por defecto pisaba estas reglas →
   texto claro sobre blanco, ilegible (bug reportado por el dueño 07-12). */
.leaflet-container .leaflet-popup-content-wrapper { background: #111729 !important; color: #E8ECF7 !important; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; font-size: 12.5px; box-shadow: 0 12px 32px -10px rgba(0,0,0,.8); }
.leaflet-container .leaflet-popup-content { color: #E8ECF7 !important; margin: 12px 16px; line-height: 1.55; }
.leaflet-container .leaflet-popup-content b { color: #fff; }
.leaflet-container .leaflet-popup-tip { background: #111729 !important; border: 1px solid rgba(255,255,255,.18); }
.leaflet-container a.leaflet-popup-close-button { color: #A6AEC4 !important; }
.leaflet-container a.leaflet-popup-close-button:hover { color: #fff !important; }

/* ===== editor de rutas: sidebar contraído a íconos, expande al hover (solo desktop) ===== */
@media (min-width: 1025px) {
  body.rail #sidebar { width: 76px; transition: width .22s cubic-bezier(.2,.7,.2,1); overflow: hidden; }
  body.rail #sidebar button, body.rail #sidebar a { font-size: 0; white-space: nowrap; }
  body.rail #sidebar button i, body.rail #sidebar a i { font-size: 1.2rem; }
  /* íconos CENTRADOS en el rail (los items de abajo tienen px-4/gap-4 y quedaban corridos) */
  body.rail #sidebar button, body.rail #sidebar a {
    padding-left: .5rem; padding-right: .5rem;
    justify-content: center; gap: 0;
  }
  body.rail #sidebar:hover { width: 18rem; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
  body.rail #sidebar:hover button, body.rail #sidebar:hover a {
    font-size: .875rem;
    padding-left: 1rem; padding-right: 1rem;
    justify-content: flex-start; gap: 1rem;
  }
}

/* ===== Branding por estado del sidebar (SA y AC) =====
   Expandido: logo3 (vertical, según tema) en el sidebar y SIN logo en cabecera.
   Contraído (rail): ícono cuadrado en el sidebar + logo4 (horizontal) en cabecera. */
.hd-logo, .sb-logo-full, .sb-logo-icon { display: none; }
html:not(.dark) .sb-logo-light { display: block; }
.dark .sb-logo-dark { display: block; }
@media (min-width: 1025px) {
  body.rail #sidebar .sb-logo-full { display: none !important; }
  body.rail #sidebar .sb-logo-icon { display: block; height: 44px; width: 44px; }
  /* logo de cabecera SOLO con el sidebar realmente contraído (sin hover) */
  html:not(.dark) body.rail:not(.rail-hover) .hd-logo-light { display: block; }
  .dark body.rail:not(.rail-hover) .hd-logo-dark { display: block; }
  /* hover del rail (sidebar expandido temporalmente): vuelve el logo3 */
  body.rail #sidebar:hover .sb-logo-icon { display: none; }
  html:not(.dark) body.rail #sidebar:hover .sb-logo-light { display: block !important; }
  .dark body.rail #sidebar:hover .sb-logo-dark { display: block !important; }
}


/* ============== Banner de incidente del Dashboard NOC (con GPS) ============== */
.noc-banner {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px; border-radius: 16px; border: 1px solid;
  backdrop-filter: blur(14px);
}
.noc-banner-danger {
  border-color: rgba(251, 113, 133, .4);
  background: rgba(251, 113, 133, .08);
  animation: noc-alert 2.4s ease-in-out infinite;
}
@keyframes noc-alert {
  0%, 100% { box-shadow: 0 0 40px -14px rgba(251, 113, 133, .5); }
  50%      { box-shadow: 0 0 58px -8px rgba(251, 113, 133, .65); }
}
.noc-banner-warn { border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .07); }
.nb-ic {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 12px; font-size: 1.3rem;
  background: rgba(251, 113, 133, .16); color: #fb7185;
}
.noc-banner-warn .nb-ic { background: rgba(251, 191, 36, .14); color: #fbbf24; }
.nb-title { font-weight: 900; text-transform: uppercase; letter-spacing: .02em; font-size: .92rem; color: #fff; }
html:not(.dark) .nb-title { color: #0f172a; }
.nb-emp {
  font-weight: 700; font-size: .68rem; letter-spacing: .1em; margin-left: 8px;
  padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.08); color: #cbd5e1;
}
html:not(.dark) .nb-emp { background: rgba(15,23,42,.08); color: #475569; }
.nb-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 4px; font-size: .78rem; color: #94a3b8; }
.nb-meta b { color: #fff; }
html:not(.dark) .nb-meta { color: #64748b; }
html:not(.dark) .nb-meta b { color: #0f172a; }
.nb-meta i { margin-right: 5px; opacity: .7; }
.nb-actions { display: flex; gap: 10px; margin-left: auto; flex-shrink: 0; }
.nb-btn {
  padding: 9px 16px; border-radius: 10px; font-size: .72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em; cursor: pointer;
  transition: transform .15s, background .2s, color .2s; border: 1px solid transparent;
  white-space: nowrap;
}
.nb-btn:hover { transform: translateY(-1px); }
.nb-btn-ghost { background: transparent; border-color: rgba(255,255,255,.18); color: #e2e8f0; }
.nb-btn-ghost:hover { border-color: #fb7185; }
html:not(.dark) .nb-btn-ghost { border-color: rgba(15,23,42,.25); color: #334155; }
.nb-btn-solid { background: #fb7185; color: #0f172a; box-shadow: 0 0 26px -8px #fb7185; }
.nb-btn-solid:hover { background: #fda4af; }
.noc-banner-warn .nb-btn-solid { background: #fbbf24; box-shadow: 0 0 26px -8px #fbbf24; }
@media (max-width: 900px) {
  .noc-banner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .nb-actions { margin-left: 0; width: 100%; }
  .nb-btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .noc-banner-danger { animation: none; } }

/* F8: las <option> nativas heredaban el fondo oscuro del select y el pintado
   del SO las dejaba ilegibles (pedido del dueño 07-14): fondo claro SIEMPRE. */
select option, select optgroup {
    background-color: #ffffff;
    color: #0f172a;
}
