/* ==========================================================================
   activacion — design tokens y estilos del dashboard
   ========================================================================== */

:root {
  --app-bg: #f1f5f9;
  --app-surface: #ffffff;
  --app-border: #e2e8f0;
  --app-text: #1e293b;
  --app-text-muted: #64748b;

  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #334155;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;

  --danger: #dc2626;
  --success: #16a34a;

  --radius: 0.6rem;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
}

body {
  background-color: var(--app-bg);
  color: var(--app-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Layout con sidebar fijo ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 250px;
  flex-shrink: 0;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 1030;
}

.app-sidebar .brand {
  padding: 1.25rem 1.25rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  letter-spacing: 0.02em;
}

.app-sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 0.65rem 1.25rem;
  border-radius: 0;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-sidebar .nav-link:hover {
  background-color: var(--sidebar-hover);
  color: #fff;
}

.app-sidebar .nav-link.active {
  background-color: var(--accent);
  color: #fff;
}

.app-sidebar .nav-section-title {
  padding: 1rem 1.25rem 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.app-sidebar .sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

.app-main {
  margin-left: 250px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Usuarios sin menú lateral: el contenido ocupa todo el ancho. */
.app-main-completo {
  margin-left: 0;
}

.app-topbar {
  background-color: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-content {
  padding: 1.5rem;
  flex: 1;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease-in-out;
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
}

/* ---------- Componentes reutilizables ---------- */

.card {
  border: 1px solid var(--app-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background-color: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  font-weight: 600;
}

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-outline-primary:hover {
  background-color: var(--accent);
  border-color: var(--accent);
}

.table thead th {
  background-color: var(--app-bg);
  color: var(--app-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom-width: 1px;
}

/* Renglón de filtros dentro del thead (historial de activaciones). */
.historial-filtros td {
  background-color: var(--app-surface);
  border-bottom: 2px solid var(--app-border);
  padding: 0.5rem 0.5rem 0.65rem;
  vertical-align: top;
}

.historial-filtros .form-select,
.historial-filtros .form-control {
  min-width: 9rem;
}

/* ---------- Login (sin sidebar) ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--sidebar-bg) 0%, #0f172a 100%);
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background-color: var(--app-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}

.auth-card .brand {
  text-align: center;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 1.5rem;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

/* ---------- Botón scroll-to-top (reemplaza el de jQuery) ---------- */

#IrArriba {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: none;
  z-index: 1040;
}

#IrArriba a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-md);
  text-decoration: none;
  font-size: 1.2rem;
}

#IrArriba a:hover {
  background-color: var(--accent-hover);
}

/* ---------- Pantalla de llave generada (llave_v) ---------- */

.llave-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.result-card {
  width: 100%;
  max-width: 560px;
  padding: 1.75rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  background-color: var(--app-surface);
  border: 1px solid var(--app-border);
}

.llave-encabezado {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.llave-icono {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.llave-icono-ok    { background-color: var(--success); }
.llave-icono-error { background-color: var(--danger); }

.llave-titulo {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.15rem;
}

.llave-subtitulo {
  font-size: 0.85rem;
  color: var(--app-text-muted);
}

/* ---------- La llave ---------- */

.llave-bloque {
  background-color: var(--accent-soft);
  border: 1px solid #dcd9fb;
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.llave-etiqueta {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-text-muted);
  margin-bottom: 0.4rem;
}

.llave-valor {
  font-family: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.04em;
  color: var(--app-text);
  overflow-wrap: anywhere;
  cursor: text;
  user-select: all;
}

.llave-valor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

.llave-aviso {
  font-size: 0.82rem;
  min-height: 1.2em;
}

/* ---------- Datos del equipo ---------- */

.llave-datos {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.5rem 1rem;
  margin: 0 0 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
  font-size: 0.9rem;
}

.llave-datos dt {
  color: var(--app-text-muted);
  font-weight: 400;
}

.llave-datos dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.llave-mono {
  font-family: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 0.85rem;
}

@media (max-width: 575.98px) {
  .llave-datos {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  .llave-datos dd {
    margin-bottom: 0.5rem;
  }
  .llave-valor {
    font-size: 1.1rem;
  }
}

/* En papel sobra el fondo y el recuadro: solo interesan los datos. */
@media print {
  body {
    background-color: #fff;
  }
  .llave-shell {
    min-height: 0;
    padding: 0;
    display: block;
  }
  .result-card {
    max-width: none;
    box-shadow: none;
    border: 0;
    padding: 0;
  }
  .llave-bloque {
    background-color: transparent;
    border: 1px dashed #94a3b8;
  }
}
