/* Devi Admin — estilos del panel */
:root {
  --azul: #1e40af;
  --azul-osc: #0f172a;
  --azul-med: #1e293b;
  --acento: #38bdf8;
  --verde: #16a34a;
  --rojo: #dc2626;
  --ambar: #d97706;
  --fondo: #f1f5f9;
  --carta: #ffffff;
  --texto: #0f172a;
  --texto-suave: #64748b;
  --borde: #e2e8f0;
  --radio: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  font-size: 15px;
}
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--azul-osc), var(--azul-med));
  color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.marca-logo { font-size: 26px; }
.marca strong { color: #fff; display: block; font-size: 16px; }
.marca small { color: #94a3b8; font-size: 12px; }
.sidebar nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-seccion {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: #64748b; padding: 14px 12px 5px; font-weight: 700;
}
.sidebar nav a {
  color: #cbd5e1; text-decoration: none; padding: 10px 12px;
  border-radius: 8px; display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.activo { background: var(--azul); color: #fff; font-weight: 600; }
.sidebar-pie { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); display: flex; justify-content: space-between; font-size: 13px; }
.sidebar-pie a { color: var(--acento); text-decoration: none; }

/* ---------- Contenido ---------- */
.contenido { flex: 1; padding: 28px 32px; max-width: 1200px; }
.contenido h1 { font-size: 22px; margin-bottom: 20px; }
h2 { font-size: 16px; margin: 22px 0 10px; color: var(--texto); }

/* ---------- Tarjetas de estadisticas ---------- */
.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tarjeta {
  background: var(--carta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 16px 18px; box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.tarjeta .valor { font-size: 28px; font-weight: 700; }
.tarjeta .etiqueta { color: var(--texto-suave); font-size: 13px; margin-top: 2px; }
.tarjeta .sub { color: var(--texto-suave); font-size: 12px; margin-top: 6px; }
.tarjeta.verde .valor { color: var(--verde); }
.tarjeta.azul .valor { color: var(--azul); }
.tarjeta.ambar .valor { color: var(--ambar); }
.tarjeta.rojo .valor { color: var(--rojo); }

/* ---------- Paneles / tablas ---------- */
.panel {
  background: var(--carta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 18px 20px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.tabla-envoltura { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--texto-suave); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 2px solid var(--borde); }
td { padding: 9px 10px; border-bottom: 1px solid var(--borde); vertical-align: top; }
tr:hover td { background: #f8fafc; }

/* ---------- Chips de estado ---------- */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip-verde { background: #dcfce7; color: #166534; }
.chip-rojo { background: #fee2e2; color: #991b1b; }
.chip-azul { background: #dbeafe; color: #1e40af; }
.chip-ambar { background: #fef3c7; color: #92400e; }
.chip-gris { background: #e2e8f0; color: #334155; }

/* ---------- Formularios ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: var(--texto); }
input[type=text], input[type=password], input[type=email], input[type=file], select, textarea {
  width: 100%; max-width: 520px; padding: 9px 12px; border: 1px solid var(--borde);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acento); border-color: transparent; }
.boton {
  display: inline-block; background: var(--azul); color: #fff; border: none;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; margin-top: 14px;
}
.boton:hover { filter: brightness(1.1); }
.boton-sec { background: #e2e8f0; color: var(--texto); }
.boton-peligro { background: var(--rojo); }
.boton-mini { padding: 4px 10px; font-size: 12px; margin: 0; }

/* ---------- Avisos ---------- */
.aviso { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.aviso-ok { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.aviso-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.aviso-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ---------- Barras (grafico simple) ---------- */
.barra-fila { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.barra-nombre { width: 220px; font-size: 13px; color: var(--texto-suave); flex-shrink: 0; }
.barra-fondo { flex: 1; background: #e2e8f0; border-radius: 6px; height: 22px; overflow: hidden; }
.barra-relleno { background: linear-gradient(90deg, var(--azul), var(--acento)); height: 100%; border-radius: 6px; min-width: 2px; }
.barra-valor { width: 60px; text-align: right; font-weight: 600; font-size: 13px; }

/* ---------- Login ---------- */
.login-fondo {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--azul-osc), var(--azul));
}
.login-caja {
  background: #fff; border-radius: 16px; padding: 36px; width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.login-caja h1 { font-size: 20px; margin-bottom: 4px; }
.login-caja p { color: var(--texto-suave); font-size: 13px; margin-bottom: 10px; }
.login-caja .boton { width: 100%; }

/* ---------- Salida de consola (importador) ---------- */
.consola {
  background: var(--azul-osc); color: #a7f3d0; font-family: Consolas, monospace;
  font-size: 13px; padding: 16px; border-radius: 8px; white-space: pre-wrap;
  overflow-x: auto; margin-top: 14px;
}
.consola.error { color: #fca5a5; }

/* ---------- Insignia de superadministrador ---------- */
.insignia {
  background: var(--ambar); color: #fff; border-radius: 4px;
  padding: 1px 6px; font-size: 9.5px; font-weight: 700;
  letter-spacing: .06em; vertical-align: middle;
}

/* ---------- Globo de alerta (solicitudes pendientes) ---------- */
/* El nombre ocupa el espacio sobrante: asi el globo siempre queda pegado
   al borde derecho y todos los numeros forman una columna recta. */
.nav-texto {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.globo {
  background: var(--rojo); color: #fff; border-radius: 999px;
  min-width: 24px; padding: 2px 7px; font-size: 11px; font-weight: 700;
  text-align: center; flex: 0 0 auto; margin-left: 8px;
  font-variant-numeric: tabular-nums;
}
/* Solo late lo urgente (un socio esperando a que le escriban). Si latieran
   todos a la vez, el menu pareceria un arbol de navidad y dejarias de mirarlos. */
.globo-urgente { animation: latido 1.6s ease-in-out infinite; }
@keyframes latido {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.14); }
}
@media (prefers-reduced-motion: reduce) {
  .globo-urgente { animation: none; }
}

/* ================================================================
   RESPONSIVE — el panel se usa también en celular y tablet
   ================================================================ */

/* Botón hamburguesa: sólo aparece en pantallas chicas */
.abrir-menu {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 60;
  background: var(--azul-osc); color: #fff; border: none;
  width: 44px; height: 44px; border-radius: 10px; font-size: 20px;
  cursor: pointer; box-shadow: 0 2px 10px rgba(15,23,42,.3);
}
.velo { display: none; }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  .contenido { padding: 22px 20px; }
  .tarjetas { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
  .tarjeta .valor { font-size: 24px; }
  .barra-nombre { width: 150px; }
}

/* ---------- Celular ---------- */
@media (max-width: 780px) {
  body { font-size: 16px; } /* evita que iOS haga zoom al enfocar un input */

  .abrir-menu { display: block; }

  /* El menú se desliza desde la izquierda.
     Lo abre y cierra el checkbox oculto #menu-check: sin JavaScript
     y sin dejar un #hash pegado en la URL. */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; width: 260px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 50;
  }
  .menu-check:checked ~ .sidebar { transform: translateX(0); }
  .menu-check:checked ~ .velo {
    display: block; position: fixed; inset: 0;
    background: rgba(15,23,42,.5); z-index: 40;
  }

  .contenido { padding: 66px 14px 24px; max-width: 100%; }
  .contenido h1 { font-size: 19px; }

  /* Tarjetas de dos en dos, que es lo que entra cómodo */
  .tarjetas { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tarjeta { padding: 12px 14px; }
  .tarjeta .valor { font-size: 21px; }
  .tarjeta .etiqueta { font-size: 12px; }
  .tarjeta .sub { font-size: 11px; }

  .panel { padding: 14px; border-radius: 10px; }

  /* Las tablas se desplazan solas en lugar de romper la página */
  .tabla-envoltura {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px; padding: 0 14px;
  }
  table { font-size: 13px; min-width: 560px; }
  th, td { padding: 8px 7px; }

  /* Formularios a todo el ancho y botones cómodos para el dedo */
  input[type=text], input[type=password], input[type=email],
  input[type=file], input[type=date], select, textarea { max-width: 100%; }
  .boton { padding: 11px 16px; }
  .boton-mini { padding: 7px 12px; font-size: 12px; }

  /* Barras: el nombre arriba y la barra debajo */
  .barra-fila { flex-wrap: wrap; gap: 6px; }
  .barra-nombre { width: 100%; font-size: 12px; }
  .barra-fondo { height: 18px; }

  /* Chat de conversaciones: burbujas más anchas */
  .contenido [style*="max-width:70%"] { max-width: 88% !important; }

  .login-caja { width: 100%; max-width: 360px; margin: 16px; padding: 26px; }
}

/* ---------- Celular pequeño ---------- */
@media (max-width: 420px) {
  .tarjetas { grid-template-columns: 1fr 1fr; }
  .contenido { padding: 62px 10px 20px; }
  .tabla-envoltura { margin: 0 -10px; padding: 0 10px; }
  .marca strong { font-size: 15px; }
}

/* ---------- Impresión (para imprimir un reporte) ---------- */
@media print {
  .sidebar, .abrir-menu, .boton, .velo { display: none !important; }
  .app { display: block; }
  .contenido { padding: 0; max-width: 100%; }
  .panel { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  table { font-size: 11px; }
}
