/* ────────────────────────────────────────────────────────────
   AGAPER · Supervision Ops — styles.css
   ──────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:       #020617;
  --bg-card:       rgba(15, 23, 42, 0.82);
  --bg-card-hover: rgba(15, 23, 42, 0.95);
  --bg-inner:      rgba(30, 41, 59, 0.55);
  --border:        rgba(148, 163, 184, 0.2);
  --border-hover:  rgba(148, 163, 184, 0.38);
  --text-primary:  #f8fafc;
  --text-secondary:#cbd5e1;
  --text-muted:    #64748b;
  --indigo:        #6366f1;
  --green:         #22c55e;
  --green-text:    #4ade80;
  --yellow:        #eab308;
  --yellow-text:   #facc15;
  --red:           #ef4444;
  --red-text:      #f87171;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(145deg, #020617 0%, #0f172a 50%, #1e1b4b 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(2, 6, 23, 0.75);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  flex-shrink: 0;
  animation: pulse-dot 2.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--green); }
  50%       { opacity: 0.35; box-shadow: 0 0 4px var(--green); }
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* ── KPI Pills ───────────────────────────────────────────── */
.kpi-pill {
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.kpi-online   { background: rgba(34,197,94,0.14);  color: var(--green-text);  border: 1px solid rgba(34,197,94,0.28); }
.kpi-offline  { background: rgba(239,68,68,0.14);  color: var(--red-text);    border: 1px solid rgba(239,68,68,0.28); }
.kpi-checking { background: rgba(234,179,8,0.14);  color: var(--yellow-text); border: 1px solid rgba(234,179,8,0.28); }

/* ── Main layout ─────────────────────────────────────────── */
.main {
  flex: 1;
  padding: 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: rgba(99,102,241,0.8);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: rgba(99,102,241,1); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-inner);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(51,65,85,0.9); color: var(--text-primary); }

.sort-label { font-size: 13px; color: var(--text-muted); }

.sort-select {
  background: rgba(15,23,42,0.8);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.sort-select:focus { outline: none; border-color: rgba(99,102,241,0.55); }

/* ── Cards Grid ──────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
  border-left-width: 3px;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 24px rgba(2,6,23,0.4);
}

.card.status-online   { border-left-color: var(--green); }
.card.status-offline  { border-left-color: var(--red); }
.card.status-checking { border-left-color: var(--yellow); }

/* Card header */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.card-icon { font-size: 20px; flex-shrink: 0; }
.card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  flex-shrink: 0;
}
.status-badge.online   { background: rgba(34,197,94,0.14);  color: var(--green-text);  border: 1px solid rgba(34,197,94,0.28); }
.status-badge.offline  { background: rgba(239,68,68,0.14);  color: var(--red-text);    border: 1px solid rgba(239,68,68,0.28); }
.status-badge.checking { background: rgba(234,179,8,0.14);  color: var(--yellow-text); border: 1px solid rgba(234,179,8,0.28); }

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-badge.online   .status-dot { background: var(--green); }
.status-badge.offline  .status-dot { background: var(--red); }
.status-badge.checking .status-dot { background: var(--yellow); animation: pulse-dot 1s ease-in-out infinite; }

/* Card note */
.card-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

/* KPI blocks */
.card-kpis {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.kpi-block {
  flex: 1;
  background: var(--bg-inner);
  border-radius: 10px;
  padding: 9px 8px;
  text-align: center;
  border: 1px solid rgba(148,163,184,0.1);
}
.kpi-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 5px;
  line-height: 1;
}
.kpi-value {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.kpi-value.good { color: var(--green-text); }
.kpi-value.warn { color: var(--yellow-text); }
.kpi-value.bad  { color: var(--red-text); }

/* Card actions */
.card-actions {
  display: flex;
  gap: 8px;
}
.btn-card {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-open {
  background: rgba(99,102,241,0.7);
  color: #fff;
}
.btn-open:hover { background: rgba(99,102,241,1); color: #fff; }

.btn-fresh {
  background: var(--bg-inner);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-fresh:hover { background: rgba(51,65,85,0.9); color: var(--text-primary); }

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Progress bar (countdown) ────────────────────────────── */
.progress-bar-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(99,102,241,0.12);
  z-index: 200;
}
.progress-bar {
  height: 100%;
  background: rgba(99,102,241,0.7);
  transition: width 1s linear;
}

/* ── Spinner ─────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.7s linear infinite; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  .topbar { flex-direction: column; align-items: flex-start; padding: 10px 16px; }
  .main   { padding: 16px; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .cards-grid { grid-template-columns: 1fr; }
  .footer { flex-direction: column; text-align: center; }
}
