/* ==========================================================================
   Apex Telemetry - Standalone Web Dashboard Stylesheet
   Agentic Era Design DNA: Deep Space, Glassmorphism, Bento Grids, High Chroma
   ========================================================================== */

:root {
  --bg-deep: #030303;
  --bg-surface: #0a0a0c;
  --bg-card: rgba(16, 16, 20, 0.65);
  --bg-card-hover: rgba(24, 24, 30, 0.85);
  --border-glass: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(92, 92, 252, 0.5);
  --primary: #5c5cfc;
  --primary-glow: rgba(92, 92, 252, 0.35);
  --cyan: #00f0ff;
  --cyan-glow: rgba(0, 240, 255, 0.3);
  --emerald: #10b981;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --font-main: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Ambient Space Lighting */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
}

.glow-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(92, 92, 252, 0.12) 0%, transparent 70%);
  top: -150px;
  right: 5%;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.08) 0%, transparent 70%);
  bottom: -100px;
  left: 10%;
}

.space-grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 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: 40px 40px;
  pointer-events: none;
  z-index: 1;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 2;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: rgba(10, 10, 13, 0.85);
  backdrop-filter: blur(35px);
  -webkit-backdrop-filter: blur(35px);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  flex-shrink: 0;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.brand-radar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 16px var(--primary);
  position: relative;
}

.brand-radar::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border: 1px solid var(--primary);
  border-radius: 50%;
  animation: radar-ping 2.4s infinite ease-out;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: block;
}

.brand-accent {
  color: var(--primary);
}

.brand-subtitle {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  display: block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(92, 92, 252, 0.15), rgba(92, 92, 252, 0.03));
  border-color: rgba(92, 92, 252, 0.3);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(92, 92, 252, 0.15);
}

.sidebar-footer {
  padding-top: 20px;
  border-top: 1px solid var(--border-glass);
}

.stream-status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
}

.status-indicator {
  position: relative;
  width: 8px;
  height: 8px;
}

.pulse-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--emerald);
  border-radius: 50%;
}

.pulse-ring {
  position: absolute;
  width: 16px;
  height: 16px;
  top: -4px;
  left: -4px;
  border: 1px solid var(--emerald);
  border-radius: 50%;
  animation: radar-ping 2s infinite ease-out;
}

.status-label {
  font-size: 10px;
  color: var(--text-dim);
  display: block;
}

.status-state {
  font-size: 11px;
  font-weight: 600;
  color: #34d399;
  display: block;
}

/* Main Viewport */
.main-viewport {
  flex: 1;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-headline h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-headline p {
  font-size: 13px;
  color: var(--text-muted);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
}

.action-btn.primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 20px var(--primary-glow);
}

.action-btn.primary:hover {
  background: #6e6eff;
  transform: translateY(-1px);
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  backdrop-filter: blur(15px);
}

.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Bento Grid */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.bento-tile {
  background: var(--bg-card);
  backdrop-filter: blur(35px);
  -webkit-backdrop-filter: blur(35px);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.bento-tile:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.bento-tile.accent-tile {
  border-color: rgba(92, 92, 252, 0.4);
  background: linear-gradient(135deg, rgba(92, 92, 252, 0.15), var(--bg-card));
  box-shadow: 0 10px 30px rgba(92, 92, 252, 0.1);
}

.bento-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.bento-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.bento-metric {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  color: #ffffff;
  font-feature-settings: 'tnum';
  margin-bottom: 4px;
}

.bento-subtext {
  font-size: 11px;
  color: var(--text-dim);
}

/* Content Split Panels */
.content-split {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  flex: 1;
}

.panel {
  background: var(--bg-card);
  backdrop-filter: blur(35px);
  -webkit-backdrop-filter: blur(35px);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-glass);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title h3 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

.badge-realtime {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(0, 240, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

/* Live Feed Panel */
.feed-container {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
}

.feed-event-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 12px 14px;
  transition: all 0.2s ease;
  animation: feed-slide-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.feed-event-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(92, 92, 252, 0.4);
  transform: translateX(2px);
}

.event-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.event-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.event-type-badge.open {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.event-type-badge.click {
  background: rgba(0, 240, 255, 0.15);
  color: var(--cyan);
}

.event-time {
  font-size: 10px;
  color: var(--text-dim);
}

.event-subject {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-geo {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.event-ip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #a78bfa;
}

.empty-feed {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 12px;
}

/* Ledger Panel & Table */
.search-box input {
  background: rgba(15, 15, 18, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
  width: 240px;
  transition: border-color 0.2s ease;
}

.search-box input:focus {
  border-color: var(--primary);
}

.table-wrapper {
  overflow-x: auto;
  flex: 1;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.ledger-table th {
  padding: 14px 18px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-glass);
}

.ledger-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-muted);
}

.ledger-table tbody tr {
  transition: background 0.15s ease;
  cursor: pointer;
}

.ledger-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
}

.badge-status.read {
  background: rgba(0, 240, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

.badge-status.unread {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
}

.table-empty {
  text-align: center;
  padding: 60px 20px !important;
  color: var(--text-dim);
}

/* Slide-Over Drawer */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  z-index: 100;
}

.drawer-overlay.hidden {
  display: none;
}

.telemetry-drawer {
  position: fixed;
  top: 0;
  right: -520px;
  width: 500px;
  height: 100vh;
  background: rgba(10, 10, 13, 0.98);
  border-left: 1px solid var(--border-glass);
  z-index: 101;
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.8);
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.telemetry-drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid var(--border-glass);
}

.drawer-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.drawer-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.drawer-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

@keyframes radar-ping {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes feed-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Security Authentication Modal */
.auth-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 3, 5, 0.92);
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: auth-fade-in 0.3s ease;
}

.auth-modal-overlay.hidden {
  display: none;
}

.auth-modal-card {
  width: 100%;
  max-width: 380px;
  background: rgba(14, 14, 18, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 35px rgba(92, 92, 252, 0.2);
}

.auth-radar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 16px var(--primary);
  margin: 0 auto 16px auto;
  position: relative;
}

.auth-radar::after {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border: 1px solid var(--primary);
  border-radius: 50%;
  animation: radar-ping 2s infinite ease-out;
}

.auth-modal-card h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  color: #fff;
}

.auth-modal-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form input {
  background: rgba(20, 20, 26, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: #fff;
  outline: none;
  text-align: center;
  letter-spacing: 1px;
  transition: border-color 0.2s ease;
}

.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

.auth-error-text {
  font-size: 11px;
  color: #f87171;
  min-height: 16px;
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

@keyframes auth-fade-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
