/* ============================================================
   PERAVIX NEXUS INTEGRATION STYLES
   ============================================================ */

:root {
    --primary:      #6366f1;
    --primary-dk:   #4f46e5;
    --secondary:    #8b5cf6;
    --accent:       #0ea5e9;
    --success:      #10b981;
    --warning:      #f59e0b;
    --danger:       #ef4444;

    --bg-dark:      #020617;
    --bg-surface:   #0f172a;
    --bg-surface2:  #1e293b;
    --bg-light:     #f8fafc;
    --bg-alt:       #f1f5f9;
    --bg-white:     #ffffff;

    --text-main:    #0f172a;
    --text-muted:   #475569;
    --text-light:   #94a3b8;
    --text-white:   #f8fafc;

    --border:       rgba(15,23,42,0.08);
    --border-md:    rgba(15,23,42,0.12);
    --border-dark:  rgba(255,255,255,0.1);

    --r-sm:   6px;
    --r-md:   10px;
    --r-lg:   16px;
    --r-xl:   24px;
    --r-2xl:  32px;
    --r-pill: 100px;

    /* Status Page Specific (legacy bridge) */
    --color-bg:         var(--bg-light);
    --color-surface:    var(--bg-white);
    --color-surface-2:  var(--bg-alt);
    --color-border:     var(--border-md);
    --color-text:       var(--text-main);
    --color-text-muted: var(--text-muted);
    --color-brand:      var(--primary);
    --color-brand-dark: var(--primary-dk);

    --color-up:         var(--success);
    --color-up-bg:      rgba(16,185,129,0.12);
    --color-down:       var(--danger);
    --color-down-bg:    rgba(239,68,68,0.12);
    --color-degraded:   var(--warning);
    --color-degraded-bg:rgba(245,158,11,0.12);
    --color-unknown:    var(--text-light);
    --color-unknown-bg: rgba(100,116,139,0.12);
    --color-maintenance:var(--secondary);
    --color-maintenance-bg: rgba(139,92,246,0.12);

    --radius:    var(--r-md);
    --radius-lg: var(--r-xl);
    --shadow:    0 1px 3px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.08);
    --font:      'Inter', system-ui, -apple-system, sans-serif;
}

body.dark-mode {
    --bg-light:     #020617;
    --bg-alt:       #0f172a;
    --bg-white:     #0f172a;
    --text-main:    #f8fafc;
    --text-muted:   #94a3b8;
    --border-md:    rgba(255,255,255,0.1);
    
    --color-bg:         var(--bg-light);
    --color-surface:    #1e293b; /* Lighter surface for cards */
    --color-surface-2:  #334155; /* Even lighter for headers */
    --color-border:     var(--border-md);
    --color-text:       var(--text-main);
    --color-text-muted: var(--text-muted);
}

body.dark-mode .status-banner { background: var(--color-surface); }
body.dark-mode .service-group { background: var(--color-surface); }
body.dark-mode .group-header { background: var(--color-surface-2); }
body.dark-mode .incident-card { background: var(--color-surface); }
body.dark-mode .incident-timeframe { background: var(--color-surface-2); }
body.dark-mode .uptime-bar.no_data { background: #334155; }
body.dark-mode .uptime-labels { color: var(--text-muted); }
body.dark-mode .uptime-pct { color: var(--text-muted); }
body.dark-mode .current-time { background: var(--bg-alt); color: var(--text-muted); }
body.dark-mode .btn-theme:hover { background: rgba(15,23,42,0.05); }

/* Keep Nav text dark and ensure it stays on top */
body.dark-mode .site-topbar { background: var(--bg-dark); }
body.dark-mode .nav-wrapper { background: var(--bg-dark); z-index: 1000; }
body.dark-mode .nav-pill { background: rgba(255,255,255,0.93); border-color: rgba(255,255,255,0.6); z-index: 1001; }
body.dark-mode .nav-link { color: #475569 !important; }
body.dark-mode .nav-link:hover { background: rgba(15,23,42,0.05); color: #0f172a !important; }
body.dark-mode .nav-link i { color: #475569; opacity: 0.55; }
body.dark-mode .btn-px { color: #fff !important; }
body.dark-mode .btn-theme { background: transparent; color: #475569; border-color: rgba(15,23,42,0.1); }

.btn-theme {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-md);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-theme:hover {
    border-color: var(--primary);
    color: var(--text-main);
    background: rgba(15,23,42,0.05);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg-light);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.status-container {
    padding-top: 40px;
}

.d-flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.site-topbar {
    background: var(--bg-dark);
    color: rgba(255,255,255,0.5);
    padding: 8px 0;
    font-size: 0.76rem;
    font-weight: 500;
}
.site-topbar i { margin-right: 8px; color: var(--primary); }
.site-topbar a { color: rgba(255,255,255,0.5); text-decoration: none; transition: color 0.2s; }
.site-topbar a:hover, .site-topbar a.active { color: #fff; }
.site-topbar .sep { opacity: 0.2; margin: 0 10px; }

/* ── NAV WRAPPER ──────────────────────────────────────────── */
.nav-wrapper {
    background: var(--bg-dark);
    padding: 14px 20px 36px;
    position: relative;
    z-index: 500;
}

.nav-pill {
    max-width: 1280px;
    margin: 0 auto;
    height: 62px;
    background: rgba(255,255,255,0.93);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: var(--r-pill);
    display: flex;
    align-items: center;
    padding: 0 10px 0 22px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.07);
    gap: 4px;
}

.nav-pill .nav-brand img { height: 36px; display: block; }

.nav-pill .nav-links {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0 0 0 20px;
    gap: 2px;
}

.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--r-pill);
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.nav-link:hover { background: rgba(15,23,42,0.05); color: var(--text-main); }
.nav-link i { font-size: 0.8rem; opacity: 0.55; }

/* Dropdown */
.nav-item.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 230px;
    background: transparent;
    padding: 10px 0 0;
    display: none;
    z-index: 600;
}
.nav-item.dropdown:hover .dropdown-menu { display: block; }
.dm-inner {
    background: #fff;
    border-radius: var(--r-xl);
    padding: 8px;
    box-shadow: 0 16px 48px rgba(15,23,42,0.14);
    border: 1px solid var(--border);
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    font-size: 0.86rem;
    color: var(--text-muted);
    text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-light); color: var(--primary); }

/* Right actions */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.current-time {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-light);
    padding: 6px 12px;
    border-radius: var(--r-pill);
}

.live-indicator {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-px {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    padding: 8px 18px;
    border-radius: var(--r-pill);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(99,102,241,0.2);
}

.nav-toggler {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background: var(--bg-alt);
    border: 1px solid var(--border);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ── Status Banner ────────────────────────────────────────── */
.status-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: 24px 28px;
  margin: -20px 0 24px;
  position: relative;
  z-index: 600;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.3s;
}

.status-banner.status-operational { border-color: var(--success); }
.status-banner.status-degraded    { border-color: var(--warning); }
.status-banner.status-outage      { border-color: var(--danger); }
.status-banner.status-unknown     { border-color: var(--text-light); }

.status-banner-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-operational .status-banner-icon { background: var(--color-up-bg); color: var(--success); }
.status-degraded    .status-banner-icon { background: var(--color-degraded-bg); color: var(--warning); }
.status-outage      .status-banner-icon { background: var(--color-down-bg); color: var(--danger); }
.status-unknown     .status-banner-icon { background: var(--color-unknown-bg); color: var(--text-light); }

.status-banner-title {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
  color: var(--text-main);
}

.status-banner-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Section Titles ───────────────────────────────────────── */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Incidents ────────────────────────────────────────────── */
.incidents-section {
  margin-bottom: 28px;
}

.incident-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}

.incident-card.severity-critical { border-left: 3px solid var(--danger); }
.incident-card.severity-major    { border-left: 3px solid var(--warning); }
.incident-card.severity-minor    { border-left: 3px solid var(--primary); }

.incident-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.incident-title {
  font-size: 1rem;
  font-weight: 600;
}

.incident-timeframe {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  display: inline-block;
}

.incident-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-investigating { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-identified    { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-monitoring    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-resolved      { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-maintenance-planned { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-maintenance-active  { background: rgba(139,92,246,0.25); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.3); }
.badge-maintenance-completed { background: rgba(100,116,139,0.15); color: #94a3b8; }

.badge-minor         { background: rgba(59,130,246,0.1); color: #93c5fd; }
.badge-major         { background: rgba(245,158,11,0.1); color: #fde68a; }
.badge-critical      { background: rgba(239,68,68,0.1); color: #fca5a5; }

.incident-message {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.incident-updates {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}

.update-item {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.update-time {
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 100px;
}

.update-msg { color: var(--text-main); }

/* ── Service Groups ───────────────────────────────────────── */
.service-group {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.group-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.group-status-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.group-status-badge.up          { background: var(--color-up-bg); color: var(--success); }
.group-status-badge.degraded    { background: var(--color-degraded-bg); color: var(--warning); }
.group-status-badge.down        { background: var(--color-down-bg); color: var(--danger); }
.group-status-badge.maintenance { background: var(--color-maintenance-bg); color: var(--secondary); }
.group-status-badge.unknown     { background: var(--color-unknown-bg); color: var(--text-light); }

/* ── Monitor Row ──────────────────────────────────────────── */
.monitor-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.monitor-row:last-child { border-bottom: none; }
.monitor-row:hover { background: var(--bg-light); }

.monitor-info { min-width: 0; }

.monitor-name {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monitor-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

.status-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.up          { color: var(--success); }
.status-dot.up::before    { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.down        { color: var(--danger); }
.status-dot.down::before  { background: var(--danger); }
.status-dot.degraded    { color: var(--warning); }
.status-dot.degraded::before { background: var(--warning); }
.status-dot.maintenance { color: var(--secondary); }
.status-dot.maintenance::before { background: var(--secondary); }
.status-dot.unknown     { color: var(--text-light); }
.status-dot.unknown::before { background: var(--text-light); }

/* ── Uptime Bars ──────────────────────────────────────────── */
.uptime-bars-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.uptime-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 28px;
}

.uptime-bar {
  flex: 1;
  min-width: 3px;
  max-width: 8px;
  height: 100%;
  border-radius: 1px;
  cursor: default;
  transition: opacity 0.15s;
  position: relative;
}

.uptime-bar:hover { opacity: 0.8; }

.uptime-bar.up          { background: var(--success); opacity: 0.8; }
.uptime-bar.degraded    { background: var(--warning); opacity: 0.8; }
.uptime-bar.down        { background: var(--danger); opacity: 0.8; }
.uptime-bar.maintenance { background: var(--secondary); opacity: 0.8; }
.uptime-bar.no_data     { background: var(--border); opacity: 0.6; }

.uptime-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.uptime-pct {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

/* ── History Section ──────────────────────────────────────── */
.history-section {
  margin: 28px 0;
}

.history-incident {
  border-left: 2px solid var(--border);
  padding-left: 16px;
  margin-bottom: 24px;
  position: relative;
}

.history-incident::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  position: absolute;
  left: -5px;
  top: 6px;
}

.history-incident.resolved::before { background: var(--success); }

.history-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 48px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-md);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991px) {
    .nav-links { display: none; }
    .nav-toggler { display: flex; }
    .site-topbar { display: none; }
    .nav-pill .nav-links.show-mobile { display: flex !important; flex-direction: column; position: absolute; top: 100%; left: 20px; right: 20px; background: #fff; border-radius: var(--r-xl); padding: 16px; box-shadow: var(--shadow-lg); z-index: 1000; }
    .nav-pill .nav-links.show-mobile li { width: 100%; }
    .nav-pill .nav-links.show-mobile .nav-link { width: 100%; color: var(--text-main); }
}

@media (max-width: 600px) {
  .status-banner { flex-direction: column; text-align: center; padding: 20px; }
  .monitor-row { grid-template-columns: 1fr; }
  .monitor-right { align-items: flex-start; flex-direction: row; justify-content: space-between; }
  .uptime-bars { height: 20px; }
  .current-time { display: none; }
}
