/* UI components - loading, offline, errors, empty states */
/* =============================================
     LOADING SKELETONS
     ============================================= */

.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.skeleton-row:last-child {
  border-bottom: none;
}

.skeleton-block {
  width: 100px;
  height: 16px;
}

.skeleton-block.sm {
  width: 60px;
}
.skeleton-block.md {
  width: 100px;
}
.skeleton-block.lg {
  width: 160px;
}
.skeleton-block.xl {
  width: 220px;
}

.skeleton-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-bar {
  flex: 1;
  height: 12px;
  max-width: 200px;
}

.skeleton-status {
  width: 180px;
  height: 32px;
  border-radius: 8px;
}

.skeleton-pill {
  width: 70px;
  height: 24px;
  border-radius: 12px;
}

.loading-container {
  display: none;
}

.loading-container.visible {
  display: block;
}

.data-container.loading {
  display: none;
}

/* =============================================
     OFFLINE BANNER
     ============================================= */

.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fcd34d;
  border-radius: 12px;
  margin-bottom: 16px;
  color: #92400e;
  font-size: 14px;
  font-weight: 500;
}

.offline-banner.visible {
  display: flex;
}

.offline-banner-icon {
  font-size: 18px;
}

.offline-banner-text {
  flex: 1;
}

.offline-banner-dismiss {
  background: none;
  border: none;
  color: #92400e;
  cursor: pointer;
  padding: 10px 14px;
  font-size: 14px;
  opacity: 0.7;
}

.offline-banner-dismiss:hover {
  opacity: 1;
}

.online-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #16a34a;
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  opacity: 0;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.online-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* =============================================
     API ERROR STATES
     ============================================= */

.api-error {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.api-error.visible {
  display: flex;
}

.api-error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.api-error-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.api-error-message {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 24px;
  max-width: 360px;
  line-height: 1.5;
}

.api-error-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.api-error-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.api-error-btn.primary {
  background: var(--accent);
  color: white;
  border: none;
}

.api-error-btn.primary:hover {
  background: #1d4ed8;
}

.api-error-btn.secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.api-error-btn.secondary:hover {
  background: #f8fafc;
}

/* Inline error for chart/expansion area */
.chart-error {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  background: #fef2f2;
  border-radius: 12px;
  margin: 12px;
}

.chart-error.visible {
  display: flex;
}

.chart-error-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.chart-error-text {
  font-size: 14px;
  color: #991b1b;
  margin: 0 0 16px;
}

.chart-error-retry {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  background: white;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  cursor: pointer;
}

.chart-error-retry:hover {
  background: #fff5f5;
}

/* =============================================
     DEVICE OFFLINE INDICATOR
     ============================================= */

/* Device status indicated via caret/toggle color */
.row-toggle.status-online {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}
.row-toggle.status-online svg {
  color: #16a34a;
}

.row-toggle.status-stale {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  animation: pulse-stale 2s ease-in-out infinite;
}
.row-toggle.status-stale svg {
  color: #d97706;
}

.row-toggle.status-offline {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  animation: pulse-offline 2s ease-in-out infinite;
}
.row-toggle.status-offline svg {
  color: #dc2626;
}

@keyframes pulse-stale {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes pulse-offline {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.device-offline-notice {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 14px;
  color: #92400e;
  margin: 12px 12px 0;
}

.device-offline-notice.visible {
  display: flex;
}

.device-offline-notice.critical {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.device-offline-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* =============================================
     EMPTY STATES
     ============================================= */

.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-state.visible {
  display: flex;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.8;
}

.empty-state-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
}

.empty-state-message {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 28px;
  max-width: 400px;
  line-height: 1.6;
}

.empty-state-btn {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.empty-state-btn:hover {
  background: #1d4ed8;
}

/* No data for selected range */
.no-data-range {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  background: #f8fafc;
  border-radius: 12px;
  margin: 12px;
}

.no-data-range.visible {
  display: flex;
}

.no-data-range-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.no-data-range-text {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

/* =============================================
     REDUCED MOTION
     ============================================= */

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
  .row-toggle.status-stale,
  .row-toggle.status-offline {
    animation: none;
  }
}
