/* ==========================================================================
   PNS MANAGER - CORE DESIGN SYSTEM & TOKENS (Vanilla CSS)
   Aesthetic: Obsidian Glassmorphism with Amber & Emerald Accents
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-app: #080c14;
  --bg-surface: #0e1422;
  --bg-panel: #131b2e;
  --bg-elevated: #1a243d;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(249, 115, 22, 0.12);

  /* Primary Accent: Amber Flame */
  --accent-primary: #f97316;
  --accent-primary-hover: #ea580c;
  --accent-primary-light: #fed7aa;
  --accent-glow: rgba(249, 115, 22, 0.35);

  /* Functional Status Colors */
  --status-emerald: #10b981;
  --status-emerald-bg: rgba(16, 185, 129, 0.12);
  --status-emerald-glow: rgba(16, 185, 129, 0.4);

  --status-blue: #3b82f6;
  --status-blue-bg: rgba(59, 130, 246, 0.12);

  --status-purple: #a855f7;
  --status-purple-bg: rgba(168, 85, 247, 0.12);

  --status-amber: #f59e0b;
  --status-amber-bg: rgba(245, 158, 11, 0.12);

  --status-danger: #ef4444;
  --status-danger-hover: #dc2626;
  --status-danger-bg: rgba(239, 68, 68, 0.12);
  --status-danger-glow: rgba(239, 68, 68, 0.4);

  /* Typography Colors */
  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-focus: #f97316;

  /* Fonts */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Layout Constants */
  --topbar-height: 60px;
  --sidebar-width: 250px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 35px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px var(--accent-glow);
}

/* CSS Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden !important;
  box-sizing: border-box;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* App Structure */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
  background: radial-gradient(circle at 15% 10%, rgba(249, 115, 22, 0.04) 0%, transparent 40%),
              radial-gradient(circle at 85% 90%, rgba(16, 185, 129, 0.03) 0%, transparent 40%),
              var(--bg-app);
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: rgba(14, 20, 34, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.2);
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

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

.edge-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--status-emerald-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--status-emerald);
}

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

.status-dot.pulsating {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.profile-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.profile-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-main);
}

.profile-role {
  font-size: 10px;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Main Body Layout */
.main-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--topbar-height));
  position: relative;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Sidebar - Firm, Grounded & Sticky Architecture */
.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  position: sticky;
  top: var(--topbar-height);
  background: linear-gradient(180deg, #0e1628 0%, #090e1a 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  overflow: hidden;
}

/* Sidebar Anchor Header */
.sidebar-workspace-anchor {
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
}

.workspace-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.workspace-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 6px var(--accent-primary);
}

.workspace-badge-text {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-primary);
  text-transform: uppercase;
}

.workspace-name-text {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 14px 10px 6px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.nav-section-title:first-child {
  margin-top: 0;
  border-top: none;
  padding-top: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.nav-icon-box {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.nav-icon {
  font-size: 14px;
}

.nav-label {
  flex: 1;
}

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

.nav-item:hover .nav-icon-box {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Docked Active State (Vững Chãi, Neo Chặt Cột Trái) */
.nav-item.active {
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.18) 0%, rgba(249, 115, 22, 0.04) 100%);
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-left: 4px solid var(--accent-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.15);
}

.nav-item.active .nav-icon-box {
  background: rgba(249, 115, 22, 0.25);
  border-color: rgba(249, 115, 22, 0.45);
}

.nav-counter {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 9999px;
  color: var(--text-secondary);
}

.live-dot-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-emerald);
  box-shadow: 0 0 8px var(--status-emerald);
  animation: pulse-green 1.5s infinite;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.cache-stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.cache-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 6px;
}

.cache-stats-row {
  display: flex;
  justify-content: space-between;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.stat-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.version-tag {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Viewport */
.content-viewport {
  flex: 1;
  min-width: 0;
  padding: 24px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

.app-view {
  display: none;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* View Header */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.view-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.view-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

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