/* ---------------------------------------------------------
   KaktusBOX — motyw "pustynna noc"
   Paleta budowana wokół cieplej, brązowo-czarnej nocy pustynnej,
   zamiast typowego neonowo-zielonego "hacker black".
--------------------------------------------------------- */
:root {
  --bg: #171310;
  --bg-glow-1: #2c2015;
  --bg-glow-2: #1c2318;
  --surface: #201a15;
  --surface-2: #291f18;
  --border: #3a2e23;
  --border-soft: #2c231b;
  --text: #f4ead8;
  --muted: #a9906f;
  --muted-dim: #7d6b53;

  --cactus: #5fa86f;
  --cactus-bright: #8fd39b;
  --sun: #e2914f;
  --danger: #d1594a;
  --danger-bg: rgba(209, 89, 74, 0.14);
  --ok-bg: rgba(95, 168, 111, 0.16);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Manrope', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', monospace;

  --discord: #5865f2;
  --discord-bright: #7289fa;

  --radius: 12px;
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 900px 500px at 18% -8%, var(--bg-glow-1) 0%, transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, var(--bg-glow-2) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.grad {
  background: linear-gradient(90deg, var(--cactus-bright), var(--cactus));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

h1 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }

a, button, input { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--cactus-bright);
  outline-offset: 2px;
}

/* ---------- login ---------- */

#login-view {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  padding: 24px;
}

.desert-scene {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46vh;
  min-height: 300px;
  z-index: 0;
  pointer-events: none;
}
.desert-scene svg { width: 100%; height: 100%; display: block; }
.desert-scene .star {
  fill: #f4ead8;
  opacity: 0.5;
  animation: twinkle 4.5s ease-in-out infinite;
}
.desert-scene .star:nth-child(3n) { animation-delay: 1.1s; }
.desert-scene .star:nth-child(4n) { animation-delay: 2.3s; }
@keyframes twinkle {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.7; }
}
.desert-scene .moon {
  fill: #f3e6c8;
  opacity: 0.85;
  filter: drop-shadow(0 0 30px rgba(243, 230, 200, 0.3));
}
.desert-scene .dune {
  fill: var(--surface);
  opacity: 0.95;
}
.desert-scene .cactus-group use {
  stroke: #3c5a3f;
  opacity: 0.8;
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 34px 32px;
  width: 340px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.brand-mark {
  color: var(--cactus-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

.login-card h1 { margin: 0 0 4px; font-size: 27px; }
.sub { color: var(--muted); margin: 0 0 26px; font-size: 13px; }

.field { text-align: left; margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-dim);
  margin-bottom: 6px;
  font-weight: 600;
}

input[type="text"], input[type="password"] {
  width: 100%;
  background: #16110d;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: 9px;
  font-size: 14px;
  transition: border-color 0.15s ease;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--cactus);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 9px;
  padding: 11px 16px;
  font-weight: 600;
  font-size: 14px;
  background: linear-gradient(90deg, var(--cactus-bright), var(--cactus));
  color: #0f1a10;
  transition: transform 0.12s ease, filter 0.12s ease;
  width: 100%;
  margin-top: 6px;
}
button:hover { filter: brightness(1.07); transform: translateY(-1px); }
button:active { transform: translateY(0); }

.ghost-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: auto;
  margin-top: 0;
}
.ghost-btn:hover { filter: none; background: var(--border-soft); border-color: var(--muted-dim); }

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
  margin-top: 12px;
  margin-bottom: 0;
}

/* ---------- app shell ---------- */

.view { animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .brand-mark { width: 38px; height: 38px; margin-bottom: 0; border-radius: 10px; }
header h1 { font-size: 19px; margin: 0; display: flex; gap: 8px; align-items: baseline; }
.sub-inline { color: var(--muted); font-weight: 400; font-size: 13px; font-family: var(--font-body); }

.header-right { display: flex; align-items: center; gap: 14px; }
.switch-group { display: flex; align-items: center; gap: 9px; }
.switch-label { font-size: 13px; color: var(--muted); min-width: 92px; font-weight: 500; }

.ghost-btn { padding: 9px 16px; }

.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #3a2620; border-radius: 24px; transition: 0.2s;
}
.slider::before {
  content: ""; position: absolute; height: 17px; width: 17px; left: 3px; top: 3px;
  background: #f4ead8; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: #2c5236; }
.switch input:checked + .slider::before { transform: translateX(17px); background: var(--cactus-bright); }

/* ---------- stats strip ---------- */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 20px 28px 0;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--cactus-bright);
}
.stat-label { font-size: 12px; color: var(--muted); }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 4px; padding: 22px 28px 0; border-bottom: 1px solid var(--border-soft); }
.tab-btn {
  background: transparent; color: var(--muted); border: none;
  padding: 10px 4px; margin-right: 22px; font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent; border-radius: 0; width: auto; margin-top: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab-btn:hover { color: var(--text); filter: none; transform: none; }
.tab-btn.active { color: var(--cactus-bright); border-bottom-color: var(--cactus); font-weight: 600; }

.tab-content { padding: 22px 28px 40px; }

/* ---------- table ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
th {
  color: var(--muted-dim); font-weight: 600; text-transform: uppercase;
  font-size: 10.5px; letter-spacing: 0.06em; background: var(--surface-2);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }

.player-cell { display: flex; align-items: center; gap: 10px; }
.player-avatar {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--cactus), #2c5236);
  color: #0f1a10; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.badge.ok { background: var(--ok-bg); color: var(--cactus-bright); }
.badge.locked { background: var(--danger-bg); color: var(--danger); }

.action-btn {
  font-size: 12px; padding: 6px 11px; margin-right: 6px; width: auto; margin-top: 0;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  font-weight: 500;
}
.action-btn:hover { filter: none; background: var(--border-soft); }
.action-btn.danger { border-color: rgba(209,89,74,0.4); color: var(--danger); background: transparent; }
.action-btn.danger:hover { background: var(--danger-bg); }
.action-btn.ok { border-color: rgba(95,168,111,0.4); color: var(--cactus-bright); background: transparent; }
.action-btn.ok:hover { background: var(--ok-bg); }

/* ---------- empty states ---------- */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
}
.empty-icon { color: var(--muted-dim); margin-bottom: 10px; }
.empty-state p { margin: 0; font-size: 13.5px; }

/* ---------- console ---------- */

.console-box {
  background: #120e0b; border: 1px solid var(--border-soft); border-radius: var(--radius);
  height: 380px; overflow-y: auto; padding: 16px; font-family: var(--font-mono);
  font-size: 13px; margin-bottom: 12px; white-space: pre-wrap; line-height: 1.6;
}
.console-hint { color: var(--muted-dim); }
.console-input-row { display: flex; gap: 10px; }
.console-input-row input { margin-bottom: 0; font-family: var(--font-mono); }
.console-input-row button { flex-shrink: 0; width: auto; margin-top: 0; }
.console-prompt {
  display: flex; align-items: center; padding: 0 4px; color: var(--cactus-bright);
  font-family: var(--font-mono); font-weight: 700;
}

/* ---------- logs ---------- */

#logs-list .log-item {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 13px 16px; margin-bottom: 8px; font-size: 13.5px;
}
#logs-list .log-item .log-title { font-weight: 700; color: var(--cactus-bright); }
#logs-list .log-item .log-time { color: var(--muted-dim); font-size: 11px; float: right; font-family: var(--font-mono); }
#logs-list .log-item div:last-child { color: var(--muted); margin-top: 4px; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 8, 6, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  animation: fade-in 0.15s ease; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px; width: 360px; box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: 18px; margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.modal input { margin-bottom: 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { margin-top: 0; }

/* ---------- toasts ---------- */

#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease; max-width: 320px;
}
.toast.success { border-color: rgba(95,168,111,0.4); }
.toast.error { border-color: rgba(209,89,74,0.4); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  header { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px 18px; }
  .header-right { width: 100%; justify-content: space-between; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); padding: 16px 18px 0; }
  .tabs { padding: 18px 18px 0; }
  .tab-content { padding: 18px 18px 32px; }
}

/* ---------- discord login ---------- */

.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted-dim); font-size: 12px; margin: 18px 0;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.discord-btn {
  width: 100%; padding: 11px 16px; border-radius: 9px; font-weight: 600; font-size: 14px;
  background: var(--discord); color: #fff; align-items: center; justify-content: center;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.discord-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ---------- toolbar / szukajka ---------- */

.toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 9px;
  padding: 0 12px; width: 100%; max-width: 300px; color: var(--muted-dim);
}
.search-box input {
  border: none; background: transparent; padding: 9px 0; margin-bottom: 0;
}
.search-box input:focus { border: none; outline: none; }

.clickable-row { cursor: pointer; }

/* ---------- bany IP ---------- */

.ipban-form { display: flex; gap: 10px; margin-bottom: 16px; }
.ipban-form input { margin-bottom: 0; }
.ipban-form input#ipban-ip { max-width: 220px; }
.ipban-form button { width: auto; flex-shrink: 0; margin-top: 0; }

#ipbans-list { display: flex; flex-direction: column; gap: 8px; }
.ipban-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 13px 16px;
}
.ipban-ip { font-family: var(--font-mono); font-weight: 600; color: var(--text); font-size: 14px; }
.ipban-reason { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

/* ---------- presety konsoli ---------- */

.command-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.preset-btn {
  width: auto; margin-top: 0; padding: 7px 13px; font-size: 12.5px; font-weight: 500;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.preset-btn:hover { filter: none; color: var(--text); background: var(--border-soft); }

/* ---------- modal szczegółów gracza ---------- */

.detail-modal { width: 400px; }
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.detail-avatar {
  width: 52px; height: 52px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border-soft); image-rendering: pixelated;
}
.detail-head h2 { margin: 0 0 6px; font-size: 18px; }

.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px;
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
}
.detail-grid .full { grid-column: 1 / -1; }
.detail-grid .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-dim); margin-bottom: 3px; font-weight: 600; }
.detail-grid .v { font-size: 13.5px; color: var(--text); word-break: break-word; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.detail-actions .action-btn { margin-right: 0; }

.reset-link-box {
  margin-top: 14px; padding: 12px 14px; background: var(--surface-2);
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  font-size: 12.5px; color: var(--muted);
}
.reset-link-box .link-row { display: flex; gap: 8px; margin-top: 8px; }
.reset-link-box input {
  font-family: var(--font-mono); font-size: 12px; margin-bottom: 0;
}
.reset-link-box button { width: auto; flex-shrink: 0; margin-top: 0; padding: 9px 14px; font-size: 12.5px; }

@media (max-width: 480px) {
  .detail-modal { width: 100%; }
  .ipban-form { flex-wrap: wrap; }
  .ipban-form input#ipban-ip { max-width: none; }
}
