/* =========================================
   RESET & TOKENS
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg:            #070913;
  --bg2:           #0c1021;
  --sidebar-bg:    rgba(10, 13, 28, 0.95);
  --card-bg:       rgba(16, 20, 40, 0.6);
  --card-border:   rgba(255, 255, 255, 0.07);
  --card-glow:     rgba(99, 102, 241, 0.12);

  --primary:       #6366f1;
  --primary-dim:   rgba(99, 102, 241, 0.15);
  --primary-glow:  rgba(99, 102, 241, 0.45);
  --cyan:          #22d3ee;
  --cyan-dim:      rgba(34, 211, 238, 0.15);
  --green:         #10b981;
  --green-dim:     rgba(16, 185, 129, 0.15);
  --red:           #f43f5e;
  --red-dim:       rgba(244, 63, 94, 0.15);
  --amber:         #f59e0b;

  --text:          #f0f4ff;
  --text-muted:    #7c8db5;
  --text-faint:    #3d4f7c;

  --radius-sm:     10px;
  --radius-md:     16px;
  --radius-lg:     22px;
  --sidebar-w:     230px;
}

html, body {
  height: 100%;
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* =========================================
   SCROLLBARS
   ========================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* =========================================
   LOGIN SCREEN
   ========================================= */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 20% 50%, #1a0f3c 0%, transparent 55%),
              radial-gradient(ellipse at 80% 20%, #0a2040 0%, transparent 50%),
              var(--bg);
}

.login-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  animation: orbFloat 10s ease-in-out infinite alternate;
}
.orb1 { width: 400px; height: 400px; background: rgba(99,102,241,0.18); top: -100px; left: -100px; }
.orb2 { width: 350px; height: 350px; background: rgba(34,211,238,0.12); bottom: -80px; right: -80px; animation-delay: -5s; }

@keyframes orbFloat {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.05); }
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(12, 16, 33, 0.8);
  backdrop-filter: blur(24px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04) inset;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.login-logo {
  font-size: 2.8rem;
  text-align: center;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px rgba(99,102,241,0.5));
}

.login-title {
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.15;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #a78bfa, var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 32px;
}

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 13px 16px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus {
  border-color: var(--primary);
  background: rgba(0,0,0,0.5);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.btn-full { width: 100%; margin-bottom: 12px; }

.btn-primary, .btn-secondary, .btn-success, .btn-danger, .btn-ghost {
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 12px 22px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 16px var(--primary-glow); }
.btn-primary:hover { background: #4f46e5; transform: translateY(-1px); box-shadow: 0 6px 20px var(--primary-glow); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-ghost:hover { background: var(--primary-dim); }

.btn-secondary { background: rgba(255,255,255,0.08); color: var(--text-muted); }
.btn-secondary:hover { background: rgba(255,255,255,0.14); color: var(--text); }

.btn-success { background: var(--green); color: #fff; box-shadow: 0 4px 16px rgba(16,185,129,0.35); }
.btn-success:hover { background: #059669; transform: translateY(-1px); }
.btn-success:active { transform: scale(0.97); }

.btn-danger { background: var(--red); color: #fff; box-shadow: 0 4px 16px rgba(244,63,94,0.35); }
.btn-danger:hover { background: #e11d48; transform: translateY(-1px); }
.btn-danger:active { transform: scale(0.97); }

.login-error {
  color: var(--red);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 8px;
  padding: 10px;
  background: var(--red-dim);
  border-radius: var(--radius-sm);
}

/* =========================================
   DASHBOARD SHELL
   ========================================= */
.dashboard {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  backdrop-filter: blur(20px);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  margin-bottom: 32px;
}
.logo-icon { font-size: 1.8rem; filter: drop-shadow(0 0 10px rgba(99,102,241,0.6)); }
.logo-text { font-size: 1.2rem; font-weight: 800; background: linear-gradient(135deg, #a78bfa, var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(34,211,238,0.1));
  color: #fff;
  box-shadow: 0 0 0 1px rgba(99,102,241,0.3);
}
.nav-icon { font-size: 1.05rem; width: 20px; text-align: center; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid var(--card-border);
  margin-top: 16px;
}
.sidebar-avatar { font-size: 1.3rem; }
#sidebar-username { flex: 1; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem;
  padding: 4px; border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.logout-btn:hover { color: var(--red); background: var(--red-dim); }

/* MAIN CONTENT */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 70% 10%, rgba(99,102,241,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 10% 80%, rgba(34,211,238,0.05) 0%, transparent 45%),
              var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  background: rgba(7, 9, 19, 0.85);
  backdrop-filter: blur(16px);
  z-index: 10;
}
.page-title { font-size: 1.25rem; font-weight: 700; }
.topbar-status { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; padding: 6px 14px; border-radius: 20px; border: 1px solid var(--card-border); background: var(--card-bg); }

/* Status dot */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.running { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse-dot 2s infinite; }
.status-dot.stopped { background: var(--red); }
.status-dot.loading { background: var(--text-faint); animation: blink 1.5s infinite; }
@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* PAGES */
.page { display: none; padding: 28px; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* CARDS */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.card:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.2);
}
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.card-sub { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px; }

/* OVERVIEW GRID */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 20px;
}
.hero-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 28px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(34,211,238,0.06));
  border-color: rgba(99,102,241,0.25);
}
.hero-icon {
  font-size: 5rem;
  filter: drop-shadow(0 0 24px rgba(99,102,241,0.5));
  animation: float 5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.hero-info { flex: 1; }
.hero-status-text {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}
.hero-status-text.running { color: var(--green); text-shadow: 0 0 20px rgba(16,185,129,0.4); }
.hero-status-text.stopped { color: var(--red); }
.hero-status-text.loading { color: var(--text-muted); }

.hero-stats { display: flex; gap: 24px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--cyan); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-actions button { padding: 10px 20px; }

/* PLAYERS */
.players-list, .players-list-full {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}
.player-avatar { font-size: 1.2rem; }
.player-empty {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 12px 0;
  text-align: center;
}

/* TOGGLE */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
}
.toggle-label-text { font-weight: 500; font-size: 0.9rem; }

.toggle-switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 30px;
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toggle-switch input:checked + .slider { background: var(--primary); box-shadow: 0 0 12px var(--primary-glow); }
.toggle-switch input:checked + .slider::before { transform: translateX(22px); }

/* CONSOLE */
.console-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  box-shadow: 0 0 20px rgba(99,102,241,0.1);
}
.console-prefix { color: var(--cyan); font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }
.console-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 14px 0 !important;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}
.console-input:focus { box-shadow: none !important; }

.cmd-output {
  margin-top: 14px;
  padding: 14px 16px;
  background: rgba(0,0,0,0.4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--cyan);
  white-space: pre-wrap;
  word-break: break-all;
}

/* MODS */
.mods-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.mod-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: monospace;
}
.mod-icon { font-size: 1.1rem; }

.upload-area {
  position: relative;
  border: 2px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-dim); color: var(--text); }
.upload-area input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* TEXTAREA OVERRIDES */
textarea {
  resize: vertical;
  min-height: 180px;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
}

/* =========================================
   SIDEBAR ROLE BADGE
   ========================================= */
.sidebar-user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#sidebar-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 2px;
  display: inline-block;
  width: fit-content;
}
.role-badge-viewer  { background: rgba(148,163,184,0.15); color: #94a3b8; }
.role-badge-starter { background: rgba(34,211,238,0.15);  color: var(--cyan); }
.role-badge-full    { background: rgba(99,102,241,0.15);   color: #a78bfa; }
.role-badge-admin   { background: rgba(244,63,94,0.15);    color: #fb7185; }

/* =========================================
   USER MANAGEMENT
   ========================================= */
.create-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}
.create-user-form input { margin-bottom: 0; }
.create-user-form button { grid-column: 1 / -1; }

.role-select, .role-select-inline {
  width: 100%;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 12px 14px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}
.role-select:focus, .role-select-inline:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.users-table-wrap { overflow-x: auto; }
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.users-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  border-bottom: 1px solid var(--card-border);
}
.users-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  vertical-align: middle;
}
.users-table tr:last-child td { border-bottom: none; }
.users-table tr:hover td { background: rgba(255,255,255,0.02); }
.self-row td { background: rgba(99,102,241,0.05); }

.user-name { font-weight: 600; }
.you-badge {
  margin-left: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--primary-dim);
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.date-cell { color: var(--text-muted); font-size: 0.82rem; }
.text-muted { color: var(--text-faint); }

/* Role chips (read-only display) */
.role-chip {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}
.role-chip-viewer  { background: rgba(148,163,184,0.15); color: #94a3b8; }
.role-chip-starter { background: rgba(34,211,238,0.15);  color: var(--cyan); }
.role-chip-full    { background: rgba(99,102,241,0.15);   color: #a78bfa; }
.role-chip-admin   { background: rgba(244,63,94,0.15);    color: #fb7185; }

/* Inline role select in the table */
.role-select-inline {
  padding: 6px 10px;
  font-size: 0.82rem;
  width: auto;
  min-width: 160px;
}

.btn-delete {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(244,63,94,0.3);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-delete:hover { background: var(--red); color: #fff; }
.btn-delete:active { transform: scale(0.96); }
