/* ==========================================================================
   BCH ECOSYSTEM RADAR — STYLES
   Architecture: CSS custom properties drive the entire palette + spacing
   scale, so re-theming is a one-block edit. Layout is CSS Grid/Flexbox only
   (no framework). Motion is centralized in the "ANIMATIONS" block at the
   bottom so timing stays consistent across the app.
   ========================================================================== */

:root{
  /* --- BCH palette --- */
  --primary: #0AC18E;
  --secondary: #00E6A8;
  --bg: #0B1117;
  --card: #141C24;
  --card-border: rgba(10, 193, 142, 0.14);

  /* status colors */
  --online: #0AC18E;
  --slow: #F2B84B;
  --offline: #F0495A;
  --unknown: #6B7A8C;

  /* text */
  --text-primary: #EAF2EF;
  --text-secondary: #93A4AF;
  --text-dim: #5C6B77;

  /* type */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* spacing / radius */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --gap: 20px;

  --shadow-soft: 0 8px 30px rgba(0,0,0,0.35);
  --shadow-glow: 0 0 24px rgba(10,193,142,0.18);
}

*{ box-sizing: border-box; }

html{ scroll-behavior: smooth; }

body{
  margin: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(10,193,142,0.10), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(0,230,168,0.06), transparent),
    var(--bg);
  color: var(--text-primary);
  font-family: var(--font-display);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Subtle scanline / grid overlay for "NOC" feel — purely decorative, no interaction */
.scanline-overlay{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black, transparent 75%);
}

.app-shell{
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 28px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Reusable glass surface */
.glass{
  background: rgba(20, 28, 36, 0.72);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
}

/* ============ HEADER ============ */
.header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px;
}

.logo{ display: flex; align-items: center; gap: 14px; }
.logo-mark{ display:flex; filter: drop-shadow(0 0 10px rgba(10,193,142,0.45)); animation: pulseGlow 3.5s ease-in-out infinite; }
.logo-text h1{
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-sub{ font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.03em; }

.header-right{ display: flex; gap: 26px; }
.time-block{ display: flex; flex-direction: column; align-items: flex-end; }
.time-label{ font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.time-value{ font-family: var(--font-mono); font-size: 0.95rem; color: var(--text-primary); font-weight: 600; }

/* ============ STATS BAR ============ */
.stats-bar{
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
}
.stat-card{
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.stat-value{ font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; color: var(--text-primary); }
.stat-label{ font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-online .stat-value{ color: var(--online); }
.stat-degraded .stat-value{ color: var(--slow); }
.stat-offline .stat-value{ color: var(--offline); }
.stat-unknown .stat-value{ color: var(--unknown); }

/* ============ CONTROLS ============ */
.controls{
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  flex-wrap: wrap;
}
.search-wrap{
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  flex: 1 1 220px;
  min-width: 180px;
  color: var(--text-dim);
  transition: border-color 0.2s ease;
}
.search-wrap:focus-within{ border-color: var(--primary); }
.search-wrap input{
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 0.88rem;
  width: 100%;
}
.search-wrap input::placeholder{ color: var(--text-dim); }

.filter-group{ display: flex; gap: 10px; flex-wrap: wrap; }
select{
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}
select:hover, select:focus{ border-color: var(--primary); color: var(--text-primary); }

.action-group{ display: flex; gap: 10px; margin-left: auto; }

.btn{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}
.btn:active{ transform: scale(0.97); }
.btn-primary{
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #04120D;
  box-shadow: 0 4px 18px rgba(10,193,142,0.28);
}
.btn-primary:hover{ box-shadow: 0 6px 22px rgba(10,193,142,0.42); }
.btn-ghost{
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-ghost:hover{ color: var(--text-primary); border-color: var(--primary); }
.refresh-icon{ display: inline-block; }
.btn-primary:active .refresh-icon{ animation: spin 0.5s linear; }

/* ============ CATEGORY SECTIONS ============ */
.categories-root{ display: flex; flex-direction: column; gap: 30px; }

.category-section{ display: flex; flex-direction: column; gap: 14px; }
.category-header{ display: flex; align-items: center; gap: 12px; }
.category-icon{ font-size: 1.1rem; }
.category-header h2{ font-size: 1.05rem; margin: 0; font-weight: 600; }
.category-count{
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  padding: 2px 9px;
  border-radius: 20px;
}
.category-divider{ flex: 1; height: 1px; background: linear-gradient(90deg, rgba(10,193,142,0.25), transparent); }

.services-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ============ SERVICE CARD ============ */
.service-card{
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}
.service-card:hover{
  transform: translateY(-3px);
  border-color: rgba(10,193,142,0.4);
  box-shadow: var(--shadow-glow);
}
.service-card-top{ display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.service-name-wrap{ display: flex; align-items: center; gap: 9px; min-width: 0; }
.service-name{ font-weight: 600; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status-dot{
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.4s ease, box-shadow 0.4s ease;
}
.status-dot.online{ background: var(--online); box-shadow: 0 0 10px rgba(10,193,142,0.8); animation: dotPulse 2.2s ease-in-out infinite; }
.status-dot.slow{ background: var(--slow); box-shadow: 0 0 10px rgba(242,184,75,0.8); animation: dotPulse 1.4s ease-in-out infinite; }
.status-dot.offline{ background: var(--offline); box-shadow: 0 0 10px rgba(240,73,90,0.8); }
.status-dot.unknown{ background: var(--unknown); }

.status-pill{
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 700;
}
.status-pill.online{ color: var(--online); background: rgba(10,193,142,0.12); }
.status-pill.slow{ color: var(--slow); background: rgba(242,184,75,0.12); }
.status-pill.offline{ color: var(--offline); background: rgba(240,73,90,0.12); }
.status-pill.unknown{ color: var(--unknown); background: rgba(107,122,140,0.12); }

.service-desc{ font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; min-height: 34px; }

.service-meta{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.service-meta b{ color: var(--text-secondary); font-weight: 600; }

.service-footer{ display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.uptime-badge{ font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-secondary); }
.visit-link{
  font-size: 0.72rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(10,193,142,0.08);
  transition: background 0.2s ease;
}
.visit-link:hover{ background: rgba(10,193,142,0.18); }

.empty-state{
  text-align: center;
  color: var(--text-dim);
  padding: 50px 20px;
  font-size: 0.9rem;
}

/* ============ CHARTS ============ */
.section-title{ font-size: 1.15rem; margin: 0 0 4px; font-weight: 600; }
.charts-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}
.chart-card{ padding: 18px 20px 10px; }
.chart-card h3{ margin: 0 0 10px; font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; }
.chart-wrap{ position: relative; height: 220px; }

/* ============ FOOTER ============ */
.footer{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 20px 6px 4px;
  color: var(--text-dim);
  font-size: 0.78rem;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.footer-left{ display: flex; flex-direction: column; gap: 2px; }
.footer-left strong{ color: var(--text-secondary); }
.footer-right a{ color: var(--primary); text-decoration: none; font-weight: 600; }
.footer-right a:hover{ text-decoration: underline; }

/* ============ NOTIFICATION BANNER ============ */
.notification-banner{
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, 90vw);
  pointer-events: none;
}
.notif-item{
  pointer-events: auto;
  background: rgba(20,28,36,0.94);
  border: 1px solid rgba(10,193,142,0.3);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.82rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  animation: slideDown 0.35s ease both;
}
.notif-item.offline{ border-left-color: var(--offline); border-color: rgba(240,73,90,0.3); }
.notif-item.slow{ border-left-color: var(--slow); border-color: rgba(242,184,75,0.3); }
.notif-item b{ color: var(--secondary); }
.notif-item.fade-out{ animation: fadeOutUp 0.4s ease both; }

/* ============ MODAL ============ */
.modal-overlay{
  position: fixed; inset: 0;
  background: rgba(5,8,11,0.75);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
}
.modal-overlay.open{ opacity: 1; pointer-events: auto; }
.modal{
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 28px 28px;
  position: relative;
  transform: translateY(14px) scale(0.98);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.modal-overlay.open .modal{ transform: translateY(0) scale(1); opacity: 1; }
.modal-close{
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.06); border: none; color: var(--text-secondary);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 0.85rem;
  transition: background 0.2s ease, color 0.2s ease;
}
.modal-close:hover{ background: rgba(240,73,90,0.2); color: var(--offline); }
.modal-header{ display: flex; align-items: center; gap: 10px; margin-bottom: 6px; padding-right: 30px; }
.modal-header h2{ margin: 0; font-size: 1.25rem; }
.modal-status-dot{ width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.modal-desc{ color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; margin: 4px 0 18px; }
.modal-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.modal-field{ display: flex; flex-direction: column; gap: 3px; }
.field-label{ font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.field-value{ font-family: var(--font-mono); font-size: 0.92rem; color: var(--text-primary); font-weight: 600; }
.modal-uptime-chart{ height: 130px; margin-bottom: 16px; }
.modal-notes{ font-size: 0.78rem; color: var(--text-dim); font-style: italic; margin-bottom: 20px; }

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp{
  from{ opacity: 0; transform: translateY(8px); }
  to{ opacity: 1; transform: translateY(0); }
}
@keyframes dotPulse{
  0%, 100%{ opacity: 1; }
  50%{ opacity: 0.55; }
}
@keyframes pulseGlow{
  0%, 100%{ filter: drop-shadow(0 0 8px rgba(10,193,142,0.35)); }
  50%{ filter: drop-shadow(0 0 16px rgba(10,193,142,0.65)); }
}
@keyframes slideDown{
  from{ opacity: 0; transform: translateY(-14px); }
  to{ opacity: 1; transform: translateY(0); }
}
@keyframes fadeOutUp{
  from{ opacity: 1; transform: translateY(0); }
  to{ opacity: 0; transform: translateY(-10px); }
}
@keyframes spin{
  from{ transform: rotate(0deg); }
  to{ transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1080px){
  .stats-bar{ grid-template-columns: repeat(3, 1fr); }
  .charts-grid{ grid-template-columns: 1fr; }
}
@media (max-width: 720px){
  .app-shell{ padding: 14px 14px 40px; }
  .header{ padding: 14px 16px; }
  .header-right{ gap: 14px; width: 100%; justify-content: space-between; }
  .stats-bar{ grid-template-columns: repeat(2, 1fr); }
  .controls{ flex-direction: column; align-items: stretch; }
  .action-group{ margin-left: 0; }
  .modal-grid{ grid-template-columns: 1fr; }
  .footer{ flex-direction: column; align-items: flex-start; }
}
