/* Admin Performance Dashboard */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.5;
}

.perf-dashboard {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

/* Header */
.perf-header {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  padding: 20px 24px;
  border-radius: 0 0 12px 12px;
  margin: 0 -16px 20px;
}

.perf-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.perf-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.perf-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auto-refresh-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.auto-refresh-toggle input[type='checkbox'] {
  accent-color: #fff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  transition: background 0.15s;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  background: #e2e8f0;
  color: #334155;
}

.btn-sm:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

/* Panel */
.panel {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.panel-disabled {
  opacity: 0.6;
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: #334155;
}

.sub-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 16px 0 10px;
  color: #475569;
}

.muted {
  color: #94a3b8;
  font-size: 0.85rem;
}

/* Status Cards */
.status-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.status-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.status-card-title {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* StatusDot */
.status-dot-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--healthy {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.status-dot--degraded {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.status-dot--error {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.status-dot--disabled {
  background: #94a3b8;
}

.status-dot-label {
  font-size: 0.85rem;
  font-weight: 500;
}

/* GaugeBar */
.gauge-bar {
  margin-bottom: 12px;
}

.gauge-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.gauge-bar-label {
  font-size: 0.8rem;
  color: #64748b;
}

.gauge-bar-value {
  font-size: 0.8rem;
  font-weight: 600;
}

.gauge-bar-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.gauge-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease, background-color 0.3s;
  min-width: 2px;
}

/* StatCard */
.stat-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.stat-card-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.stat-card-label {
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 2px;
}

/* Query Performance */
.query-perf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.query-perf-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-content: start;
}

.query-perf-chart {
  min-height: 200px;
}

/* Redis */
.redis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.redis-mini-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.redis-namespaces {
  overflow-x: auto;
}

/* Mini Table */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.mini-table th,
.mini-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.mini-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
}

/* Memory Cache Cards */
.cache-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.cache-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 14px;
}

.cache-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.cache-card-desc {
  font-size: 0.72rem;
  color: #64748b;
  margin-bottom: 8px;
}

.cache-card-ttl {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 4px;
}

.route-cache-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

/* Connection Pool */
.pool-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

/* Worker */
.worker-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-dialog {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-dialog h3 {
  margin-bottom: 8px;
}

.modal-dialog p {
  font-size: 0.9rem;
  color: #475569;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-actions .btn {
  background: #e2e8f0;
  color: #334155;
}

/* Log Controls */
.log-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.log-controls select,
.log-controls input[type='text'] {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.82rem;
  outline: none;
}

.log-controls input[type='text'] {
  flex: 1;
  min-width: 160px;
}

/* Log Table */
.log-table-wrapper {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.log-table th,
.log-table td {
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

.log-table th {
  background: #f8fafc;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.log-msg {
  white-space: pre-wrap;
  word-break: break-all;
  max-width: 600px;
}

.log-time {
  color: #64748b;
}

.log-level {
  font-weight: 600;
}

.log-error .log-level {
  color: #ef4444;
}

.log-warning .log-level {
  color: #f59e0b;
}

.log-info .log-level {
  color: #3b82f6;
}

.log-debug .log-level {
  color: #94a3b8;
}

/* Log Pagination */
.log-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.82rem;
}

/* Responsive */
@media (max-width: 768px) {
  .status-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .query-perf-grid,
  .redis-grid {
    grid-template-columns: 1fr;
  }

  .pool-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .route-cache-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Trend Charts */
.trend-chart-card {
  margin-top: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
}
.trend-chart-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}
.trend-chart-canvas {
  width: 100%;
  min-height: 200px;
}
.trend-chart-empty {
  color: #94a3b8;
  font-size: 0.85rem;
  text-align: center;
  padding: 32px 0;
}
