/* ═══════════════════════════════════════════════════════════════════════════
   Phanterus Control — Design System
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(18, 18, 30, 0.7);
  --bg-card-hover: rgba(25, 25, 40, 0.8);
  --bg-input: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(168, 85, 247, 0.3);
  --text-primary: #f0f0f5;
  --text-secondary: rgba(240, 240, 245, 0.55);
  --text-muted: rgba(240, 240, 245, 0.3);
  --accent-purple: #a855f7;
  --accent-indigo: #6366f1;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-green: #22c55e;
  --accent-yellow: #eab308;
  --accent-red: #ef4444;
  --accent-orange: #f97316;
  --gradient-main: linear-gradient(135deg, #a855f7, #6366f1);
  --gradient-glow: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(99, 102, 241, 0.08));
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--border);
  --shadow-glow: 0 0 40px rgba(168, 85, 247, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(168, 85, 247, 0.3);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ═══════ LOGIN PAGE ═══════════════════════════════════════════════════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%);
}

.login-particles {
  position: absolute;
  inset: 0;
}

.particle {
  position: absolute;
  background: var(--accent-purple);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0);
  }

  10% {
    opacity: 0.6;
  }

  90% {
    opacity: 0.1;
  }

  100% {
    opacity: 0;
    transform: translateY(-120px) scale(1);
  }
}

.login-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-card {
  width: 100%;
  background: var(--bg-card);
  backdrop-filter: blur(40px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  animation: cardAppear 0.6s ease-out;
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.logo-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {

  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.3));
  }

  50% {
    filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.5));
  }
}

.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo h1 span {
  font-weight: 400;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition);
}

.input-wrapper input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input-wrapper input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12);
}

.input-wrapper input:focus+.input-icon,
.input-wrapper input:focus~.input-icon {
  color: var(--accent-purple);
}

.input-wrapper:has(input:focus) .input-icon {
  color: var(--accent-purple);
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
  animation: shake 0.3s ease-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-6px);
  }

  75% {
    transform: translateX(6px);
  }
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--gradient-main);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-login:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.3);
}

.btn-login:active:not(:disabled) {
  transform: translateY(0);
}

.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.spinner {
  width: 20px;
  height: 20px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-footer {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

/* ═══════ DASHBOARD ═══════════════════════════════════════════════════════ */

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-title span {
  font-weight: 400;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.server-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  transition: all var(--transition);
}

.server-status-badge.online {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.2);
  color: var(--accent-green);
}

.server-status-badge.starting {
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(234, 179, 8, 0.2);
  color: var(--accent-yellow);
  animation: pulse-starting 1.5s ease-in-out infinite;
}

@keyframes pulse-starting {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    box-shadow: 0 0 0 0 currentColor;
  }

  50% {
    box-shadow: 0 0 0 4px transparent;
  }
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

/* Main Content */
.dashboard-main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.section-header {
  margin-bottom: 16px;
}

.section-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}

.metric-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.metric-card:hover::before {
  opacity: 1;
}

#cpuCard::before {
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-indigo));
}

#ramCard::before {
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
}

#diskCard::before {
  background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
}

#netCard::before {
  background: linear-gradient(90deg, var(--accent-orange), var(--accent-yellow));
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  padding: 6px;
}

.cpu-icon {
  color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.1);
}

.ram-icon {
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

.disk-icon {
  color: var(--accent-green);
  background: rgba(34, 197, 94, 0.1);
}

.net-icon {
  color: var(--accent-orange);
  background: rgba(249, 115, 22, 0.1);
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.net-value {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.net-direction {
  color: var(--text-muted);
  font-weight: 400;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

.metric-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
  width: 0;
}

.cpu-bar {
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-indigo));
}

.ram-bar {
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
}

.disk-bar {
  background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
}

.net-bar {
  background: linear-gradient(90deg, var(--accent-orange), var(--accent-yellow));
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header h3 svg {
  color: var(--accent-purple);
}

.card-body {
  padding: 20px;
}

/* Info rows */
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.info-value {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

.status-badge {
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
}

.status-badge.online {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.2);
  color: var(--accent-green);
}

.status-badge.starting {
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(234, 179, 8, 0.2);
  color: var(--accent-yellow);
  animation: pulse-starting 1.5s ease-in-out infinite;
}

/* TPS */
.tps-display {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.tps-circle {
  position: relative;
  width: 120px;
  height: 120px;
}

.tps-circle svg {
  width: 100%;
  height: 100%;
}

.tps-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tps-value span {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tps-value small {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* Copy row & IP box */
.ip-box {
  margin-bottom: 16px;
}

.ip-box label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.copy-row input,
.copy-row .input-wrapper {
  flex: 1;
}

.copy-row>input,
.copy-row .input-wrapper input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
}

.btn-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-copy:hover {
  background: rgba(168, 85, 247, 0.1);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.btn-copy.copied {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

/* Server Controls */
.server-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  flex: 1;
}

.btn-start:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--accent-green);
}

.btn-restart:hover {
  background: rgba(249, 115, 22, 0.1);
  border-color: rgba(249, 115, 22, 0.3);
  color: var(--accent-orange);
}

.btn-stop:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

/* FTP */
.ftp-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ftp-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ftp-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 90px;
}

/* FTP Open Button */
.ftp-open-btn {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.btn-ftp-open {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(168, 85, 247, 0.3);
  background: rgba(168, 85, 247, 0.08);
  color: var(--accent-purple);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-ftp-open:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.15);
}

/* Bottom Grid */
.bottom-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
}

/* Console */
.console-card {
  display: flex;
  flex-direction: column;
}

.console-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 0;
}

.console-output {
  flex: 1;
  min-height: 300px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
}

.console-output div {
  padding: 1px 0;
  word-break: break-all;
}

.console-welcome {
  color: var(--accent-purple);
}

.console-input-row {
  display: flex;
  align-items: center;
  padding: 0;
  border-top: 1px solid var(--border);
}

.console-prompt {
  padding: 12px;
  padding-right: 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent-purple);
  font-weight: 700;
  user-select: none;
}

.console-input-row input {
  flex: 1;
  padding: 12px 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
}

.btn-send {
  border: none;
  background: transparent;
  color: var(--accent-purple);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-send:hover {
  color: var(--accent-indigo);
  background: rgba(168, 85, 247, 0.08);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: white;
  z-index: 1000;
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.2s forwards;
  pointer-events: none;
}

.toast.success {
  background: var(--accent-green);
}

.toast.error {
  background: var(--accent-red);
}

.toast.info {
  background: var(--accent-purple);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ═══════ Responsive ═══════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-main {
    padding: 16px;
  }
}