/* Admin Monitoring - stylesheet
   Hand-written utility + component CSS (no build step required).
   Visual language: dark blue background, gold accents, rounded cards,
   left sidebar - matching the reference admin panel's design tokens. */

:root {
  --bg-sidebar: #0b1220;
  --bg-card: #141c30;
  --bg-card-alt: #101828;
  --border-card: rgba(255, 255, 255, 0.08);
  --accent-gold: #f0c454;
  --accent-gold-dim: rgba(240, 196, 84, 0.12);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #facc15;
  --blue: #60a5fa;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #0f1728, #16203a 55%, #1c2a4a);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

/* Layout ------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-card);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.main-content { flex: 1; padding: 28px 32px; overflow-x: hidden; min-width: 0; }
.brand { padding: 0 8px; margin-bottom: 24px; }
.brand-name { font-size: 1.15rem; font-weight: 700; color: var(--accent-gold); }
.brand-sub { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }

.nav-section-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); padding: 14px 12px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 8px;
  border-left: 3px solid transparent;
  color: #cbd5e1;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,0.05); }
.nav-link.active { border-left-color: var(--accent-gold); background: var(--accent-gold-dim); color: var(--accent-gold); font-weight: 600; }
.sidebar-spacer { flex: 1; }
.sidebar-user { padding: 8px 12px; font-size: 0.75rem; color: var(--text-faint); border-top: 1px solid var(--border-card); margin-top: 8px; }
.sidebar-user .uname { color: #cbd5e1; font-weight: 600; }
.logout-btn { background: none; border: none; color: var(--red); font-size: 0.85rem; padding: 8px 12px; text-align: left; width: 100%; }
.logout-btn:hover { text-decoration: underline; }

.mobile-topbar { display: none; }
.sidebar-toggle { background: none; border: 1px solid var(--border-card); color: var(--text-main); border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; }

@media (max-width: 860px) {
  .app-shell { display: block; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-sidebar); padding: 12px 16px; position: sticky; top: 0; z-index: 30;
    border-bottom: 1px solid var(--border-card);
  }
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; z-index: 40;
    transform: translateX(-100%); transition: transform 0.2s ease; width: 260px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,0.4); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 35; }
  .sidebar-backdrop.open { display: block; }
  .main-content { padding: 18px; }
}

/* Cards & components --------------------------------------------------- */
.card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 16px; }
.card-pad { padding: 20px; }
.card-list > * { border-bottom: 1px solid rgba(255,255,255,0.05); }
.card-list > *:last-child { border-bottom: none; }
.card-list-item { padding: 14px 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 520px) { .stat-grid { grid-template-columns: 1fr; } }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 16px; padding: 18px; }
.stat-value { font-size: 1.7rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.input-dark {
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-main);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
  width: 100%;
  font-family: inherit;
}
.input-dark::placeholder { color: var(--text-faint); }
.input-dark:focus { outline: none; border-color: var(--accent-gold); }
select.input-dark { appearance: auto; }
label.field-label { font-size: 0.85rem; font-weight: 500; color: #cbd5e1; display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.help-text { font-size: 0.75rem; color: var(--text-faint); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: #cbd5e1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 8px; padding: 9px 16px; font-size: 0.88rem; font-weight: 600; cursor: pointer; }
.btn-gold { background: var(--accent-gold); color: #241a05; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-ghost { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-danger { background: rgba(239,68,68,0.15); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link-btn { background: none; border: none; padding: 0; color: var(--accent-gold); text-decoration: underline; font-size: inherit; cursor: pointer; }
.link-danger { color: var(--red); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-up { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-down { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-review { background: rgba(250,204,21,0.15); color: var(--yellow); }
.badge-unchecked { background: rgba(96,165,250,0.15); color: var(--blue); }
.badge-disabled { background: rgba(148,163,184,0.15); color: #94a3b8; }
.badge-role-admin { background: var(--accent-gold-dim); color: var(--accent-gold); }
.badge-role-operator { background: rgba(96,165,250,0.15); color: var(--blue); }
.badge-connected { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-pending { background: rgba(250,204,21,0.15); color: var(--yellow); }
.badge-problem { background: rgba(239,68,68,0.15); color: var(--red); }

.alert { border-radius: 12px; padding: 12px 16px; font-size: 0.85rem; }
.alert-error { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.alert-warn { background: rgba(250,204,21,0.1); color: #fde047; border: 1px solid rgba(234,179,8,0.2); }
.alert-success { background: rgba(34,197,94,0.1); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.alert-info { background: rgba(96,165,250,0.1); color: var(--blue); border: 1px solid rgba(96,165,250,0.2); }

table.data-table { font-size: 0.85rem; }
table.data-table th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border-card); white-space: nowrap; }
table.data-table td { padding: 10px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: top; }
table.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table-scroll { overflow-x: auto; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.p-0 { padding: 0; }
.text-xs { font-size: 0.72rem; }
.text-sm { font-size: 0.85rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.4rem; }
.text-2xl { font-size: 1.7rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-gold { color: var(--accent-gold); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.max-w-md { max-width: 480px; }
.max-w-lg { max-width: 620px; }
.max-w-xl { max-width: 760px; }
.w-full { width: 100%; }
.divider { border-top: 1px solid var(--border-card); margin: 16px 0; }
.pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-tab { padding: 6px 14px; border-radius: 999px; font-size: 0.8rem; background: rgba(255,255,255,0.05); color: #cbd5e1; }
.pill-tab.active { background: var(--accent-gold-dim); color: var(--accent-gold); font-weight: 600; }
.empty-state { padding: 32px; text-align: center; color: var(--text-faint); font-size: 0.9rem; }
.qr-box { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal-box { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 16px; padding: 22px; max-width: 480px; width: 100%; max-height: 85vh; overflow-y: auto; }
[hidden] { display: none !important; }
