/*
 * Infinity Security — Shared App Stylesheet
 * iPhone-first, scales to tablet → desktop → wall monitor
 * Future auth integration: add .auth-required class gating here
 */

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:         #07090d;
  --bg2:        #0c1017;
  --panel:      #0f1520;
  --card:       #101722;
  --card2:      #131d2a;
  --glass:      rgba(15,21,32,0.88);

  /* Borders */
  --border:     #1c2535;
  --border2:    #243040;

  /* Accent palette */
  --accent:     #00c8ff;
  --accent2:    #0090cc;
  --green:      #00e676;
  --amber:      #ffab00;
  --red:        #ff4444;
  --purple:     #b388ff;

  /* Text */
  --text:       #d8e4f0;
  --text2:      #a0b4c8;
  --muted:      #5a7080;
  --muted2:     #3a5060;

  /* Effects */
  --shadow:     0 4px 28px rgba(0,0,0,.65);
  --shadow-sm:  0 2px 12px rgba(0,0,0,.45);
  --glow:       0 0 20px rgba(0,200,255,.08);
  --glow-sm:    0 0 10px rgba(0,200,255,.05);

  /* Radii */
  --radius:     14px;
  --radius-sm:  8px;
  --radius-xs:  5px;

  /* Layout */
  --nav-h:      56px;
  --bot-h:      64px;
  --page-max:   1400px;
  --page-pad:   16px;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  min-height: 100%;
  background: var(--bg)
    radial-gradient(ellipse at 20% 0%, rgba(0,100,200,.07) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(0,50,120,.04) 0%, transparent 50%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  /* bottom padding for mobile nav — overridden on desktop */
  padding-bottom: calc(var(--bot-h) + env(safe-area-inset-bottom));
  /* prevent content hiding behind notch on scroll */
  padding-left:  env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
@media (min-width: 768px) {
  body { padding-bottom: 0; font-size: 14px; }
}

/* ── Top Navigation ────────────────────────────────────── */
#topnav {
  position: sticky; top: 0; z-index: 200;
  height: var(--nav-h);
  padding-top: env(safe-area-inset-top);
  background: rgba(7,9,13,.94);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding-left: calc(var(--page-pad) + env(safe-area-inset-left));
  padding-right: calc(var(--page-pad) + env(safe-area-inset-right));
  gap: 10px;
}

.nav-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: .83rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); white-space: nowrap;
  text-decoration: none;
}
.nav-brand svg {
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(0,200,255,.45));
}
.nav-brand-sub {
  font-size: .65rem; font-weight: 500; letter-spacing: .06em;
  color: var(--muted); opacity: .8;
}

/* Desktop horizontal nav links — hidden on mobile */
.nav-links { display: none; gap: 2px; }
@media (min-width: 768px) { .nav-links { display: flex; } }

.nav-link {
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: .74rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); text-decoration: none;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-link.active { color: var(--accent); background: rgba(0,200,255,.07); }

.nav-spacer { flex: 1; }

.nav-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--border);
  font-size: .68rem; color: var(--muted);
  white-space: nowrap;
}
#navclock {
  font-size: .7rem; color: var(--muted);
  min-width: 76px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Status Bar (scrollable) ───────────────────────────── */
#statusbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 6px var(--page-pad);
  display: flex; align-items: center; gap: 18px;
  overflow-x: auto; scrollbar-width: none;
  font-size: .67rem; white-space: nowrap;
}
#statusbar::-webkit-scrollbar { display: none; }

.sb-item { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.sb-item b { color: var(--text); }
.sb-sep { color: var(--muted2); user-select: none; }

/* ── Dot / Indicators ──────────────────────────────────── */
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.dot-sm { width: 5px; height: 5px; }
.dot-green  { background: var(--green); }
.dot-amber  { background: var(--amber); }
.dot-red    { background: var(--red); }
.dot-accent { background: var(--accent); }
.dot-muted  { background: var(--muted2); }

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .15; } }
.blink { animation: blink 1.8s ease-in-out infinite; }

@keyframes pulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.25);opacity:.7} }
.pulse { animation: pulse 2s ease-in-out infinite; }

/* ── Page Content Wrapper ──────────────────────────────── */
.page-content {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad) 24px;
}

/* ── Section Label ─────────────────────────────────────── */
.sec-lbl {
  font-size: .64rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted2);
  margin: 20px 0 10px;
  display: flex; align-items: center; gap: 10px;
}
.sec-lbl::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-glass {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ── Grid layouts ──────────────────────────────────────── */
.grid-auto {
  display: grid; gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 540px)  { .grid-auto { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .grid-auto { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .grid-auto { grid-template-columns: repeat(4, 1fr); } }

.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.grid-3 { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--border);
  font-size: .78rem; font-weight: 600; color: var(--muted);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover, .btn:active { color: var(--accent); border-color: rgba(0,200,255,.35); background: rgba(0,200,255,.05); }
.btn-primary {
  background: rgba(0,200,255,.1); border-color: rgba(0,200,255,.35);
  color: var(--accent);
}
.btn-primary:hover { background: rgba(0,200,255,.18); }
.btn-danger  { color: var(--red);   border-color: rgba(255,68,68,.3); }
.btn-sm  { padding: 5px 12px; font-size: .7rem; }
.btn-lg  { padding: 13px 24px; font-size: .9rem; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; }

/* Touch-friendly minimum tap size */
@media (max-width: 767px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
}

/* ── Chips / Filter Pills ──────────────────────────────── */
.chip-row {
  display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: none;
  padding: 12px var(--page-pad) 4px;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0; padding: 7px 16px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--border);
  font-size: .73rem; font-weight: 600; letter-spacing: .04em;
  color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
  user-select: none; -webkit-tap-highlight-color: transparent;
  min-height: 36px; display: flex; align-items: center;
}
.chip:hover, .chip.active {
  color: var(--accent);
  border-color: rgba(0,200,255,.4);
  background: rgba(0,200,255,.07);
}

/* ── Form Controls ─────────────────────────────────────── */
select, input[type=text], input[type=search] {
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: .8rem; font-family: inherit;
  min-height: 38px;
}
select:focus, input:focus { outline: none; border-color: var(--accent); }

/* ── Badge ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: .6rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  background: rgba(0,0,0,.6);
}
.badge-live     { color: var(--green); }
.badge-awaiting { color: var(--amber); }
.badge-offline  { color: var(--red); }
.badge-info     { color: var(--accent); }
.badge-muted    { color: var(--muted); }

/* ── Status Widgets (stat boxes) ───────────────────────── */
.stat-box {
  background: var(--card2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  text-align: center;
}
.stat-val {
  font-size: 2rem; font-weight: 800;
  color: var(--accent); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-val.green  { color: var(--green); }
.stat-val.amber  { color: var(--amber); }
.stat-val.red    { color: var(--red); }
.stat-val.muted  { color: var(--muted); }
.stat-lbl {
  font-size: .62rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}

/* ── Gauge bar ─────────────────────────────────────────── */
.gauge-row { margin: 6px 0; }
.gauge-header {
  display: flex; justify-content: space-between;
  font-size: .72rem; margin-bottom: 5px;
}
.gauge-header .lbl { color: var(--muted); }
.gauge-header .val { color: var(--text); font-weight: 600; }
.gauge-track {
  height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden;
}
.gauge-fill {
  height: 100%; border-radius: 3px;
  background: var(--accent);
  transition: width .5s ease;
}
.gauge-fill.ok   { background: var(--green); }
.gauge-fill.warn { background: var(--amber); }
.gauge-fill.crit { background: var(--red); }

/* ── Notification / Notice ─────────────────────────────── */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: .76rem; line-height: 1.5;
  margin: 12px 0;
}
.notice-amber {
  background: rgba(255,171,0,.06);
  border: 1px solid rgba(255,171,0,.25);
  color: rgba(255,171,0,.9);
}
.notice-red {
  background: rgba(255,68,68,.06);
  border: 1px solid rgba(255,68,68,.25);
  color: rgba(255,68,68,.9);
}
.notice-green {
  background: rgba(0,230,118,.06);
  border: 1px solid rgba(0,230,118,.25);
  color: rgba(0,230,118,.9);
}
.notice-close {
  margin-left: auto; background: none; border: none;
  color: inherit; opacity: .5; cursor: pointer; font-size: 1.1rem; line-height: 1;
  flex-shrink: 0; padding: 0 4px;
}
.notice-close:hover { opacity: 1; }

/* ── List rows ─────────────────────────────────────────── */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: rgba(255,255,255,.02); }
.list-row-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 1rem;
}
.list-row-body { flex: 1; min-width: 0; }
.list-row-title { font-size: .85rem; font-weight: 600; color: var(--text); }
.list-row-sub { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.list-row-right { flex-shrink: 0; }

/* ── Empty / Loading states ────────────────────────────── */
.empty-state {
  padding: 48px 24px; text-align: center;
  color: var(--muted); font-size: .85rem;
}
.empty-icon { font-size: 3rem; opacity: .2; margin-bottom: 12px; }
.empty-title { color: var(--text2); font-weight: 600; margin-bottom: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 22px; height: 22px;
  border: 2px solid var(--border2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
.loading-row {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 48px; color: var(--muted); font-size: .82rem;
}

/* ── Loading skeleton ──────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--border) 25%, var(--border2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ── Modal / Lightbox overlay ──────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,.97);
  flex-direction: column;
}
.modal-overlay.open { display: flex; }

.modal-hdr {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(12,16,23,.92); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  margin-left: auto;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--muted); padding: 6px 14px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .85rem; min-height: 36px;
}
.modal-close:hover { color: var(--accent); border-color: var(--accent); }

.modal-ftr {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(12,16,23,.92); border-top: 1px solid var(--border);
  font-size: .7rem; color: var(--muted); flex-shrink: 0;
}
.modal-ftr b { color: var(--text); }

/* ── Bottom App Nav (mobile) ────────────────────────────── */
#botnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bot-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(7,9,13,.96);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--border);
  display: grid;
  /* filled by JS / inline with number of buttons */
}
@media (min-width: 768px) { #botnav { display: none; } }

.bot-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; cursor: pointer;
  color: var(--muted2); font-size: .56rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  transition: color .15s; padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.bot-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.bot-btn.active, .bot-btn:hover { color: var(--accent); }
.bot-btn .badge-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--red); position: absolute;
  top: 6px; right: 20%;
}

/* ── Page Footer ────────────────────────────────────────── */
#pagefooter {
  border-top: 1px solid var(--border);
  margin-top: 24px; padding: 12px var(--page-pad);
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: .64rem; color: var(--muted);
}
#pagefooter a { color: rgba(0,200,255,.5); text-decoration: none; }
#pagefooter a:hover { color: var(--accent); }
#footer-ts { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ── Settings section layouts ───────────────────────────── */
.settings-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  margin-bottom: 20px;
}
.settings-section-hdr {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: .7rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 8px;
}
.settings-row {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--border); gap: 12px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-body { flex: 1; }
.settings-row-lbl { font-size: .85rem; font-weight: 600; color: var(--text); }
.settings-row-sub { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.settings-row-val { font-size: .8rem; color: var(--muted); flex-shrink: 0; }

/* ── Alert item ─────────────────────────────────────────── */
.alert-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.alert-item:last-child { border-bottom: none; }
.alert-item:hover { background: rgba(255,255,255,.02); }
.alert-icon {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .9rem; margin-top: 2px;
}
.alert-body { flex: 1; min-width: 0; }
.alert-msg  { font-size: .83rem; color: var(--text); line-height: 1.4; }
.alert-meta { font-size: .68rem; color: var(--muted); margin-top: 3px; }

/* ── Quick action buttons on home ───────────────────────── */
.quick-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 10px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  cursor: pointer; text-decoration: none;
  transition: border-color .2s, background .2s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.quick-btn:hover, .quick-btn:active {
  border-color: var(--accent); background: rgba(0,200,255,.05);
  transform: translateY(-1px);
}
.quick-btn-icon { font-size: 1.6rem; line-height: 1; }
.quick-btn-lbl  { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

/* ── Health status cell ─────────────────────────────────── */
.health-cell {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.health-cell:last-child { border-bottom: none; }
.health-cell-left { display: flex; align-items: center; gap: 10px; flex: 1; }
.health-cell-name { font-size: .84rem; font-weight: 600; }
.health-cell-sub  { font-size: .68rem; color: var(--muted); margin-top: 2px; }
.health-cell-val  { font-size: .8rem; color: var(--muted2); text-align: right; font-family:monospace; }

/* ── Group card ─────────────────────────────────────────── */
.group-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .2s;
}
.group-card:hover { border-color: var(--border2); }
.group-icon {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  background: rgba(0,200,255,.06); border: 1px solid rgba(0,200,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.group-info { flex: 1; }
.group-name { font-size: .9rem; font-weight: 700; }
.group-meta { font-size: .7rem; color: var(--muted); margin-top: 3px; }
.group-count {
  font-size: 1.5rem; font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── Responsive utilities ───────────────────────────────── */
.desktop-only { display: none; }
@media (min-width: 768px) { .desktop-only { display: block; } }
.mobile-only { display: block; }
@media (min-width: 768px) { .mobile-only { display: none; } }

/* ── Scrollbar styling (webkit) ─────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
