/* IntelAgro Monitor — extension de layout sobre design-system/{tokens,components}.css.
   Solo agrega lo que el DS compartido no cubre (pagina de un solo nivel, sin sidebar). */

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg-soft);
  color: var(--color-text);
}

/* .btn fija display:inline-flex en design-system/components.css, lo que pisa
   el atributo nativo [hidden] (misma especificidad, la regla de autor gana
   sobre la hoja UA) -- sin esto, #refreshBtn se queda visible al cambiar de
   seccion aunque su .hidden este en true. */
.btn[hidden] {
  display: none;
}

.topbar__subtitle {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-soft);
}

.monitor-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-6);
}

/* Tarjeta de cliente — variante clicable de .card con franja de estado */
.client-card {
  cursor: pointer;
  border-left: 4px solid var(--color-border);
}

.client-card--ok {
  border-left-color: var(--color-success);
}

.client-card--alert {
  border-left-color: var(--color-error);
}

.client-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.client-card__modules {
  margin-top: var(--space-4);
}

.client-card__modules[hidden] {
  display: none;
}

.monitor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  cursor: pointer;
}

.monitor-row:hover .accordion-card__title {
  color: var(--color-accent);
}

/* Lista de usuarios (capturista) dentro del modal -- .table-modal__body no trae
   padding propio (lo necesita para su tabla cruda de datos), asi que esta lista
   se queda pegada a la orilla si no se le da su propio respiro horizontal. */
.usuarios-list {
  padding: var(--space-2) var(--space-6);
}

.usuarios-list__row {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-soft);
}

.usuarios-list__row:last-child {
  border-bottom: none;
}

/* ── Login gate ── */

.login-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg-soft);
}

.login-gate__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-8) var(--space-6);
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  width: 100%;
}

.login-gate__logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.login-gate__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-heading);
  margin: 0;
}

.login-gate__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.login-gate__input {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s;
}

.login-gate__input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-alpha-10);
}

.login-gate__btn {
  padding: var(--space-3);
  background: var(--color-accent);
  color: var(--color-on-accent);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s;
}

.login-gate__btn:hover {
  background: var(--color-accent-hover);
}

.login-gate__btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-gate__error {
  color: var(--color-error);
  font-size: var(--text-xs);
  text-align: center;
  margin: 0;
}

/* ── Sidebar footer + toggle movil (patron de dashboards/css/dashboard.css) ── */

.sidebar__footer {
  padding: var(--space-4) var(--space-5);
  margin-top: auto;
}

.sidebar__version {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.sidebar-toggle {
  display: none;
}

@media (max-width: 1024px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .sidebar-toggle {
    display: inline-flex;
  }
}

/* ── Vista AdaFace: header, modal, formularios (portado de dashboards/css/dashboard.css
   -- monitor.intelagro.mx no incluye ese archivo, asi que se replica solo lo que se usa) ── */

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.view-header__title {
  font-size: var(--text-lg, 1.125rem);
  font-weight: 600;
  color: var(--color-heading);
  margin: 0;
}

.table-scroll {
  overflow-x: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  width: 100%;
  max-width: 420px;
  padding: 0;
  overflow: hidden;
  /* Si el contenido crece (p. ej. resultado de "Probar conexion") el cuerpo se desplaza y
     el encabezado y los botones quedan siempre visibles. */
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}
.modal__title {
  margin: 0;
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  color: var(--color-heading);
}
.modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text-muted, #94a3b8);
  cursor: pointer;
  padding: 0 .25rem;
}
.modal__close:hover { color: var(--color-heading); }
.modal__body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  min-height: 0;
}

/* Resultado de "Probar conexion": nombres largos de tablas no deben salirse del cuadro */
.ds-test { overflow-wrap: anywhere; }
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border, #e2e8f0);
}

.form-label {
  display: block;
  font-size: var(--text-sm, .875rem);
  font-weight: 500;
  color: var(--color-heading);
  margin-bottom: .25rem;
}
.form-input {
  width: 100%;
  padding: .5rem .75rem;
  font-size: var(--text-sm, .875rem);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text);
  box-sizing: border-box;
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-hint {
  font-size: var(--text-xs, .75rem);
  color: var(--color-text-muted, #94a3b8);
  margin: .25rem 0 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted, #94a3b8); }
.badge--active { background: #d1fae5; color: #065f46; }
.badge--inactive { background: #fee2e2; color: #991b1b; }

/* Botones de estado/editar en las tablas de Usuarios y Dispositivos de
   AdaFace -- no hay variante amarilla/azul en design-system/components.css
   (solo primary/secondary/ghost, todos verdes), asi que se definen aqui,
   locales a esta pagina. */
.btn--warn { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.btn--warn:hover { background: #d97706; border-color: #d97706; }
.btn--ok { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn--ok:hover { background: #15803d; border-color: #15803d; }
.btn--info { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn--info:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* Spinner del boton #refreshBtn mientras carga -- .btn.is-loading del design
   system solo baja opacidad, no dibuja nada; este ::before agrega el circulo. */
#refreshBtn.is-loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: var(--space-2, .5rem);
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: -2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
