/* =====================================================
   DESIGN SYSTEM - Futuristic 90s Retro (Cyberpunk/Vaporwave)
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Rajdhani:wght@400;600;700&display=swap');

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

:root {
  /* Neon Palette */
  --neon-cyan: #00f3ff;
  --neon-pink: #ff00ff;
  --neon-purple: #bc13fe;
  --neon-green: #0aff0a;
  --neon-yellow: #ffee00;

  /* Dark Backgrounds */
  --bg-void: #050510;
  --bg-grid: #0a0a1a;
  --bg-panel: rgba(15, 15, 30, 0.8);

  /* Text */
  --text-main: #e0e0ff;
  --text-dim: #8080a0;
  --text-glow: 0 0 10px rgba(224, 224, 255, 0.5);

  /* UI Elements */
  --border-glow: 0 0 15px rgba(0, 243, 255, 0.3);
  --glass-border: 1px solid rgba(0, 243, 255, 0.2);

  /* Fonts */
  --font-display: 'Rajdhani', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
}

/* =====================================================
   BASE STYLES & CRT EFFECT
   ===================================================== */

body {
  background-color: var(--bg-void);
  background-image:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 2px, 3px 100%;
  color: var(--text-main);
  font-family: var(--font-display);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Subtle Grid Background */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background:
    linear-gradient(transparent 95%, rgba(0, 243, 255, 0.1) 95%),
    linear-gradient(90deg, transparent 95%, rgba(0, 243, 255, 0.1) 95%);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: -1;
  transform: perspective(500px) rotateX(20deg) scale(1.5);
  transform-origin: top;
  opacity: 0.3;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-shadow: 0 0 10px var(--neon-cyan);
}

a {
  color: var(--neon-cyan);
  text-decoration: none;
  transition: all 0.3s ease;
}

a:hover {
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink);
}

/* Activity Feed / Logs Scrollbar */
.retro-card::-webkit-scrollbar,
#activity-list::-webkit-scrollbar {
  width: 6px;
}

.retro-card::-webkit-scrollbar-track,
#activity-list::-webkit-scrollbar-track {
  background: rgba(0, 255, 255, 0.08);
  border-radius: 3px;
}

.retro-card::-webkit-scrollbar-thumb,
#activity-list::-webkit-scrollbar-thumb {
  background: var(--neon-cyan);
  border-radius: 3px;
}

.retro-card::-webkit-scrollbar-thumb:hover,
#activity-list::-webkit-scrollbar-thumb:hover {
  background: #00e5e5;
  box-shadow: 0 0 10px var(--neon-cyan);
}

/* =====================================================
   LAYOUT (Sidebar + Main)
   ===================================================== */

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

.sidebar {
  width: 280px;
  background: rgba(10, 10, 20, 0.9);
  border-right: 1px solid var(--neon-purple);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  box-shadow: 5px 0 20px rgba(188, 19, 254, 0.1);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}

.main-content {
  flex: 1;
  padding: var(--space-xl);
  overflow-y: auto;
}

/* =====================================================
   SIDEBAR COMPONENTS
   ===================================================== */

.brand {
  font-size: 24px;
  font-weight: 700;
  color: var(--neon-cyan);
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: center;
  gap: 10px;
  text-shadow: 0 0 15px var(--neon-cyan);
}

.nav-section {
  margin-bottom: var(--space-lg);
}

.nav-title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  color: var(--text-main);
  border-radius: 4px;
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 14px;
  transition: all 0.2s;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(0, 243, 255, 0.1);
  color: var(--neon-cyan);
  border-left: 3px solid var(--neon-cyan);
  padding-left: 7px;
  /* Adjust for border */
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.1);
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

/* =====================================================
   DASHBOARD GRID & CARDS
   ===================================================== */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.search-bar {
  position: relative;
  width: 300px;
}

.search-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--neon-purple);
  padding: 10px 15px;
  padding-left: 40px;
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  border-radius: 4px;
  transition: all 0.3s;
}

.search-input:focus {
  outline: none;
  box-shadow: 0 0 15px rgba(188, 19, 254, 0.3);
  border-color: var(--neon-pink);
}

.input-field {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--neon-purple);
  padding: 10px 15px;
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  border-radius: 4px;
  transition: all 0.3s;
}

.input-field:focus {
  outline: none;
  box-shadow: 0 0 15px rgba(188, 19, 254, 0.3);
  border-color: var(--neon-pink);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--neon-purple);
  pointer-events: none;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-lg);
}

@media (max-width: 768px) {
  .system-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
}

.retro-card {
  background: linear-gradient(135deg, rgba(10, 10, 30, 0.9), rgba(15, 15, 35, 0.75));
  border: 1px solid rgba(0, 243, 255, 0.25);
  position: relative;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.retro-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 2;
}

.retro-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 243, 255, 0.14), 0 0 0 1px rgba(0, 243, 255, 0.35);
  border-color: rgba(0, 243, 255, 0.55);
}

.retro-card:hover::before {
  opacity: 1;
}

/* Card Header: icon + title + status */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.sys-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  background: rgba(0, 243, 255, 0.08);
  border: 1px solid rgba(0, 243, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--neon-cyan);
  text-decoration: none;
  transition: all 0.3s;
}

.sys-icon:hover {
  background: rgba(0, 243, 255, 0.18);
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.25);
}

.card-title-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: white;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  transition: color 0.2s;
}

.card-title:hover {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

.card-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-subtitle .group-tag {
  color: var(--neon-purple);
}

/* Action buttons row */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.12);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  padding: 5px 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.action-btn span {
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.action-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(0, 243, 255, 0.08);
}

.action-btn.danger:hover {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  background: rgba(255, 0, 100, 0.1);
}

.action-btn:active {
  transform: scale(0.95);
}

/* Card body: status info */
.card-body {
  padding: 12px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-info {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.card-info .highlight {
  color: var(--neon-green);
}

.card-note {
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 16px;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.15);
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border: 1px solid;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-badge.online {
  color: var(--neon-green);
  border-color: rgba(0, 255, 136, 0.4);
  background: rgba(0, 255, 136, 0.08);
}

.status-badge.online::before {
  background: var(--neon-green);
  box-shadow: 0 0 8px var(--neon-green);
  animation: pulse 2s infinite;
}

.status-badge.standby {
  color: var(--neon-yellow);
  border-color: rgba(255, 200, 0, 0.4);
  background: rgba(255, 200, 0, 0.08);
}

.status-badge.standby::before {
  background: var(--neon-yellow);
  box-shadow: 0 0 8px var(--neon-yellow);
  animation: pulse 3s infinite;
}

.status-badge.offline {
  color: var(--text-dim);
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.6;
}

.status-badge.offline::before {
  background: var(--text-dim);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (max-width: 480px) {
  .card-header {
    padding: 10px 12px 10px;
  }
  .card-body {
    padding: 10px 12px;
  }
  .card-actions {
    padding: 8px 12px;
    gap: 4px;
  }
  .action-btn {
    padding: 5px 7px;
  }
}

/* =====================================================
   BUTTONS & FORMS
   ===================================================== */

.btn-retro {
  background: transparent;
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 8px 16px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.btn-retro:hover {
  background: var(--neon-cyan);
  color: black;
  box-shadow: 0 0 20px var(--neon-cyan);
}

.btn-retro.primary {
  background: rgba(0, 243, 255, 0.1);
}

.btn-retro.danger {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
}

.btn-retro.danger:hover {
  background: var(--neon-pink);
  color: white;
  box-shadow: 0 0 20px var(--neon-pink);
}

/* =====================================================
   MODALS & TOASTS
   ===================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  /* visibility keeps closed dialogs out of the tab order / accessibility tree */
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.modal {
  background: var(--bg-void);
  border: 1px solid var(--neon-purple);
  width: 400px;
  padding: var(--space-lg);
  box-shadow: 0 0 30px rgba(188, 19, 254, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Tall dialogs scroll instead of running off-screen */
  max-height: 88vh;
  overflow: auto;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  font-size: 20px;
  color: var(--neon-purple);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid rgba(188, 19, 254, 0.3);
  padding-bottom: 10px;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

/* Keyboard focus ring (only shows for keyboard navigation; later in the file
   than the .search-input/.input-field :focus rules so it wins the cascade) */
:focus-visible,
.search-input:focus-visible,
.input-field:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.5);
}

/* Sidebar / feed health indicator (was referenced in markup with no rule) */
.health-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 8px var(--neon-green);
}

/* Remote shell command input (replaces inline focus/blur handlers) */
.exec-input {
  flex: 1;
  height: 44px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 243, 255, 0.3);
  color: var(--neon-green);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  resize: vertical;
  transition: border-color 0.2s;
}

.exec-input:focus {
  border-color: var(--neon-cyan);
}

/* Field label above an input/textarea inside a modal */
.field-label {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 5px;
  font-family: var(--font-mono);
}

.toast {
  background: rgba(10, 10, 20, 0.9);
  border-left: 4px solid var(--neon-cyan);
  padding: 15px 20px;
  color: white;
  font-family: var(--font-mono);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease-out;
  min-width: 250px;
}

.toast.success {
  border-color: var(--neon-green);
}

.toast.error {
  border-color: var(--neon-pink);
}

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

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* =====================================================
   SIGN IN PAGE (Split Layout)
   ===================================================== */

.split-layout {
  display: flex;
  height: 100vh;
}

.split-art {
  flex: 1;
  background: radial-gradient(circle at center, #1a0b2e 0%, #000000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.split-form {
  width: 450px;
  background: rgba(5, 5, 10, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--neon-purple);
  position: relative;
  z-index: 10;
}

.cyber-grid {
  position: absolute;
  width: 200%;
  height: 200%;
  background-image:
    linear-gradient(rgba(0, 243, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 243, 255, 0.1) 1px, transparent 1px);
  background-size: 50px 50px;
  transform: perspective(500px) rotateX(60deg) translateY(-100px) translateZ(-200px);
  animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
  0% {
    transform: perspective(500px) rotateX(60deg) translateY(0) translateZ(-200px);
  }

  100% {
    transform: perspective(500px) rotateX(60deg) translateY(50px) translateZ(-200px);
  }
}

/* =====================================================
    EMPTY STATE
    ===================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  min-height: 300px;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-dim);
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-dim);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  opacity: 0.6;
}

/* =====================================================
    EXEC HISTORY SCROLLBAR
    ===================================================== */

#exec-history::-webkit-scrollbar {
  width: 5px;
}

#exec-history::-webkit-scrollbar-track {
  background: rgba(0, 255, 255, 0.05);
}

#exec-history::-webkit-scrollbar-thumb {
  background: var(--neon-purple);
  border-radius: 3px;
}

#exec-history::-webkit-scrollbar-thumb:hover {
  background: var(--neon-cyan);
}

#exec-output::-webkit-scrollbar {
  width: 5px;
}

#exec-output::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

#exec-output::-webkit-scrollbar-thumb {
  background: var(--neon-green);
  border-radius: 3px;
}

/* =====================================================
    RESPONSIVE
    ===================================================== */

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .split-layout {
    flex-direction: column;
  }

  .split-art {
    display: none;
  }

  .split-form {
    width: 100%;
  }
}