:root {
  /* Design Tokens from Documentation */
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --destructive: #ef4444;
  --destructive-hover: #dc2626;
  --warning: #f59e0b;
  --bg-light: #f0f9ff;
  --bg-dark: #0f1117;
  --card-light: rgba(255, 255, 255, 0.85);
  --card-dark: #161b27;
  --text-light: #0f172a;
  --text-dark: #f8fafc;
  --muted: #64748b;
  --border-light: rgba(14, 165, 233, 0.15);
  --border-dark: #2a2f3e;
  --sidebar-light: rgba(255, 255, 255, 0.95);
  --sidebar-dark: #161b27;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-light);
  color: var(--text-light);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  overflow: hidden;
}

body.dark {
  background: var(--bg-dark);
  color: var(--text-dark);
}

.app-shell {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--sidebar-light);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: all 0.3s;
  z-index: 50;
}

body.dark .sidebar {
  background: var(--sidebar-dark);
  border-color: var(--border-dark);
}

.sidebar-header {
  padding: 32px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-container {
  width: 40px;
  height: 40px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  transition: stroke 0.2s;
}

.nav-item:hover {
  background: rgba(16, 185, 129, 0.05);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: white;
}

.nav-item.active svg {
  stroke: white;
}

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

body.dark .sidebar-footer {
  border-color: var(--border-dark);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

body.dark .theme-toggle {
  border-color: var(--border-dark);
}

.theme-toggle:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text-light);
}

body.dark .theme-toggle:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-dark);
}

.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
body.dark .theme-toggle .sun { display: block; color: var(--warning); }
body.dark .theme-toggle .moon { display: none; }

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  height: 80px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
}

body.dark .top-bar {
  background: rgba(15, 17, 23, 0.5);
  border-color: var(--border-dark);
}

#view-title { font-family: 'Outfit', sans-serif; font-size: 1.5rem; font-weight: 700; }

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

.monitoring-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(100, 116, 139, 0.1);
  color: var(--muted);
}

.monitoring-badge .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
}

.monitoring-badge.running { background: rgba(16, 185, 129, 0.1); color: var(--primary); }
.monitoring-badge.running .dot { 
  background: var(--primary); 
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 1.5s infinite;
}

.user-profile {
  display: flex; align-items: center; gap: 12px;
}

.avatar {
  width: 36px; height: 36px; border-radius: 10px; background: var(--primary);
  color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.875rem;
}

.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-info .name { font-weight: 600; font-size: 0.875rem; }
.user-info .role { font-size: 0.75rem; color: var(--muted); }

/* Content Area */
.content-area {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
}

/* Glassmorphism Classes */
.glass {
  background: rgba(255, 255, 255, 0.7) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

body.dark .glass {
  background: rgba(22, 27, 39, 0.7) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

/* Utility Components */
.card {
  background: var(--card-light);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s;
}

body.dark .card {
  background: var(--card-dark);
  border-color: var(--border-dark);
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-secondary { background: transparent; border-color: var(--border-light); color: var(--text-light); }
body.dark .btn-secondary { border-color: var(--border-dark); color: var(--text-dark); }
.btn-secondary:hover { background: rgba(0,0,0,0.02); }

/* Modal Styles */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}

.modal-overlay:not(.hidden) { opacity: 1; pointer-events: auto; }

.modal-card {
  width: 100%; max-width: 500px; border-radius: var(--radius-xl); overflow: hidden;
  transform: translateY(20px); transition: transform 0.3s;
}

.modal-overlay:not(.hidden) .modal-card { transform: translateY(0); }

.modal-header { padding: 24px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 24px; }
.modal-footer { padding: 24px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 12px; }

.close-modal {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}

.close-modal:hover { color: var(--text-light); }
body.dark .close-modal:hover { color: var(--text-dark); }

.hidden { display: none !important; }

/* Dashboard Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-bottom: 32px; }
.stat-card { display: flex; flex-direction: column; gap: 8px; }
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-family: 'Outfit'; }

/* Site List */
.site-table { width: 100%; border-collapse: collapse; }
.site-table th { text-align: left; padding: 12px 16px; font-size: 0.75rem; color: var(--muted); border-bottom: 1px solid var(--border-light); }
.site-table td { padding: 16px; border-bottom: 1px solid var(--border-light); font-size: 0.875rem; }
body.dark .site-table th, body.dark .site-table td { border-color: var(--border-dark); }

.site-table.interactive tbody tr {
  cursor: pointer;
  transition: background 0.2s;
}

.site-table.interactive tbody tr:hover {
  background: rgba(16, 185, 129, 0.04);
}

body.dark .site-table.interactive tbody tr:hover {
  background: rgba(16, 185, 129, 0.08);
}

/* Sparklines */
polyline {
  filter: drop-shadow(0 0 2px var(--primary));
}

/* Uptime Bar */
.uptime-bar {
  height: 32px;
  display: flex;
  gap: 3px;
}

.uptime-dot {
  flex: 1;
  height: 100%;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.1);
  min-width: 4px;
}

body.dark .uptime-dot {
  background: rgba(255, 255, 255, 0.1);
}

.uptime-dot.up { 
  background: #0ea5e9; /* Vibrant Sky Blue */
}
.uptime-dot.down { background: var(--destructive); }
.uptime-dot.empty { opacity: 0.2; }

/* Range Slider */
.form-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  margin: 10px 0;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  margin-top: -6px;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.form-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: var(--border-light);
  border-radius: 2px;
}

body.dark .form-range::-webkit-slider-runnable-track {
  background: var(--border-dark);
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 500; }

.form-control {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--card-light);
  color: var(--text-light);
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

body.dark .form-control {
  background: rgba(0, 0, 0, 0.3);
  border-color: var(--border-dark);
  color: var(--text-dark);
}

body.dark .form-control:focus {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.5);
}

/* Toast Notifications */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 12px; z-index: 2000;
}

.toast {
  padding: 12px 20px; border-radius: 10px; background: var(--card-light); border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg); font-size: 0.875rem; font-weight: 500; min-width: 200px;
  animation: slideIn 0.3s ease-out forwards;
}

body.dark .toast { background: var(--card-dark); border-color: var(--border-dark); }

.toast.success { border-left: 4px solid var(--primary); }
.toast.error { border-left: 4px solid var(--destructive); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
  animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* Status Indicator Variants */
.indicator-online { background: #10b981; }
.indicator-offline { background: #ef4444; }
.indicator-unknown { background: #94a3b8; }
.indicator-maintenance { background: #facc15; }

.dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}

.dot-online {
  background: var(--primary);
  animation: pulse 1.5s infinite;
}

.dot-offline {
  background: var(--destructive);
  animation: pulse 1.5s infinite;
}

.text-online { color: var(--primary); }
.text-offline { color: var(--destructive); }
.text-warning { color: #facc15; }

.badge-online { background: rgba(16, 185, 129, 0.1); color: #059669; }
.badge-offline { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
.badge-unknown { background: rgba(148, 163, 184, 0.1); color: #475569; }
.badge-maintenance { background: #facc151a; color: #facc15; }

body.dark .badge-online { background: rgba(52, 211, 153, 0.12); color: #34d399; }
body.dark .badge-offline { background: rgba(248, 113, 113, 0.12); color: #f87171; }

/* Audio Alert Animations */
@keyframes pulse-red {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%       { opacity: 0.85; box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* Login Styles */
.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  background: var(--bg-light);
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1000;
}

body.dark .login-shell {
  background: var(--bg-dark);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
  margin: 20px;
}

.login-header {
  margin-bottom: 32px;
}

.login-header .logo-container {
  margin: 0 auto 16px auto;
  width: 64px;
  height: 64px;
  border-radius: 16px;
}

.login-header .logo-container svg {
  width: 32px;
  height: 32px;
}

.login-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 8px;
}

body.dark .login-header h2 {
  color: var(--text-dark);
}

.login-header p {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Mobile Sidebar Styles */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
  backdrop-filter: blur(4px);
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.mobile-menu-btn:hover {
  color: var(--text-light);
}
body.dark .mobile-menu-btn:hover {
  color: var(--text-dark);
}

@media (max-width: 768px) {
  .app-shell {
    display: flex;
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    bottom: 0;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  body.sidebar-open .sidebar {
    transform: translateX(260px);
  }
  
  body.sidebar-open .sidebar-overlay {
    display: block;
  }
  
  .mobile-menu-btn {
    display: block;
  }
  
  .top-bar {
    padding: 0 20px;
  }
  
  .content-area {
    padding: 20px;
  }
}

