/* =========================================================
   machines.css — Listado de máquinas (rediseño, fuente Sora)
   ========================================================= */

body {
  background: #f4f6fa;
}

.page {
  font-family: var(--base-font);
  color: #0f172a;
  padding: 24px clamp(16px, 4vw, 48px) 40px;
}

/* ===== ENCABEZADO DE PÁGINA ===== */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #e7f0fa;
  color: var(--primary-solid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.page-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: #64748b;
}

.page-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 14px;
  min-width: 260px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--secondary-solid);
  box-shadow: 0 0 0 3px rgba(29, 132, 181, 0.12);
}

.search-box i {
  color: #94a3b8;
  font-size: 13px;
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: #0f172a;
  width: 100%;
}

.search-box input::placeholder {
  color: #94a3b8;
  font-family: inherit;
}

.filter-select {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  color: #0f172a;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.filter-select:hover,
.filter-select:focus {
  border-color: #cbd5e1;
}

.filter-select-sm {
  padding: 5px 8px;
  font-size: 12px;
}

/* ===== TARJETAS DE ESTADÍSTICAS ===== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e7ebf2;
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.stat-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.stat-icon-total   { background: #e7f0fa; color: var(--primary-solid); }
.stat-icon-ok      { background: #ecfdf5; color: #059669; }
.stat-icon-off     { background: #f1f5f9; color: #64748b; }
.stat-icon-error   { background: #fef2f2; color: #dc2626; }
.stat-icon-refresh { background: #eef2ff; color: #4f46e5; }

.stat-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.stat-sub {
  font-size: 11.5px;
  color: #94a3b8;
}

.stat-refresh-main {
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}

.stat-refresh-state {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
}

.stat-refresh-state .fa-circle {
  color: var(--success-color);
  font-size: 7px;
}

/* ===== TOOLBAR (TABS + ORDEN) ===== */

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab:hover {
  border-color: #cbd5e1;
}

.tab-active {
  background: #0f2c47;
  background: var(--active-primary-solid);
  border-color: var(--active-primary-solid);
  color: #fff;
}

.tab-count {
  background: #f1f5f9;
  color: #475569;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
}

.tab-active .tab-count {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.tab-count-ok    { background: #ecfdf5; color: #059669; }
.tab-count-error { background: #fef2f2; color: #dc2626; }

.sort-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}

/* ===== TABLA ===== */

.table-card {
  background: #fff;
  border: 1px solid #e7ebf2;
  border-radius: 14px;
  overflow-x: auto;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
  font-family: inherit;
  min-width: 720px;
}

.table-card thead tr {
  border-bottom: 1px solid #e7ebf2;
}

.table-card th {
  text-align: left;
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  padding: 13px 18px;
  text-transform: none;
  white-space: nowrap;
}

.table-card td {
  padding: 13px 18px;
  font-size: 13.5px;
  color: #0f172a;
  vertical-align: middle;
}

.table-card tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}

.table-card tbody tr:last-child {
  border-bottom: none;
}

.table-card tbody tr:hover {
  background: #f8fafc;
  cursor: pointer;
}

.table-card tbody tr.empty-row:hover {
  background: transparent;
  cursor: default;
}

/* Celda máquina */

.machine-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.machine-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #e7f0fa;
  color: var(--primary-solid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.machine-name {
  font-weight: 600;
  font-size: 13.5px;
}

.machine-ip {
  font-size: 12px;
  color: #94a3b8;
}

.company-link {
  color: var(--secondary-solid);
  text-decoration: none;
  font-weight: 500;
}

.company-link:hover {
  text-decoration: underline;
}

/* Punto de conexión */

.conn-dot {
  font-size: 9px;
}

.conn-ok      { color: var(--success-color); }
.conn-error   { color: var(--danger-color); }
.conn-off     { color: #cbd5e1; }
.conn-unknown { color: #e2e8f0; }

/* Badge de estado */

.status-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 4px 11px;
  border-radius: 999px;
  display: inline-block;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.status-ok    { background: #ecfdf5; color: #059669; }
.status-error { background: #fef2f2; color: #dc2626; }
.status-off   { background: #f1f5f9; color: #64748b; }

.fade-update {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0.4; transform: translateY(2px); }
  to   { opacity: 1;   transform: translateY(0); }
}

/* Botón Ver detalles */

.th-actions,
.td-actions {
  text-align: right;
}

.btn-details {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #dbe2ec;
  border-radius: 10px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-details i {
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.2s ease, color 0.2s ease;
}

.btn-details:hover {
  background: var(--primary-solid);
  border-color: var(--primary-solid);
  color: #fff;
}

.btn-details:hover i {
  color: #fff;
  transform: translateX(2px);
}

/* Estado vacío */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 0;
  color: #94a3b8;
  font-size: 13px;
}

.empty-state i {
  font-size: 26px;
}

.empty-state p {
  margin: 0;
}

/* ===== PIE DE TABLA ===== */

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.pagination-info {
  font-size: 12.5px;
  color: #64748b;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.page-btn:hover:not(:disabled) {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-active {
  background: var(--primary-solid);
  border-color: var(--primary-solid);
  color: #fff;
}

.page-active:hover {
  background: var(--primary-solid) !important;
}

.page-ellipsis {
  color: #94a3b8;
  font-size: 12px;
  padding: 0 2px;
}

.perpage {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #64748b;
}

/* Loader chico dentro de la celda de estado */

.loader-mini {
  width: 12px;
  height: 12px;
  border: 2px solid #e5e7eb;
  border-top: 2px solid var(--primary-solid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ===== */

@media screen and (max-width: 760px) {
  .page {
    padding: 16px 12px 32px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-tools {
    width: 100%;
  }

  .search-box {
    min-width: 0;
    flex: 1 1 100%;
  }

  .filter-select {
    flex: 1;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sort-box {
    justify-content: flex-end;
  }

  .table-footer {
    flex-direction: column;
    align-items: center;
  }
}