:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, "Liberation Mono", monospace;

  /* GitHub Dark Mode Default */
  --bg-app: #0d1117;
  --bg-navbar: #010409;
  --bg-card: #0d1117;
  --bg-card-header: #161b22;
  --bg-card-hover: #161b22;
  --bg-input: #0d1117;
  --border-color: #30363d;
  --border-focus: #58a6ff;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  
  --k8s-blue: #58a6ff;
  --k8s-blue-glow: rgba(88, 166, 255, 0.25);
  --accent-cyan: #39d353;
  --accent-emerald: #238636;
  --accent-amber: #d29922;
  --accent-rose: #f85149;
  --accent-purple: #bc8cff;

  --terminal-bg: #010409;
  --terminal-header: #161b22;
  --terminal-text: #c9d1d9;
  --shadow-card: 0 0 transparent; /* GitHub usually relies on borders rather than shadows for dark mode */
  --shadow-glow: 0 0 10px rgba(88, 166, 255, 0.15);
}

[data-theme="light"] {
  /* GitHub Light Mode Default */
  --bg-app: #f6f8fa;
  --bg-navbar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-header: #f6f8fa;
  --bg-card-hover: #f3f4f6;
  --bg-input: #ffffff;
  --border-color: #d0d7de;
  --border-focus: #0969da;
  --text-primary: #24292f;
  --text-secondary: #57606a;
  --text-muted: #8c959f;

  --k8s-blue: #0969da;
  --k8s-blue-glow: rgba(9, 105, 218, 0.15);
  --accent-cyan: #1a7f37;
  --accent-emerald: #2da44e;
  --accent-amber: #bf8700;
  --accent-rose: #cf222e;
  --accent-purple: #8250df;

  --terminal-bg: #f6f8fa;
  --terminal-header: #eaeef2;
  --terminal-text: #24292f;
  --shadow-card: 0 1px 3px rgba(31, 35, 40, 0.12), 0 8px 24px rgba(66, 74, 83, 0.12);
  --shadow-glow: 0 0 10px rgba(9, 105, 218, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

/* Glass Navbar */
.navbar-custom {
  background: var(--bg-navbar);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1020;
  padding: 1rem 2rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-icon-wrapper {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #326ce5 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 15px rgba(50, 108, 229, 0.4);
  transition: transform 0.4s ease;
}

.brand-logo:hover .brand-icon-wrapper {
  transform: rotate(30deg) scale(1.05);
}

.brand-badge {
  font-size: 0.65rem;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-weight: 600;
  text-transform: uppercase;
}

/* Global Search Input */
.search-wrapper {
  position: relative;
  width: 320px;
}

.search-wrapper i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 7px 12px 7px 36px;
  font-size: 0.875rem;
  width: 100%;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
  background: var(--bg-card);
}

.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  pointer-events: none;
}

/* Metric / Stat KPI Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.deployments::before { background: linear-gradient(to bottom, #3b82f6, #06b6d4); }
.stat-card.pods::before { background: linear-gradient(to bottom, #10b981, #06b6d4); }
.stat-card.networking::before { background: linear-gradient(to bottom, #8b5cf6, #ec4899); }
.stat-card.storage::before { background: linear-gradient(to bottom, #f59e0b, #ef4444); }

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.stat-icon.green { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-top: 4px;
}

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

/* Nav Tabs */
.nav-pills-custom {
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.nav-pills-custom .nav-link {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.nav-pills-custom .nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.nav-pills-custom .nav-link.active {
  color: #ffffff;
  background: var(--k8s-blue);
  box-shadow: none;
}

.nav-pills-custom .nav-link .badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 2px 8px;
}

.nav-pills-custom .nav-link:not(.active) .badge {
  background: var(--bg-input);
  color: var(--text-secondary);
}

/* Resource Section Cards */
.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
  overflow: hidden;
  transition: all 0.2s ease;
}

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

.resource-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

/* Modern Tables */
.custom-table {
  width: 100%;
  margin-bottom: 0;
  color: var(--text-primary);
  border-collapse: separate;
  border-spacing: 0;
}

.custom-table th {
  background: var(--bg-card-header);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.custom-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  vertical-align: middle;
  background: transparent;
  transition: background-color 0.15s ease;
}

.custom-table tbody tr:hover td {
  background: var(--bg-card-hover);
}

.custom-table tbody tr:last-child td {
  border-bottom: none;
}

/* Status Badges with Pulsing Dot */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.status-badge.running,
.status-badge.bound,
.status-badge.healthy {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-badge.pending,
.status-badge.creating {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.status-badge.failed,
.status-badge.crashloop,
.status-badge.error {
  background: rgba(244, 63, 94, 0.12);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.status-badge.completed,
.status-badge.terminating,
.status-badge.unknown {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  position: relative;
  display: inline-block;
}

.pulse-dot.running { background-color: #10b981; }
.pulse-dot.running::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 50%;
  background-color: #10b981;
  animation: pulse 1.8s infinite;
}

.pulse-dot.pending { background-color: #f59e0b; }
.pulse-dot.failed { background-color: #f43f5e; }
.pulse-dot.completed { background-color: #94a3b8; }

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* Replica Progress Bar */
.replica-progress-wrapper {
  min-width: 130px;
}

.replica-progress {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-top: 4px;
}

.replica-progress-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.replica-progress-bar.ready { background: linear-gradient(90deg, #10b981, #06b6d4); }
.replica-progress-bar.warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.replica-progress-bar.danger { background: linear-gradient(90deg, #f43f5e, #ef4444); }

/* Monospace Pod Name & Micro Badges */
.resource-name-cell {
  font-family: var(--font-mono);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.8rem;
  transition: color 0.15s, background-color 0.15s;
}

.copy-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.tag-badge {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.tag-badge.port {
  background: rgba(139, 92, 246, 0.1);
  color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.25);
  font-family: var(--font-mono);
}

.tag-badge.type {
  font-weight: 600;
}
.tag-badge.type.ClusterIP { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.tag-badge.type.NodePort { background: rgba(6, 182, 212, 0.12); color: #22d3ee; }
.tag-badge.type.LoadBalancer { background: rgba(16, 185, 129, 0.12); color: #34d399; }

/* Action Buttons */
.btn-action {
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-action-primary {
  background: rgba(50, 108, 229, 0.15);
  color: #60a5fa;
  border-color: rgba(50, 108, 229, 0.3);
}
.btn-action-primary:hover {
  background: #326ce5;
  color: #fff;
  box-shadow: 0 0 10px rgba(50, 108, 229, 0.4);
}

.btn-action-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}
.btn-action-warning:hover {
  background: #f59e0b;
  color: #fff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.btn-action-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.3);
}
.btn-action-danger:hover {
  background: #f43f5e;
  color: #fff;
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.4);
}

.btn-action-secondary {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.btn-action-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Modern Modals */
.modal-content-custom {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  color: var(--text-primary);
  overflow: hidden;
}

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

.modal-header-custom .modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Stepper Scale Controls */
.stepper-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 1.5rem 0;
}

.stepper-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.stepper-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.stepper-display {
  font-size: 2.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  min-width: 90px;
  text-align: center;
  color: #38bdf8;
}

.preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 1rem;
}

.preset-pill {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-pill:hover, .preset-pill.active {
  background: #326ce5;
  color: #fff;
  border-color: #326ce5;
}

/* Terminal Log Viewer */
.terminal-window {
  background: var(--terminal-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
}

.terminal-titlebar {
  background: var(--terminal-header);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mac-dots {
  display: flex;
  gap: 6px;
}

.mac-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.mac-dot.close { background: #ef4444; }
.mac-dot.min { background: #f59e0b; }
.mac-dot.max { background: #10b981; }

.terminal-toolbar {
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.terminal-body {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  line-height: 1.6;
  color: var(--terminal-text);
  max-height: 480px;
  min-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text;
}

.terminal-body::-webkit-scrollbar {
  width: 8px;
}
.terminal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.terminal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.log-line-info { color: #34d399; }
.log-line-warn { color: #fbbf24; }
.log-line-error { color: #f87171; font-weight: 600; }
.log-line-time { color: #64748b; }
.log-highlight { background: rgba(245, 158, 11, 0.35); color: #fff; padding: 0 2px; border-radius: 2px; }

/* Toast Notifications */
.toast-container-custom {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-custom {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 420px;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.25s ease;
}

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

.toast-custom.hide {
  transform: translateX(120%);
  opacity: 0;
}

.toast-custom.success { border-left: 4px solid #10b981; }
.toast-custom.error { border-left: 4px solid #f43f5e; }
.toast-custom.info { border-left: 4px solid #38bdf8; }
.toast-custom.warning { border-left: 4px solid #f59e0b; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: inline-block;
  opacity: 0.6;
}
.empty-state h5 {
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Live badge indicator */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.live-indicator.offline {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

/* Spinner Rotate */
.rotate-anim {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}
