/* ==========================================================================
   PM2 Server Control Panel - Style System
   ========================================================================== */

:root {
  /* Color System */
  --bg-gradient: linear-gradient(135deg, #090d16 0%, #111827 100%);
  --panel-bg: rgba(17, 24, 39, 0.6);
  --panel-border: rgba(255, 255, 255, 0.08);
  --glass-card-bg: rgba(24, 33, 53, 0.5);
  --input-bg: rgba(15, 22, 36, 0.8);
  
  /* Accent Colors */
  --cyan: #00f2fe;
  --cyan-glow: rgba(0, 242, 254, 0.3);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.3);
  --purple: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.3);
  --rose: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.3);
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.3);
  
  /* Text Colors */
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #6b7280;
  
  /* Typography */
  --font-family: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Shadow & Transitions */
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background: #090d16;
  background-image: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

/* ==========================================================================
   BUTTONS & ACTIONS
   ========================================================================== */

.btn-primary {
  background: linear-gradient(135deg, #00f2fe 0%, #4f46e5 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-family);
  transition: var(--transition);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-family);
  transition: var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-secondary.active {
  background: var(--cyan-glow);
  border-color: var(--cyan);
  color: var(--cyan);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: var(--rose);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-family);
  transition: var(--transition);
}

.btn-danger:hover {
  background: var(--rose);
  color: white;
  box-shadow: 0 0 15px var(--rose-glow);
}

.btn-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--emerald);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-family);
  transition: var(--transition);
}

.btn-success:hover {
  background: var(--emerald);
  color: white;
  box-shadow: 0 0 15px var(--emerald-glow);
}

.btn-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-action-icon:hover {
  transform: translateY(-2px);
}

.btn-action-icon.restart {
  color: var(--cyan);
  border-color: rgba(0, 242, 254, 0.3);
  background: rgba(0, 242, 254, 0.05);
}
.btn-action-icon.restart:hover {
  background: var(--cyan);
  color: black;
  box-shadow: 0 0 10px var(--cyan-glow);
}

.btn-action-icon.stop {
  color: var(--rose);
  border-color: rgba(244, 63, 94, 0.3);
  background: rgba(244, 63, 94, 0.05);
}
.btn-action-icon.stop:hover {
  background: var(--rose);
  color: white;
  box-shadow: 0 0 10px var(--rose-glow);
}

.btn-action-icon.start {
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}
.btn-action-icon.start:hover {
  background: var(--emerald);
  color: white;
  box-shadow: 0 0 10px var(--emerald-glow);
}

.btn-action-icon.logs {
  color: var(--purple);
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(168, 85, 247, 0.05);
}
.btn-action-icon.logs:hover {
  background: var(--purple);
  color: white;
  box-shadow: 0 0 10px var(--purple-glow);
}

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

.btn-icon:hover {
  color: var(--text-main);
}

.btn-block {
  display: flex;
  width: 100%;
  justify-content: center;
  padding: 0.85rem;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

/* ==========================================================================
   AUTH PAGE (LOGIN)
   ========================================================================== */

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  z-index: 10;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 2.5rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  animation: fadeIn 0.5s ease-out;
}

.auth-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: linear-gradient(135deg, #00f2fe 0%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.logo-icon i {
  font-size: 1.75rem;
  color: white;
}

.auth-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.input-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-group input {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  color: white;
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition);
  width: 100%;
}

.input-group input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  padding-right: 3rem;
}

.password-wrapper button {
  position: absolute;
  right: 12px;
  height: 100%;
  width: 32px;
}

.error-msg {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: var(--rose);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  animation: shake 0.3s ease-in-out;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   MAIN DASHBOARD LAYOUT
   ========================================================================== */

.dashboard-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  gap: 1.5rem;
  animation: fadeIn 0.4s ease-out;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
  gap: 1rem;
}

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

.brand-logo {
  font-size: 2rem;
  background: linear-gradient(135deg, #00f2fe 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.server-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-green {
  color: var(--emerald);
  font-size: 0.55rem;
  text-shadow: 0 0 8px var(--emerald);
}

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

.stat-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-badge i {
  color: var(--cyan);
}

/* Dashboard Content */
.dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Metrics Overall Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.metric-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

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

.card-cyan::before { background: var(--cyan); }
.card-emerald::before { background: var(--emerald); }
.card-purple::before { background: var(--purple); }
.card-rose::before { background: var(--rose); }

.metric-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 2;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.card-cyan .card-icon { background: rgba(0, 242, 254, 0.1); color: var(--cyan); }
.card-emerald .card-icon { background: rgba(16, 185, 129, 0.1); color: var(--emerald); }
.card-purple .card-icon { background: rgba(168, 85, 247, 0.1); color: var(--purple); }
.card-rose .card-icon { background: rgba(244, 63, 94, 0.1); color: var(--rose); }

.metric-info h3 {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sub-text {
  font-size: 0.8rem;
  color: var(--text-dark);
}

.net-speed-rates {
  display: flex;
  gap: 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 0.25rem;
}
.net-speed-rates i {
  font-size: 0.8rem;
}
.net-speed-rates div:first-child i { color: var(--emerald); }
.net-speed-rates div:last-child i { color: var(--rose); }

.chart-container {
  height: 60px;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* Glass Card styling for main list */
.glass-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-icon {
  color: var(--cyan);
  font-size: 1.25rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 320px;
}

.search-box i {
  position: absolute;
  left: 12px;
  color: var(--text-dark);
}

.search-box input {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  padding: 0.5rem 1rem 0.5rem 2.25rem;
  border-radius: 8px;
  color: white;
  width: 100%;
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
}

/* ==========================================================================
   PROCESS TABLE
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.process-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.process-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 600;
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.process-table td {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}

.process-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.01);
}

/* Row-specific elements */
.project-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
}

.project-details {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-dark);
}

.badge-status {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-transform: uppercase;
}

.badge-status.online {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.badge-status.online i {
  color: var(--emerald);
  text-shadow: 0 0 6px var(--emerald);
}

.badge-status.stopped {
  background: rgba(156, 163, 175, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(156, 163, 175, 0.2);
}

.badge-status.errored, .badge-status.error {
  background: rgba(244, 63, 94, 0.1);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.process-pid {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.io-rate-display {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  gap: 0.1rem;
}

.io-rate-display span {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
}

.io-rate-display i {
  font-size: 0.75rem;
}

.io-read i { color: var(--emerald); }
.io-write i { color: var(--cyan); }

.table-loading {
  text-align: center;
  padding: 3rem !important;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.table-loading i {
  margin-right: 0.5rem;
  color: var(--cyan);
}

.actions-cell {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* ==========================================================================
   LOGS TERMINAL DIALOG (MODAL)
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 8, 17, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-card {
  width: 100%;
  max-width: 960px;
  height: 80vh;
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.modal-title i {
  font-size: 1.5rem;
  color: var(--cyan);
}

.modal-title h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-title p {
  font-size: 0.8rem;
  color: var(--text-dark);
}

.close-btn {
  font-size: 1.5rem;
}

.modal-actions-bar {
  padding: 0.75rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-buttons {
  display: flex;
  gap: 0.25rem;
}

.btn-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
}

.btn-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-tab.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--cyan);
}

.text-cyan { color: var(--cyan); }
.text-rose { color: var(--rose); }

.terminal-body {
  flex: 1;
  background: #040711;
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-footer {
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.01);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.terminal-line {
  white-space: pre-wrap;
  word-break: break-all;
}

#log-terminal[data-filter="out"] .terminal-line.err {
  display: none;
}

#log-terminal[data-filter="err"] .terminal-line.out {
  display: none;
}

.terminal-line.out {
  color: #a7f3d0; /* Soft green */
}

.terminal-line.err {
  color: #fca5a5; /* Soft red */
  font-weight: 600;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */

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

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.pulse-glow {
  animation: pulseGlow 2s infinite alternate;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 5px rgba(0, 242, 254, 0.3); }
  100% { box-shadow: 0 0 15px rgba(0, 242, 254, 0.8); }
}

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

@media (max-width: 900px) {
  .process-table th:nth-child(5),
  .process-table td:nth-child(5), /* Uptime */
  .process-table th:nth-child(8),
  .process-table td:nth-child(8) /* Disk IO */ {
    display: none;
  }
}

@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .process-table th:nth-child(3),
  .process-table td:nth-child(3), /* ID */
  .process-table th:nth-child(4),
  .process-table td:nth-child(4), /* PID */
  .process-table th:nth-child(9),
  .process-table td:nth-child(9) /* Net Connections */ {
    display: none;
  }
  
  .modal-card {
    height: 90vh;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.5rem;
  }
  .btn-primary span, .btn-danger span {
    display: none; /* Icon-only on mobile if tight */
  }
  .stat-badge {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
}
