/* ===================================================================
   OpenVexo Dashboard — Dark Theme Stylesheet
   =================================================================== */

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #0f0f23;
  --bg-card: #141428;
  --bg-card-hover: #1a1a35;
  --bg-sidebar: #0c0c1e;
  --border: #1e1e3a;
  --border-light: #2a2a4a;
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #5a5a7a;
  --accent: #00d4ff;
  --accent-glow: #00d4ff40;
  --purple: #7c3aed;
  --purple-glow: #7c3aed40;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --orange: #f97316;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

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

html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===================================================================
   Sidebar
   =================================================================== */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 24px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
.brand-text {
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.brand-text strong { color: var(--accent); font-weight: 700; }

.nav-links {
  list-style: none;
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}
.nav-links li { margin-bottom: 2px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none !important;
}
.nav-link:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.nav-link.active {
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  color: var(--accent);
}
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.version-badge {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ===================================================================
   Mobile header
   =================================================================== */
#mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  z-index: 110;
  font-size: 16px;
}
#mobile-header strong { color: var(--accent); }
#menu-toggle {
  background: none; border: none; color: var(--text-primary);
  cursor: pointer; padding: 4px;
}

/* ===================================================================
   Main content area
   =================================================================== */
#main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 0 32px 48px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 50;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
#page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-sub { font-size: 12.5px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.status-indicator { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.topbar-time { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Pulse dot */
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  position: relative; display: inline-block;
}
.pulse-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.pulse-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
.pulse-dot.degraded { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.pulse-dot.online::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--green);
  animation: pulse-ring 2s ease-out infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Status dot (non-pulsing) */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.degraded { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

/* Pages */
.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===================================================================
   Stats row
   =================================================================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: all var(--transition);
}
.stat-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.stat-info { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ===================================================================
   Section headers
   =================================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  margin-top: 8px;
}
.section-header h2 { font-size: 15px; font-weight: 600; }
.section-sub { font-size: 12px; color: var(--text-muted); }

/* ===================================================================
   Quick actions
   =================================================================== */
.quick-actions { display: flex; gap: 10px; margin-bottom: 28px; flex-wrap: wrap; }
.action-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.action-btn:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.action-btn.accent { border-color: var(--accent); color: var(--accent); }
.action-btn.accent:hover { background: var(--accent); color: var(--bg-primary); }
.action-btn.danger { border-color: var(--red); color: var(--red); }
.action-btn.danger:hover { background: var(--red); color: #fff; }

/* ===================================================================
   Health grid
   =================================================================== */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.health-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: all var(--transition);
}
.health-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}
.health-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.health-emoji { font-size: 20px; }
.health-name { font-weight: 600; font-size: 13.5px; flex: 1; }
.health-desc { font-size: 11px; color: var(--accent); margin: 4px 0 2px; opacity: 0.8; }
.health-detail { font-size: 12px; color: var(--text-muted); }
.health-port { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-top: 4px; }
.health-latency { font-size: 11px; color: var(--text-secondary); }

/* ===================================================================
   Plugins grid
   =================================================================== */
.plugins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.plugin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  cursor: pointer;
}
.plugin-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}
.plugin-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.plugin-emoji { font-size: 24px; }
.plugin-title { flex: 1; }
.plugin-title h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.plugin-title .plugin-port { font-size: 11.5px; color: var(--text-muted); }
.plugin-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.plugin-badge.online { background: #10b98120; color: var(--green); }
.plugin-badge.offline { background: #ef444420; color: var(--red); }
.plugin-badge.degraded { background: #f59e0b20; color: var(--yellow); }
.plugin-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.plugin-endpoints { display: none; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.plugin-card.expanded .plugin-endpoints { display: block; }
.endpoint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.method-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: 'SF Mono', Menlo, monospace;
  letter-spacing: 0.3px;
  min-width: 46px;
  text-align: center;
}
.method-badge.GET { background: #10b98125; color: var(--green); }
.method-badge.POST { background: #3b82f625; color: var(--blue); }
.method-badge.PUT { background: #f9731625; color: var(--orange); }
.method-badge.DELETE { background: #ef444425; color: var(--red); }
.method-badge.PATCH { background: #f59e0b25; color: var(--yellow); }

.plugin-actions {
  margin-top: 12px;
  display: none;
}
.plugin-card.expanded .plugin-actions { display: flex; gap: 8px; }
.plugin-action-btn {
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.plugin-action-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* Filter buttons */
.filter-group { display: flex; gap: 4px; }
.filter-btn {
  padding: 5px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--border-light); color: var(--text-secondary); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: var(--bg-primary); font-weight: 600; }

/* ===================================================================
   Tables
   =================================================================== */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  margin-bottom: 28px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #10b98120; color: var(--green); }
.badge-red { background: #ef444420; color: var(--red); }
.badge-blue { background: #3b82f620; color: var(--blue); }
.badge-yellow { background: #f59e0b20; color: var(--yellow); }
.badge-purple { background: #7c3aed20; color: var(--purple); }

.text-muted { color: var(--text-muted); }

/* ===================================================================
   Kanban
   =================================================================== */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.kanban-col {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 200px;
}
.kanban-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.kanban-dot { width: 8px; height: 8px; border-radius: 50%; }
.kanban-count {
  margin-left: auto;
  background: var(--bg-card);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
  transition: all var(--transition);
}
.kanban-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
}

/* ===================================================================
   Alerts list (Crypto)
   =================================================================== */
.alerts-list { margin-bottom: 28px; }
.alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
  transition: all var(--transition);
}
.alert-item:hover { background: var(--bg-card-hover); }
.alert-icon { font-size: 12px; }
.alert-up .alert-icon { color: var(--green); }
.alert-down .alert-icon { color: var(--red); }
.alert-item .badge { margin-left: auto; }

/* ===================================================================
   Chart placeholder
   =================================================================== */
.chart-placeholder {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 28px;
}
.chart-mock { width: 100%; }
.chart-svg { width: 100%; height: auto; }

/* ===================================================================
   Media grid
   =================================================================== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.media-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}
.media-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}
.media-thumb {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.media-info {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
}

/* ===================================================================
   Settings
   =================================================================== */
.settings-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  overflow: hidden;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { color: var(--text-secondary); }
.setting-value { font-weight: 500; font-variant-numeric: tabular-nums; }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: #fff; }

/* ===================================================================
   Responsive
   =================================================================== */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  #mobile-header { display: flex; }
  #main-content { margin-left: 0; padding: 0 16px 32px; padding-top: 56px; }
  .topbar { height: auto; padding: 12px 0; flex-direction: column; align-items: flex-start; gap: 4px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr 1fr; }
  .plugins-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
}

/* ===================================================================
   Loading / skeleton
   =================================================================== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.demo-notice { color: var(--text-muted); text-align: center; padding: 16px; font-style: italic; opacity: 0.6; }
.demo-label { opacity: 0.4; }
