/* Design System Variable Configuration */
:root {
  --bg-gradient: radial-gradient(circle at top left, #0e122b, #05060f);
  --glass-bg: rgba(13, 17, 38, 0.6);
  --glass-border: rgba(59, 130, 246, 0.15);
  --glass-border-hover: rgba(139, 92, 246, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  
  --primary-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --primary-glow: 0 0 15px rgba(139, 92, 246, 0.4);
  --accent-color: #06b6d4;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --color-online: #10b981;
  --color-offline: #ef4444;
  --color-warning: #f59e0b;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
}

/* Reset & Core Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* Main Container Layout */
.app-container {
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header Styles */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(12px);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem 2rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  background: var(--primary-gradient);
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--primary-glow);
}

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

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text .sub-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Stats and Tools Bar */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--border-radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
  outline: none;
  padding: 0.75rem 1.5rem;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.6);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon-text {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  padding: 0.6rem 1.2rem;
}

.btn-icon-text:hover {
  border-color: var(--glass-border-hover);
  background: rgba(13, 17, 38, 0.8);
  transform: translateY(-1px);
}

.btn-icon-text i {
  width: 16px;
  height: 16px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--border-radius-md);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

/* Server Cards Grid */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.5rem;
}

/* Glassmorphic Server Card */
.server-card {
  backdrop-filter: blur(12px);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.server-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-gradient);
  opacity: 0;
  transition: var(--transition-smooth);
}

.server-card:hover {
  transform: translateY(-5px);
  border-color: var(--glass-border-hover);
  box-shadow: 0 12px 40px 0 rgba(139, 92, 246, 0.15);
}

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

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.server-title {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.server-title h3 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.server-host-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* OS / Spec Badges */
.card-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-weight: 500;
  text-transform: capitalize;
}

.badge-os {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.badge-spec {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-auth {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Server Status Indicators */
.status-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

.status-text {
  font-size: 0.75rem;
  font-weight: 600;
}

/* Status States */
.status-checking .status-dot {
  background: var(--text-muted);
}
.status-checking .status-text {
  color: var(--text-muted);
}

.status-online .status-dot {
  background: var(--color-online);
  box-shadow: 0 0 8px var(--color-online);
}
.status-online .status-text {
  color: var(--color-online);
}

.status-offline .status-dot {
  background: var(--color-offline);
  box-shadow: 0 0 8px var(--color-offline);
}
.status-offline .status-text {
  color: var(--color-offline);
}

/* Card Body / Description */
.card-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  min-height: 2.25rem;
}

/* Card Footer Actions */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 1rem;
}

.card-actions {
  display: flex;
  gap: 0.4rem;
}

.card-actions .btn {
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  border-radius: var(--border-radius-sm);
  gap: 0.3rem;
}

.card-actions .btn i {
  width: 13px;
  height: 13px;
}


/* Add Server Card (Dotted) */
.add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(59, 130, 246, 0.3);
  background: rgba(13, 17, 38, 0.3);
  cursor: pointer;
  min-height: 240px;
  gap: 1rem;
}

.add-card:hover {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.05);
}

.add-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.add-card:hover .add-card-icon {
  color: #fff;
  border-color: #8b5cf6;
  background: var(--primary-gradient);
  box-shadow: var(--primary-glow);
}

.add-card-text {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.add-card:hover .add-card-text {
  color: #fff;
}

/* PULSE ANIMATION */
.pulse {
  animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Modal Overlay & Card System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 4, 10, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: #0f132e;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  padding: 2rem;
  transform: translateY(20px) scale(0.95);
  transition: var(--transition-smooth);
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-close:hover {
  color: #fff;
  transform: rotate(90deg);
}

/* Forms Styling */
#server-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

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

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.flex-3 { flex: 3 !important; }
.flex-1 { flex: 1 !important; }

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1rem;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
  background: rgba(0, 0, 0, 0.4);
}

textarea {
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  resize: vertical;
}

select option {
  background: #0f132e;
  color: #fff;
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1.5rem;
}

.hidden {
  display: none !important;
}

/* Terminal Fullscreen Overlay */
.terminal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 200;
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.terminal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.terminal-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #111424;
}

.terminal-header {
  height: 52px;
  background: #0b0d18;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

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

.terminal-title {
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.terminal-actions {
  display: flex;
  gap: 0.5rem;
}

.terminal-body {
  flex: 1;
  padding: 1rem;
  background: #181b2d;
  position: relative;
  overflow: hidden;
}

/* xterm layout adjustments */
.xterm {
  height: 100%;
  width: 100%;
}

.xterm-viewport {
  background-color: #181b2d !important;
}

/* Grouping Layout */
.group-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  animation: fadeIn 0.4s ease-out;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  border-left: 4px solid #8b5cf6;
  padding-left: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s ease;
}

.group-header:hover {
  opacity: 0.85;
}

.group-chevron {
  color: #8b5cf6;
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.group-chevron.collapsed {
  transform: rotate(-90deg);
}

.server-grid.collapsed {
  display: none !important;
}

.input-with-button {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.input-with-button input {
  flex: 1;
}

.group-header-count {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.5rem;
  border-radius: 12px;
}

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

/* Distinct Action Buttons styling */
.btn-edit:hover {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #3b82f6 !important;
  border-color: rgba(59, 130, 246, 0.5) !important;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

/* Terminal Container & Overlay Action System */
.terminal-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #111424;
  position: relative; /* Essential for absolute positioning of overlay */
}

.terminal-exit-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 10, 22, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.3s ease-out;
}

.exit-card {
  background: #0f132e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--glass-shadow), 0 0 30px rgba(139, 92, 246, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.exit-card-icon {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.exit-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
}

.exit-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.exit-actions {
  display: flex;
  gap: 1rem;
  width: 100%;
  margin-top: 0.5rem;
}

.server-container {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* ==========================================================================
   Responsive Overrides (Mobile & Tablet)
   ========================================================================== */
@media (max-width: 768px) {
  .app-container {
    padding: 1.25rem 0.75rem;
    gap: 1.5rem;
  }
  
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem 1rem;
    gap: 1.25rem;
  }
  
  .logo-area {
    justify-content: center;
  }
  
  .header-actions {
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    gap: 0.5rem !important;
  }
  
  .header-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 0.85rem;
    padding: 0.5rem 0.8rem;
  }

  .servers-section {
    padding: 1.25rem 1rem;
  }
  
  .group-header {
    font-size: 1.1rem;
  }

  .server-grid {
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1rem;
  }

  .modal-card {
    width: 95%;
    padding: 1.5rem 1.25rem;
    max-height: 90vh;
    overflow-y: auto;
  }

  .form-row {
    flex-direction: column;
    gap: 1rem;
  }
  
  .form-row .form-group {
    width: 100% !important;
    flex: none !important;
  }
  
  .form-row div[style*="display: flex"] {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }
  
  .form-row div[style*="display: flex"] input {
    width: 100% !important;
  }

  /* Scan buttons responsive sizing */
  #btn-ip-scan, #btn-system-scan {
    width: 100%;
    justify-content: center;
  }

  /* Terminal Drawer mobile optimizing */
  .terminal-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-width: 100vw;
    max-height: 100vh;
  }

  .terminal-header {
    padding: 0.75rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .terminal-info {
    justify-content: center;
  }

  .terminal-actions {
    width: 100%;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .terminal-actions .btn {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.8rem;
    justify-content: center;
  }
  
  /* Exit modal styling on mobile */
  .exit-card {
    width: 92%;
    padding: 1.5rem 1.25rem;
  }
  
  .exit-actions {
    flex-direction: column;
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .logo-text h1 {
    font-size: 1.15rem;
  }
  
  .logo-text .sub-text {
    font-size: 0.7rem;
  }

  .server-card {
    padding: 1.25rem 1rem;
  }

  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .card-actions .btn {
    width: 100%;
    justify-content: center;
  }
}


