﻿@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-dark: #070a13;
  --bg-card: rgba(15, 23, 42, 0.72);
  --bg-card-hover: rgba(24, 34, 58, 0.85);
  --bg-panel: #0d1322;
  --bg-input: rgba(11, 17, 32, 0.85);

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-focus: #38bdf8;
  --border-highlight: rgba(56, 189, 248, 0.35);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --color-online: #10b981;
  --color-online-glow: rgba(16, 185, 129, 0.28);
  --color-starting: #f59e0b;
  --color-starting-glow: rgba(245, 158, 11, 0.28);
  --color-stopping: #f97316;
  --color-offline: #64748b;
  --color-danger: #ef4444;
  --color-danger-glow: rgba(239, 68, 68, 0.25);
  --color-primary: #38bdf8;
  --color-indigo: #6366f1;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.15);
  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* NAVBAR */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: rgba(7, 10, 19, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0284c7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  /* Wichtig, damit das Bild nicht über die runden Ecken ragt */
}

/* Neu: Regelt die Größe des Bildes im Container */
.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Passt das Bild perfekt ein */
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  color: var(--color-primary);
  border: 1px solid rgba(56, 189, 248, 0.25);
  margin-left: 0.4rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

.role-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-admin {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.role-user {
  background: rgba(14, 165, 233, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(14, 165, 233, 0.4);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: white;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-admin-toggle {
  background: rgba(56, 189, 248, 0.1) !important;
  border-color: rgba(56, 189, 248, 0.4) !important;
  color: #38bdf8 !important;
  font-weight: 600 !important;
}

.btn-admin-toggle:hover {
  background: rgba(56, 189, 248, 0.2) !important;
  border-color: rgba(56, 189, 248, 0.6) !important;
  color: #7dd3fc !important;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25) !important;
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: white;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #be123c, #9f1239);
  box-shadow: 0 4px 14px var(--color-danger-glow);
}

.btn-icon {
  padding: 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* POWER BUTTONS */
.power-btn {
  padding: 0.48rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
}

.power-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-start {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.btn-start:hover:not(:disabled) {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 0 16px var(--color-online-glow);
  transform: translateY(-1px);
}

.btn-restart {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.btn-restart:hover:not(:disabled) {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
  transform: translateY(-1px);
}

.btn-stop {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-stop:hover:not(:disabled) {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 0 16px var(--color-danger-glow);
  transform: translateY(-1px);
}

/* CONTAINER */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem;
}

/* STATS HERO BAR */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-val {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* CONTROLS HEADER */
.controls-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-box {
  position: relative;
  min-width: 280px;
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem 0.6rem 2.4rem;
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(15, 23, 42, 0.5);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.filter-btn {
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-weight: 600;
}

.refresh-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.live-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-online);
  box-shadow: 0 0 8px var(--color-online);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* SERVER GRID */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
}

.server-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
}

.server-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-card);
  transform: translateY(-3px);
}

.card-header {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.server-identity {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.server-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.server-names {
  min-width: 0;
}

.server-name {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.server-game {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.server-id-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

/* STATUS CONTAINER & UPTIME */
.status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.uptime-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1;
  text-align: center;
}

/* STATUS BADGE */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: capitalize;
  flex-shrink: 0;
}

.status-badge.status-running {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.status-badge.status-running .status-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-ring 2s infinite;
}

.status-badge.status-starting {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.status-badge.status-starting .status-dot {
  background: #f59e0b;
  animation: spin 1.5s linear infinite;
}

.status-badge.status-offline {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.25);
}

.status-badge.status-offline .status-dot {
  background: #64748b;
}

.status-badge.status-stopping {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.28);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

#manual-refresh-btn {
  width: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  height: 34px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
}

#refresh-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  line-height: 1;
  text-align: center;
  transform-origin: center center;
  transition: transform 0.2s ease;
  font-size: 0.95rem;
}

.spin-anim,
#refresh-spinner.spinning {
  animation: spin 0.75s linear infinite !important;
}

.panel-card {
  transition: border-color 0.2s ease, background 0.2s ease;
}

.panel-card:hover {
  border-color: rgba(56, 189, 248, 0.4) !important;
  background: rgba(255, 255, 255, 0.04) !important;
}

/* CARD BODY & GAUGES */
.card-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.metric-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

.metric-label {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.metric-val {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-main);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-cpu {
  background: linear-gradient(90deg, #38bdf8, #6366f1);
}

.progress-ram {
  background: linear-gradient(90deg, #10b981, #06b6d4);
}

.progress-ram.danger {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.player-stat-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.player-count-val {
  font-size: 0.9rem;
  font-weight: 600;
  color: #38bdf8;
  font-family: var(--font-mono);
}

/* CARD ACTIONS */
.card-actions {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(7, 10, 19, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.power-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* TABS (ADMIN) */
.tabs-header {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2rem;
  padding-bottom: 0.2rem;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--color-primary);
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -0.2rem;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* TABLES (ADMIN) */
.admin-table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.admin-table th {
  background: rgba(11, 17, 32, 0.85);
  padding: 0.9rem 1.2rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.admin-table td {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* TOGGLE SWITCH */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked+.toggle-slider {
  background-color: var(--color-online);
}

input:checked+.toggle-slider:before {
  transform: translateX(20px);
}

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  padding: 1.5rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: scale(0.95);
  transition: var(--transition);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.modal-footer {
  padding: 1.2rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(7, 10, 19, 0.3);
}

/* FORMS */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

/* TOASTS */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #111827;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.25rem;
  color: var(--text-main);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success {
  border-left: 4px solid var(--color-online);
}

.toast-error {
  border-left: 4px solid var(--color-danger);
}

.toast-info {
  border-left: 4px solid var(--color-primary);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* CHECKBOX LIST (SERVER ASSIGNMENT) */
.assignment-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.assignment-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.assignment-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.assignment-item input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   RESPONSIVE MOBILE DESIGN (SMARTPHONE & TABLET)
   ========================================================================== */
html,
body {
  overflow-x: clip;
  max-width: 100%;
  width: 100%;
}

img,
svg,
video {
  max-width: 100%;
}

@media (max-width: 768px) {

  /* NAVBAR */
  .navbar {
    padding: 0.6rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .brand {
    gap: 0.55rem;
    flex-shrink: 0;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
  }

  .brand-text h1 {
    font-size: 1.05rem;
  }

  .brand-badge {
    display: none;
  }

  .nav-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .refresh-control {
    padding: 0.18rem 0.3rem 0.18rem 0.5rem;
    gap: 0.3rem;
  }

  #refresh-interval-select {
    padding: 0.2rem 0.35rem !important;
    font-size: 0.72rem !important;
    max-width: 80px;
  }

  #lang-switch-btn {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.76rem !important;
  }

  #view-mode-btn {
    padding: 0.4rem 0.65rem !important;
  }

  #view-mode-btn #view-mode-text {
    display: none;
  }

  .user-badge {
    padding: 0.25rem 0.5rem;
    gap: 0.35rem;
    font-size: 0.78rem;
  }

  .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 0.72rem;
  }

  .user-badge span:not(.user-avatar) {
    max-width: 65px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .role-pill {
    display: none;
  }

  #manual-refresh-btn,
  #profile-btn,
  #logout-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.88rem !important;
  }

  /* MAIN CONTAINER */
  .container {
    padding: 0.85rem 0.65rem;
    max-width: 100%;
    overflow-x: clip;
  }

  /* STATS BAR */
  .stats-bar {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1.15rem;
  }

  .stat-card {
    padding: 0.65rem 0.75rem;
    gap: 0.55rem;
    min-width: 0;
    overflow: hidden;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  .stat-val {
    font-size: 1.25rem;
    line-height: 1.1;
  }

  .stat-label {
    font-size: 0.7rem;
    line-height: 1.25;
    word-break: break-word;
  }

  /* CONTROLS & FILTERS */
  .controls-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    margin-bottom: 1.15rem;
  }

  .search-box {
    width: 100%;
    min-width: 0;
  }

  .search-input {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px !important;
    /* Prevents mobile iOS zoom */
  }

  .filter-pills {
    width: 100%;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.25rem;
    gap: 0.35rem;
    box-sizing: border-box;
  }

  .filter-pills::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex-shrink: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
  }

  /* SERVER CARDS */
  .server-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    width: 100%;
    min-width: 0;
  }

  .server-card {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
  }

  .card-header {
    padding: 0.85rem 0.95rem;
    gap: 0.5rem;
    min-width: 0;
  }

  .server-identity {
    flex: 1;
    min-width: 0;
    gap: 0.65rem;
  }

  .server-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .server-names {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .server-name {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .server-game {
    font-size: 0.74rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    gap: 0.35rem;
  }

  .server-game span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  .server-id-tag {
    font-size: 0.68rem;
    padding: 0.08rem 0.35rem;
    flex-shrink: 0;
  }

  .status-container {
    flex-shrink: 0;
  }

  .status-badge {
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    gap: 0.35rem;
  }

  .card-body {
    padding: 0.85rem 0.95rem;
    gap: 0.65rem;
  }

  .player-stat-badge {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  /* CARD ACTIONS & POWER BUTTONS */
  .card-actions {
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
  }

  .power-group {
    flex: 1;
    min-width: 170px;
    display: flex;
    gap: 0.3rem;
  }

  .power-btn {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.35rem;
    font-size: 0.76rem;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    gap: 0.25rem;
  }

  .btn-card-console {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .admin-card-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-shrink: 0;
  }

  .admin-card-actions .btn {
    width: 34px;
    height: 34px;
  }

  /* MODALS ON MOBILE */
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 94vh !important;
    margin: auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-radius: var(--radius-md) !important;
  }

  .modal-content form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }

  .modal-header {
    padding: 0.85rem 1rem !important;
    flex-shrink: 0;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  .modal-body {
    padding: 1rem !important;
    gap: 0.85rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
  }

  .modal-footer {
    padding: 0.8rem 1rem !important;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* MODAL GRID FIELD COLLAPSE */
  #server-modal div[style*="grid"],
  .modal-body div[style*="grid"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    width: 100%;
    min-width: 0;
  }

  .form-group {
    width: 100%;
    min-width: 0;
  }

  .form-input,
  .form-select,
  .form-textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 16px !important;
    /* Prevents mobile iOS zoom */
  }

  /* ADMIN TAB NAVIGATION & TABLES */
  .admin-panel-header {
    position: sticky;
    top: var(--navbar-height, 58px);
    z-index: 90;
    background: rgba(7, 10, 19, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    scrollbar-width: none;
    padding-top: 0.5rem;
    padding-bottom: 0.35rem;
    margin-bottom: 1.25rem;
    overflow-x: auto;
    white-space: nowrap;
  }

  .tab-nav {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    padding-bottom: 0.3rem;
    gap: 0.35rem;
  }

  .tab-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex-shrink: 0;
    padding: 0.55rem 0.8rem;
    font-size: 0.8rem;
  }

  .admin-table-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    border-radius: var(--radius-sm);
  }

  .admin-table {
    min-width: 580px;
    width: 100%;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.65rem 0.8rem;
    font-size: 0.78rem;
  }

  .controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  /* ADMIN TAB HEADERS WITH BUTTONS */
  #tab-servers>div:first-child,
  #tab-users>div:first-child,
  #tab-settings>div:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  #tab-servers>div:first-child>div:last-child,
  #tab-users>div:first-child>div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  #tab-servers>div:first-child .btn,
  #tab-users>div:first-child .btn {
    flex: 1;
    min-width: 140px;
    justify-content: center;
  }

  /* PANEL CARDS IN SETTINGS */
  .panel-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    padding: 0.85rem 1rem !important;
  }

  .panel-card>div:first-child {
    min-width: 0 !important;
    width: 100% !important;
  }

  .panel-card>div:last-child {
    width: 100% !important;
    display: flex !important;
    justify-content: flex-end !important;
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.5rem;
  }

  .panel-card code,
  .panel-card div {
    word-break: break-all;
    overflow-wrap: break-word;
  }

  /* DOCKER SERVICE CARDS */
  #tab-settings div[style*="justify-content: space-between"][style*="border-radius: var(--radius-sm)"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    padding: 0.85rem 1rem !important;
  }

  #tab-settings div[style*="justify-content: space-between"][style*="border-radius: var(--radius-sm)"]>div:last-child {
    width: 100% !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.5rem;
    flex-wrap: wrap;
  }

  /* FILE EXPLORER MODAL ON MOBILE */
  #files-modal .modal-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  #files-modal .modal-header>div:last-child {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
  }

  #files-breadcrumbs {
    font-size: 0.75rem !important;
    padding: 0.35rem 0.55rem !important;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  #files-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  #files-container .admin-table {
    min-width: 480px;
  }

  /* TOAST NOTIFICATIONS */
  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    align-items: center;
  }

  .toast {
    min-width: 0;
    width: 100%;
    max-width: 400px;
  }
}

@media (max-width: 560px) {

  /* SMARTPHONE OPTIMIZED SERVER CARD BUTTONS (2-ROW LAYOUT) */
  .card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    padding: 0.65rem 0.75rem;
  }

  .power-group {
    width: 100%;
    order: 1;
    display: flex;
    gap: 0.3rem;
  }

  .power-btn {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.2rem;
    font-size: 0.74rem;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn-card-console {
    order: 2;
    flex: 1;
    height: 35px;
    min-width: 35px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .admin-card-actions {
    order: 3;
    display: flex;
    flex: 2;
    gap: 0.35rem;
    justify-content: flex-end;
  }

  .admin-card-actions .btn {
    flex: 1;
    height: 35px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Single console button if user is not admin */
  .card-actions>.btn-card-console:last-child {
    flex: 1;
    width: 100%;
  }

  /* CONSOLE MODAL ON MOBILE */
  #console-modal .modal-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.75rem 0.9rem;
  }

  #console-modal .modal-header>div:last-child {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.4rem;
  }

  #console-terminal {
    height: 55vh !important;
    max-height: 55vh !important;
    padding: 0.75rem 0.85rem !important;
    font-size: 0.75rem !important;
    word-break: break-all;
  }

  /* FILE VIEWER MODAL ON MOBILE */
  #file-viewer-modal .modal-content {
    height: 94vh !important;
  }

  #file-viewer-content {
    height: calc(94vh - 160px) !important;
    max-height: none !important;
    font-size: 0.75rem !important;
    padding: 0.65rem !important;
  }

  #file-viewer-modal .modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  #file-viewer-modal .modal-footer>div {
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }

  #file-viewer-modal .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }

  /* REGEX MODAL CREATE BOX ON MOBILE */
  #regex-create-server-box {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  #regex-create-server-box #regex-server-identifier {
    width: 100% !important;
  }

  /* PANEL MODAL FOOTER ON MOBILE */
  #panel-modal .modal-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  #panel-modal #panel-test-btn {
    width: 100% !important;
    justify-content: center;
  }

  #panel-modal .modal-footer>div:last-child {
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }

  #panel-modal .modal-footer>div:last-child .btn {
    flex: 1;
    justify-content: center;
  }

  /* SYNC MODAL FOOTER */
  #sync-modal .modal-footer {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  #sync-modal .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  /* CONFIRM & PROMPT MODAL BUTTONS */
  #confirm-modal .modal-footer,
  #prompt-modal .modal-footer {
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }

  #confirm-modal .modal-footer .btn,
  #prompt-modal .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .navbar {
    padding: 0.45rem 0.55rem;
    gap: 0.35rem;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }

  .user-badge span:not(.user-avatar) {
    max-width: 50px;
  }

  #refresh-interval-select {
    max-width: 70px;
  }

  .stats-bar {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .stat-card {
    padding: 0.55rem 0.65rem;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .stat-val {
    font-size: 1.15rem;
  }

  .card-header {
    padding: 0.75rem 0.85rem;
  }

  .status-badge {
    padding: 0.22rem 0.5rem;
    font-size: 0.68rem;
    gap: 0.3rem;
  }

  .uptime-text {
    font-size: 0.66rem !important;
  }
}

@media (max-width: 360px) {
  .user-badge span:not(.user-avatar) {
    display: none;
  }

  #lang-switch-btn span:last-child {
    display: none;
  }

  .power-btn {
    font-size: 0.7rem;
    padding: 0.4rem 0.15rem;
  }
}

/* CONSOLE CARD BUTTON & LANGUAGE SWITCHER */
.btn-card-console {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  transition: var(--transition);
}

.btn-card-console:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
  transform: translateY(-1px);
}

.btn-card-files,
.btn-card-edit {
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  transition: var(--transition);
  font-weight: 500;
}

.btn-card-files:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
  transform: translateY(-1px);
}

.btn-card-edit:hover {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
  transform: translateY(-1px);
}

#file-viewer-content:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25) !important;
}

#lang-switch-btn {
  transition: var(--transition);
}

#lang-switch-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(56, 189, 248, 0.3);
}

/* CONSOLE MODAL FLUSH TERMINAL */
#console-modal .modal-content {
  overflow: hidden;
  padding: 0;
}

#console-modal .modal-body {
  padding: 0;
  margin: 0;
  gap: 0;
  flex: 1;
}

#console-modal #console-terminal {
  border: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin: 0;
  padding: 1.25rem 1.5rem;
  height: 520px;
  max-height: calc(85vh - 75px);
  width: 100%;
  box-sizing: border-box;
}

/* SPIN ANIMATION */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.spin-anim {
  animation: spin 0.8s linear infinite !important;
  display: inline-block;
}

/* TAB NAVIGATION & ADMIN WRAPPER */
.tab-nav,
.admin-panel-header {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2rem;
  padding-bottom: 0.2rem;
}

.admin-panel-wrapper {
  animation: fadeIn 0.25s ease;
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(15, 23, 42, 0.5);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* SERVER EDIT/ADD MODAL OPTIMIZATIONS */
#server-modal .modal-content {
  max-width: 650px !important;
  width: 95%;
  overflow-x: hidden;
  box-sizing: border-box;
}

#server-modal .modal-body {
  overflow-x: hidden;
  box-sizing: border-box;
}

#server-modal .form-group {
  min-width: 0;
}

#server-modal .form-input,
#server-modal .form-select {
  width: 100%;
  box-sizing: border-box;
}

/* CONFIRM, PROMPT & FILE VIEWER MODAL STACKING: Must be higher than other open modals (e.g. #files-modal) */
#confirm-modal {
  z-index: 2500 !important;
}

#prompt-modal {
  z-index: 2600 !important;
}

#file-viewer-modal {
  z-index: 2000 !important;
}

/* STICKY ADMIN PANEL HEADER NAVIGATION */
.admin-panel-header {
  position: sticky;
  top: var(--navbar-height, 75px);
  z-index: 90;
  background: rgba(7, 10, 19, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  scrollbar-width: none;
  padding-top: 0.75rem;
  padding-bottom: 0.5rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  white-space: nowrap;
}

.admin-panel-header .tab-nav {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}