/* ============================================
   URBot.net System Status Page
   Dark theme, responsive grid layout
   ============================================ */

:root {
  --status-bg: #0f1117;
  --status-bg-card: #1a1d27;
  --status-bg-card-hover: #22263a;
  --status-border: rgba(255, 255, 255, 0.06);
  --status-text: #e2e8f0;
  --status-text-dim: #94a3b8;
  --status-text-muted: #64748b;
  --status-green: #22c55e;
  --status-yellow: #eab308;
  --status-red: #ef4444;
  --status-blue: #3b82f6;
  --status-font: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
  --status-font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--status-bg);
  font-family: var(--status-font);
  color: var(--status-text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Header ---- */
.status-header {
  text-align: center;
  padding: 2.5rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--status-border);
}

.status-header h1 {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.overall-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.2rem;
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 500;
}

.overall-indicator .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.overall-indicator.operational { background: rgba(34, 197, 94, 0.12); color: var(--status-green); }
.overall-indicator.operational .dot { background: var(--status-green); box-shadow: 0 0 8px var(--status-green); }

.overall-indicator.degraded { background: rgba(234, 179, 8, 0.12); color: var(--status-yellow); }
.overall-indicator.degraded .dot { background: var(--status-yellow); box-shadow: 0 0 8px var(--status-yellow); }

.overall-indicator.down { background: rgba(239, 68, 68, 0.12); color: var(--status-red); }
.overall-indicator.down .dot { background: var(--status-red); box-shadow: 0 0 8px var(--status-red); }

/* ---- Auto-refresh countdown ---- */
.refresh-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem;
  font-size: 0.8rem;
  color: var(--status-text-muted);
}

.refresh-bar .countdown {
  font-family: var(--status-font-mono);
  color: var(--status-text-dim);
}

/* ---- Container ---- */
.status-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ---- Section ---- */
.status-section {
  margin-bottom: 2rem;
}

.status-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--status-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-section h2 .count {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.15rem 0.6rem;
  border-radius: 10px;
  color: var(--status-text-dim);
  font-weight: 400;
}

/* ---- Filter tabs ---- */
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.filter-tab {
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  border: 1px solid var(--status-border);
  background: transparent;
  color: var(--status-text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-tab:hover {
  border-color: var(--status-blue);
  color: var(--status-text);
}

.filter-tab.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--status-blue);
  color: var(--status-blue);
}

/* ---- Services grid ---- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.service-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--status-bg-card);
  border: 1px solid var(--status-border);
  border-radius: 10px;
  transition: background 0.2s;
}

.service-card:hover { background: var(--status-bg-card-hover); }

.service-card .service-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.service-card .service-dot.up { background: var(--status-green); box-shadow: 0 0 6px var(--status-green); }
.service-card .service-dot.down { background: var(--status-red); box-shadow: 0 0 6px var(--status-red); }
.service-card .service-dot.unknown { background: var(--status-text-muted); }

.service-card .service-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.service-card .service-status {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--status-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---- Uptime bar ---- */
.uptime-bar-wrapper {
  background: var(--status-bg-card);
  border: 1px solid var(--status-border);
  border-radius: 10px;
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.uptime-label {
  font-size: 0.85rem;
  color: var(--status-text-dim);
  white-space: nowrap;
}

.uptime-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.uptime-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--status-green);
  transition: width 0.6s ease;
}

.uptime-fill.degraded { background: var(--status-yellow); }
.uptime-fill.down { background: var(--status-red); }

.uptime-value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--status-font-mono);
  color: var(--status-green);
  white-space: nowrap;
}

.uptime-value.degraded { color: var(--status-yellow); }
.uptime-value.down { color: var(--status-red); }

/* ---- Bot grid ---- */
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
}

.bot-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  background: var(--status-bg-card);
  border: 1px solid var(--status-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.bot-card:hover {
  background: var(--status-bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

.bot-card .bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--status-text-dim);
  flex-shrink: 0;
  overflow: hidden;
}

.bot-card .bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.bot-card .bot-info {
  flex: 1;
  min-width: 0;
}

.bot-card .bot-name {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-card .bot-category {
  font-size: 0.65rem;
  color: var(--status-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bot-card .bot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bot-dot.online { background: var(--status-green); box-shadow: 0 0 4px var(--status-green); }
.bot-dot.degraded { background: var(--status-yellow); box-shadow: 0 0 4px var(--status-yellow); }
.bot-dot.offline { background: var(--status-red); box-shadow: 0 0 4px var(--status-red); }

/* ---- Bot detail panel (shown on click) ---- */
.bot-detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.bot-detail-overlay.visible { display: flex; }

.bot-detail-panel {
  background: var(--status-bg-card);
  border: 1px solid var(--status-border);
  border-radius: 14px;
  padding: 2rem;
  min-width: 320px;
  max-width: 420px;
  width: 90%;
}

.bot-detail-panel h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.bot-detail-panel .detail-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
  font-size: 0.85rem;
}

.bot-detail-panel .detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.bot-detail-panel .detail-item {
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}

.bot-detail-panel .detail-label {
  font-size: 0.7rem;
  color: var(--status-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.bot-detail-panel .detail-value {
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--status-font-mono);
}

.bot-detail-close {
  display: block;
  width: 100%;
  margin-top: 1.2rem;
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--status-border);
  border-radius: 8px;
  color: var(--status-text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.bot-detail-close:hover { background: rgba(255, 255, 255, 0.1); }

/* ---- Incidents ---- */
.incident-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.incident-item {
  padding: 0.8rem 1rem;
  background: var(--status-bg-card);
  border: 1px solid var(--status-border);
  border-radius: 8px;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.incident-item .incident-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.incident-item .incident-text {
  font-size: 0.85rem;
  line-height: 1.4;
}

.incident-item .incident-time {
  font-size: 0.7rem;
  color: var(--status-text-muted);
  margin-top: 0.2rem;
}

.no-incidents {
  padding: 1.5rem;
  text-align: center;
  color: var(--status-text-muted);
  font-size: 0.9rem;
  background: var(--status-bg-card);
  border: 1px solid var(--status-border);
  border-radius: 8px;
}

/* ---- Loading ---- */
.status-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
  color: var(--status-text-muted);
}

.status-loading .spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--status-border);
  border-top-color: var(--status-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Footer ---- */
.status-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.75rem;
  color: var(--status-text-muted);
  border-top: 1px solid var(--status-border);
  margin-top: 2rem;
}

.status-footer a {
  color: var(--status-blue);
  text-decoration: none;
}

.status-footer a:hover { text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .status-header h1 { font-size: 1.3rem; }

  .bot-grid {
    grid-template-columns: 1fr 1fr;
  }

  .services-grid {
    grid-template-columns: 1fr;
  }

  .uptime-bar-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .uptime-track { width: 100%; }

  .bot-detail-panel {
    margin: 1rem;
    min-width: auto;
  }
}

@media (max-width: 400px) {
  .bot-grid {
    grid-template-columns: 1fr;
  }
}
