@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;800&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --color-primario:    #1a3a5c;
  --color-secundario:  #2d8c1e;
  --color-fondo:       #f0f2f5;
  --color-sidebar:     #111f2e;
  --color-texto:       #2c2c2c;
  --sidebar-ancho:     240px;
}
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--color-fondo);
  color: var(--color-texto);
  margin: 0;
  font-size: 0.925rem;
}
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
}
.login-card {
  background: #fff;
  border-radius: 4px;
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
  border-top: 3px solid var(--color-primario);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-img {
  max-width: 200px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 0.5rem;
}
.login-logo p {
  color: #6c757d;
  font-size: 0.8rem;
  margin: 0.4rem 0 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-ancho);
  background: var(--color-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}
.sidebar-header {
  padding: 1.3rem 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.marca-sub {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}
.marca-nombre {
  display: inline-block;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-transform: none;
  padding-bottom: 0.1rem;
  line-height: 1;
}
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; min-height: 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav a.activo {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.sidebar-nav a.activo { border-left: 3px solid var(--color-secundario); }
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}
.sidebar-footer #nombre-usuario {
  color: rgba(255,255,255,0.8);
  font-weight: 600;
  display: block;
  margin-bottom: 0.5rem;
}
.main-content { margin-left: var(--sidebar-ancho); flex: 1; padding: 1.5rem 2rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.topbar h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primario);
  margin: 0;
  letter-spacing: 0.01em;
}
.metricas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-bottom: 1.5rem; }
.metrica-card {
  background: #fff; border-radius: 14px;
  padding: 2rem 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border-top: 4px solid var(--color-primario);
  text-align: center;
}
.metrica-card .numero {
  display: block;
  font-size: 3rem; font-weight: 800;
  color: var(--color-primario); line-height: 1;
  margin-bottom: 0.5rem;
}
.metrica-card .etiqueta {
  display: block;
  font-size: 0.78rem; color: #888;
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
}
.metrica-card.alerta { border-top-color: #dc3545; }
.metrica-card.alerta .numero { color: #dc3545; }
.metrica-card.ok     { border-top-color: #28a745; }
.metrica-card.ok .numero  { color: #28a745; }
.metrica-card.warn   { border-top-color: #e8a020; }
.metrica-card.warn .numero { color: #e8a020; }
.tabla-wrapper { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); overflow: hidden; }
.tabla-wrapper .tabla-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid #eee; }
.tabla-wrapper .tabla-header h5 { margin: 0; font-weight: 600; color: var(--color-primario); }
.badge-activa     { background: #d4edda; color: #155724; }
.badge-pausada    { background: #fff3cd; color: #856404; }
.badge-completada { background: #cce5ff; color: #004085; }
.badge-problema   { background: #f8d7da; color: #721c24; }
#mapa { height: 500px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; }

/* ── Hover en tarjetas ──────────────────────────────────── */
.metrica-card { transition: transform 0.15s, box-shadow 0.15s; }
.metrica-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }

/* ── Barra superior movil ────────────────────────────────── */
.barra-movil {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--color-sidebar);
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.barra-movil-marca {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
}
.btn-hamburguesa {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.9);
  font-size: 1.35rem;
  padding: 0.3rem 0.4rem;
  line-height: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.btn-hamburguesa:hover,
.btn-hamburguesa:focus { background: rgba(255,255,255,0.12); outline: none; }

/* Botón X dentro del sidebar header (solo mobile) */
.btn-cerrar-sidebar {
  display: none;
  position: absolute;
  top: 0.9rem; right: 0.75rem;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  font-size: 0.95rem;
  padding: 0.3rem 0.45rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-cerrar-sidebar:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ── Overlay oscuro del sidebar en mobile ───────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 52px; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
}
.sidebar-overlay.activo { display: block; }

/* ── Soporte para modales apilados ──────────────────────── */
.modal-backdrop + .modal-backdrop { z-index: 1059; }
#modal-mant { z-index: 1060; }

/* ── Centrar modales respecto al sidebar ────────────────── */
.modal {
  left: var(--sidebar-ancho);
  width: calc(100% - var(--sidebar-ancho));
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Barra movil visible */
  .barra-movil { display: flex; }

  /* Sidebar: arranca bajo la barra movil, oculto por defecto */
  .sidebar {
    top: 52px;
    height: calc(100vh - 52px);
    transform: translateX(-100%);
    transition: transform 0.26s ease;
    z-index: 250;
  }
  .sidebar.sidebar-abierto { transform: translateX(0); }

  /* Botón cerrar sidebar visible dentro del header */
  .sidebar-header { position: relative; }
  .btn-cerrar-sidebar { display: block; }

  /* Contenido ocupa toda la pantalla y baja bajo la barra */
  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(52px + 1rem);
  }

  /* Topbar de pagina */
  .topbar { margin-bottom: 1rem; gap: 0.5rem; }
  .topbar h1 { font-size: 1.05rem; }

  /* Metricas: 1 columna */
  .metricas { grid-template-columns: 1fr; }

  /* Modales full width */
  .modal { left: 0; width: 100%; }

  /* Mapa mas corto */
  #mapa { height: 280px; }

  /* Tablas con scroll horizontal */
  .table-responsive { overflow-x: auto; }
}

