/* ═══════════════════════════════════════════════════════════════════════════
   Variáveis
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --nm-sidebar-w: 220px;
  --nm-sidebar-bg-top: #080f1c;
  --nm-sidebar-bg-bot: #0c2035;
  --nm-cyan: #00bcd4;
  --nm-cyan-dim: rgba(0, 188, 212, 0.18);
  --nm-border-dark: rgba(255, 255, 255, 0.08);
  --nm-content-bg: #eef3ff;
  --nm-ink: #0f172a;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Reset / base
   ═══════════════════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--nm-ink);
  background: var(--nm-content-bg);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Layout autenticado
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.nm-sidebar {
  width: var(--nm-sidebar-w);
  background: linear-gradient(175deg, var(--nm-sidebar-bg-top) 0%, var(--nm-sidebar-bg-bot) 100%);
  border-right: 1px solid var(--nm-border-dark);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* Desktop: sidebar fica sticky e com altura cheia */
@media (min-width: 992px) {
  .nm-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    /* sobrescreve o offcanvas do Bootstrap no lg+ */
    transform: none !important;
    visibility: visible !important;
  }
}

/* Brand -------------------------------------------------------------------- */
.nm-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
  text-decoration: none;
  border-bottom: 1px solid var(--nm-border-dark);
  flex-shrink: 0;
}
.nm-brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  line-height: 1.2;
  letter-spacing: 0.2px;
}
.nm-brand-sub {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.nm-brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--nm-cyan), #55f6ff);
  box-shadow: 0 0 14px rgba(85, 246, 255, 0.85);
  flex-shrink: 0;
}

/* Grupos de nav ------------------------------------------------------------ */
.nm-nav-group-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.25);
  padding: 14px 18px 5px;
  user-select: none;
}

/* Links -------------------------------------------------------------------- */
.nm-nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 18px;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: color 0.13s, background 0.13s, border-color 0.13s;
  white-space: nowrap;
}
.nm-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border-left-color: rgba(255, 255, 255, 0.2);
}
.nm-nav-link.active {
  color: #fff;
  background: var(--nm-cyan-dim);
  border-left-color: var(--nm-cyan);
}
.nm-nav-link .bi {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  opacity: 0.75;
}
.nm-nav-link.active .bi,
.nm-nav-link:hover .bi {
  opacity: 1;
}

/* Rodapé da sidebar -------------------------------------------------------- */
.nm-sidebar-footer {
  border-top: 1px solid var(--nm-border-dark);
  padding: 14px 16px;
  flex-shrink: 0;
}
.nm-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(0, 188, 212, 0.2);
  border: 1px solid rgba(0, 188, 212, 0.45);
  color: var(--nm-cyan);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nm-logout-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.65);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  text-align: left;
  width: 100%;
}
.nm-logout-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ── Mobile topbar ───────────────────────────────────────────────────────── */
.nm-mobile-header {
  height: 52px;
  background: linear-gradient(90deg, var(--nm-sidebar-bg-top), var(--nm-sidebar-bg-bot));
  border-bottom: 1px solid var(--nm-border-dark);
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* ── Área principal ──────────────────────────────────────────────────────── */
.nm-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 0% 0%, rgba(13, 110, 253, 0.10), transparent 35%),
    radial-gradient(circle at 100% 0%, rgba(0, 188, 212, 0.10), transparent 30%),
    var(--nm-content-bg);
}

.nm-content {
  flex: 1;
  padding: 28px 32px;
}

@media (max-width: 991.98px) {
  .nm-content {
    padding: 20px 16px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Layout de login
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-login-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(13, 110, 253, 0.12), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0, 188, 212, 0.12), transparent 40%),
    #eef3ff;
}
.nm-login-box {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(13, 110, 253, 0.10);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.nm-login-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0b1220 0%, #0f2f42 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Cards de domínio / certificado — borda lateral por status
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-domain-card {
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  border: 1px solid rgba(15, 23, 42, 0.07) !important;
  border-left: 4px solid #dee2e6 !important;
  border-radius: 10px !important;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.nm-domain-card:hover {
  box-shadow: 0 4px 20px rgba(13, 110, 253, 0.10) !important;
  transform: translateY(-1px);
}
.nm-domain-card--success  { border-left-color: #198754 !important; }
.nm-domain-card--warning  { border-left-color: #ffc107 !important; }
.nm-domain-card--danger   { border-left-color: #dc3545 !important; }
.nm-domain-card--secondary{ border-left-color: #adb5bd !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   Stat cards (contadores)
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-stat-card {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 10px;
  transition: box-shadow 0.15s;
}
.nm-stat-card:hover {
  box-shadow: 0 2px 12px rgba(13, 110, 253, 0.08);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Formulários — seções
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-form-section-header {
  background: #f6f8ff;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #64748b;
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  padding: 10px 16px;
}

/* Textareas de regras WAF -------------------------------------------------- */
.nm-rules-textarea {
  font-size: 0.82rem;
  line-height: 1.65;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Opções com switch --------------------------------------------------------- */
.nm-option-row {
  background: #f8faff;
  border-radius: 8px;
  transition: background 0.12s;
}
.nm-option-row:hover {
  background: #eef3ff;
}
.form-check-input[role="switch"] {
  width: 2.5em;
  height: 1.35em;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Stats bar nos cards de domínio
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-stats-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5ff;
  border: 1px solid rgba(13, 110, 253, 0.08);
  border-radius: 7px;
  padding: 6px 10px;
  flex-wrap: wrap;
}
.nm-stats-bar--empty {
  background: #f8f9fb;
  border-color: rgba(15, 23, 42, 0.06);
}
.nm-stats-bar__item {
  display: flex;
  align-items: baseline;
  gap: 3px;
}
.nm-stats-bar__value {
  font-size: .85rem;
  font-weight: 700;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
}
.nm-stats-bar__value--danger { color: #dc3545; }
.nm-stats-bar__value--warn   { color: #d97706; }
.nm-stats-bar__label {
  font-size: .72rem;
  color: #64748b;
}
.nm-stats-bar__pct {
  font-size: .68rem;
  color: #94a3b8;
}
.nm-stats-bar__sep {
  width: 1px;
  height: 14px;
  background: rgba(15, 23, 42, 0.12);
  flex-shrink: 0;
}
.nm-stats-bar__window {
  font-size: .65rem;
  color: #94a3b8;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Health dot — upstream status indicator
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-health-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #adb5bd;
  flex-shrink: 0;
  transition: background 0.3s;
}
.nm-health-dot.up {
  background: #198754;
  box-shadow: 0 0 0 2px rgba(25, 135, 84, 0.2);
}
.nm-health-dot.down {
  background: #dc3545;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
  animation: nm-pulse-red 1.5s ease-in-out infinite;
}
@keyframes nm-pulse-red {
  0%, 100% { box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2); }
  50%       { box-shadow: 0 0 0 5px rgba(220, 53, 69, 0.0); }
}

/* Compact domain card variant (5-per-row grid) ----------------------------- */
.nm-domain-card-compact {
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  border: 1px solid rgba(15, 23, 42, 0.07) !important;
  border-left: 4px solid #dee2e6 !important;
  border-radius: 10px;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px 12px 10px;
}
.nm-domain-card-compact:hover {
  box-shadow: 0 4px 18px rgba(13, 110, 253, 0.10);
  transform: translateY(-1px);
}
.nm-domain-card-compact--success  { border-left-color: #198754 !important; }
.nm-domain-card-compact--warning  { border-left-color: #ffc107 !important; }
.nm-domain-card-compact--danger   { border-left-color: #dc3545 !important; }
.nm-domain-card-compact--secondary{ border-left-color: #adb5bd !important; }

/* Favicon fallback placeholder */
.nm-favicon {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
  background: #eef3ff;
}

/* Compact stats row inside card */
.nm-mini-stats {
  display: flex;
  gap: 0;
  background: #f1f5ff;
  border: 1px solid rgba(13, 110, 253, 0.07);
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0;
}
.nm-mini-stats__cell {
  flex: 1;
  text-align: center;
  padding: 4px 2px;
  border-right: 1px solid rgba(13, 110, 253, 0.07);
}
.nm-mini-stats__cell:last-child { border-right: none; }
.nm-mini-stats__val {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.nm-mini-stats__val--danger { color: #dc3545; }
.nm-mini-stats__lbl {
  display: block;
  font-size: .6rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Clickable stat cell — reset button styles, add hover */
button.nm-mini-stats__cell {
  background: none;
  border: none;
  border-right: 1px solid rgba(13, 110, 253, 0.07);
  cursor: pointer;
  transition: background .15s;
}
button.nm-mini-stats__cell:last-child { border-right: none; }
button.nm-mini-stats__cell:hover {
  background: rgba(13, 110, 253, 0.08);
}
button.nm-mini-stats__cell:hover .nm-mini-stats__lbl {
  color: #0d6efd;
}
/* Delta badge inside mini-stat cell */
.nm-mini-stats__delta {
  display: block;
  font-size: .56rem;
  font-weight: 600;
  line-height: 1;
  margin: 0 auto 1px;
}
.nm-mini-stats__delta--up   { color: #dc3545; }
.nm-mini-stats__delta--down { color: #198754; }

/* ═══════════════════════════════════════════════════════════════════════════
   Live status dot (tempo real card)
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dee2e6;
  flex-shrink: 0;
}
.nm-live-dot.active {
  background: #198754;
  animation: nm-pulse-green 2s ease-in-out infinite;
}
@keyframes nm-pulse-green {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(25,135,84,.4); }
  50%       { opacity: .7; box-shadow: 0 0 0 4px rgba(25,135,84,0); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   KPI grouped cards (dashboard)
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-kpi-card {
  border-left: 3px solid transparent !important;
}
.nm-kpi-card--primary { border-left-color: #0d6efd !important; }
.nm-kpi-card--danger  { border-left-color: #dc3545 !important; }
.nm-kpi-card--warning { border-left-color: #ffc107 !important; }
.nm-kpi-card--muted   { border-left-color: #dee2e6 !important; }

.nm-kpi-title {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #6c757d;
}

.nm-kpi-metric {
  padding: .55rem .5rem .45rem;
}
.nm-kpi-metric--border-r {
  border-right: 1px solid rgba(0,0,0,.06);
}
.nm-kpi-metric--border-t {
  border-top: 1px solid rgba(0,0,0,.06);
}
.nm-kpi-metric--pl {
  padding-left: .75rem;
}

.nm-kpi-val {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.1;
}

.nm-kpi-lbl {
  font-size: .67rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Telegram alert preview
   ═══════════════════════════════════════════════════════════════════════════ */
.nm-tg-preview {
  background: #e5ddd5;
  border-radius: 0;
}
.nm-tg-bubble {
  background: #fff;
  border-radius: 0 12px 12px 12px;
  padding: 10px 14px;
  font-size: .82rem;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  max-width: 95%;
  display: inline-block;
  word-break: break-word;
}
.nm-tg-muted {
  color: #94a3b8;
  font-size: .78rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Log viewer
   ═══════════════════════════════════════════════════════════════════════════ */
.log-box {
  min-height: 420px;
  max-height: 420px;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
  background: #0d1117;
  color: #e6edf3;
  padding: 14px;
  border-radius: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.5;
}
