/* ==========================================================================
   FusionOS Design System & Dashboard CSS
   Stack: Vanilla CSS, Glassmorphism, Dark Cyber Theme, Smooth Transitions
   ========================================================================== */

:root {
  --bg-dark: #090d16;
  --bg-card: rgba(16, 23, 38, 0.75);
  --bg-card-hover: rgba(23, 32, 54, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(56, 189, 248, 0.3);
  
  --primary-cyan: #38bdf8;
  --primary-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.15);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

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

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

/* Ambient Glow Background Blobs */
.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.glow-1 {
  width: 500px;
  height: 500px;
  background: rgba(56, 189, 248, 0.12);
  top: -100px;
  left: -100px;
}
.glow-2 {
  width: 600px;
  height: 600px;
  background: rgba(168, 85, 247, 0.1);
  top: 300px;
  right: -150px;
}
.glow-3 {
  width: 450px;
  height: 450px;
  background: rgba(16, 185, 129, 0.08);
  bottom: -100px;
  left: 20%;
}

/* Header & Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(9, 13, 22, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-cyan), var(--primary-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.logo-icon {
  color: #fff;
  width: 24px;
  height: 24px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.highlight {
  color: var(--primary-cyan);
}

.brand-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.nav-metrics {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.85rem;
}

.pill-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

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

.pill-value {
  font-weight: 700;
  font-family: var(--font-mono);
}

.text-accent {
  color: var(--primary-cyan);
}
.text-purple { color: var(--primary-purple); }
.text-emerald { color: var(--accent-emerald); }
.text-amber { color: var(--accent-amber); }
.text-rose { color: var(--accent-rose); }
.mono { font-family: var(--font-mono); }

/* Main Dashboard Container */
.dashboard-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  position: relative;
  z-index: 10;
}

/* Dashboard Hero */
.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 600px;
  margin-top: 0.25rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-cyan), #0284c7);
  color: #0f172a;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.5);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

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

.btn-dark {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-dark:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--primary-cyan);
  color: var(--primary-cyan);
}

/* Stats Overview Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-icon {
  width: 20px;
  height: 20px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0.5rem 0 0.25rem 0;
}

.unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-footer {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-icon {
  color: var(--primary-cyan);
  width: 22px;
  height: 22px;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-pulse {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  position: relative;
}

/* Servers Grid */
.servers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.server-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.server-card.running {
  border-left: 4px solid var(--accent-emerald);
}

.server-card.stopped {
  border-left: 4px solid var(--accent-rose);
  opacity: 0.85;
}

.server-card.loading {
  border-left: 4px solid var(--accent-amber);
}

.server-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.7);
}

.card-glow {
  position: absolute;
  top: 0;
  right: 0;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, var(--border-glow) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0.4;
}

.server-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.server-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.status-indicator.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-glow 2s infinite;
}

.status-indicator.offline {
  background-color: var(--accent-rose);
  box-shadow: 0 0 8px var(--accent-rose);
}

.status-indicator.pending {
  background-color: var(--accent-amber);
  box-shadow: 0 0 10px var(--accent-amber);
  animation: pulse-glow 1s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.server-name {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.server-type {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  font-family: var(--font-mono);
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.offline {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Details Grid */
.server-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-val {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.1rem;
}

/* Metric Bars */
.metrics-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.metric-bar-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.metric-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.progress-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

.progress-cyan { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.progress-purple { background: linear-gradient(90deg, #7e22ce, #a855f7); }
.progress-emerald { background: linear-gradient(90deg, #047857, #10b981); }

.opacity-50 { opacity: 0.5; }

/* Toggle & Action Controls */
.server-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.power-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Custom Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.slider.round {
  border-radius: 34px;
}
.slider.round:before {
  border-radius: 50%;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Console Section */
.console-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border-color);
}

.console-title {
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.console-body {
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  height: 180px;
  overflow-y: auto;
  background: rgba(4, 7, 13, 0.9);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.log-line.info { color: var(--primary-cyan); }
.log-line.success { color: var(--accent-emerald); }
.log-line.system { color: var(--text-muted); }
.log-line.warning { color: var(--accent-amber); }
.log-line.error { color: var(--accent-rose); }

/* Modal Backdrop & Card */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
}

.form-group input {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-cyan);
}

.form-group small {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: rgba(16, 23, 38, 0.95);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  backdrop-filter: blur(12px);
  animation: slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }
.toast.info { border-left: 4px solid var(--primary-cyan); }

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

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .dashboard-container { padding: 1rem; }
  .navbar { padding: 1rem; }
  .hero-title { font-size: 1.5rem; }
  .servers-grid { grid-template-columns: 1fr; }
}

/* ===== R2 Storage Browser ===== */
.console-actions { display: flex; gap: 8px; align-items: center; }
.r2-meta { color: #9fb0d0; font-size: 12px; margin: 8px 2px 12px; font-family: 'JetBrains Mono', monospace; }
.r2-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.r2-empty { color: #6b7a9c; font-size: 13px; padding: 18px; text-align: center; }
.r2-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: rgba(15,22,42,.6); border: 1px solid #1e2b48; border-radius: 10px; }
.r2-ico { width: 16px; height: 16px; color: #C9A84C; }
.r2-key { flex: 1; color: #cdd7ee; font-size: 13px; font-family: 'JetBrains Mono', monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r2-size { color: #8aa0c8; font-size: 12px; font-family: 'JetBrains Mono', monospace; }
.r2-dl { color: #58a6ff; font-size: 12px; text-decoration: none; }
.r2-dl:hover { text-decoration: underline; }
.r2-del { background: #3a1d22; color: #ff8b8b; border: 1px solid #5a2a30; border-radius: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer; }
.r2-del:hover { background: #4a2329; }
