/* Wspólne style: kolory, przyciski, pola, MOTD, statusy */

:root {
  --bg: #0d1013;
  --bg-2: #13171c;
  --card: #171c22;
  --card-2: #1d232b;
  --line: #262e38;
  --line-2: #323c48;
  --text: #e8edf2;
  --muted: #8a96a3;
  --dim: #5d6874;
  --green: #5fd068;
  --green-2: #3fa94a;
  --green-ink: #0b1a0d;
  --red: #ff5f5f;
  --yellow: #ffcc4d;
  --blue: #6aa8ff;
  --orange: #ffb366;
  --motd-bg: #0a0c0e;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
  --radius: 16px;
  --mono: 'VT323', ui-monospace, monospace;
  --pixel: 'Press Start 2P', var(--mono);
  --code: ui-monospace, 'Cascadia Code', Consolas, monospace;
}

[data-theme=light] {
  --bg: #f3f5f8;
  --bg-2: #eef1f5;
  --card: #ffffff;
  --card-2: #ffffff;
  --line: #e1e6ec;
  --line-2: #d0d7e0;
  --text: #151a20;
  --muted: #5f6b78;
  --dim: #95a0ac;
  --green: #2f9e3a;
  --green-2: #23852d;
  --green-ink: #ffffff;
  --red: #d93b3b;
  --yellow: #c78a00;
  --blue: #2f6fd6;
  --orange: #c26a00;
  --shadow: 0 6px 24px rgba(20, 30, 45, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- pola i przyciski ---------- */

.input, input:not([type=radio]):not([type=checkbox]), select, textarea {
  height: 42px;
  padding: 0 14px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
textarea { height: auto; padding: 12px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(95, 208, 104, .18); }
input::placeholder { color: var(--dim); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--card-2);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: transform .1s, filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.primary {
  background: linear-gradient(var(--green), var(--green-2));
  border-color: transparent;
  color: var(--green-ink);
  box-shadow: 0 6px 18px rgba(95, 208, 104, .25), inset 0 -3px 0 rgba(0, 0, 0, .2);
}
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .7; pointer-events: none; }
.btn.loading::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); background: var(--card-2); border-color: var(--line-2); }
.icon-btn.danger:hover { color: var(--red); border-color: rgba(255, 95, 95, .4); }
.icon-btn.active { color: var(--green); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
.icon-btn[disabled] { opacity: .35; pointer-events: none; }

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--card-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.copy-btn:hover { border-color: var(--green); color: var(--green); }
.copy-btn.copied { border-color: var(--green); color: var(--green); background: rgba(95, 208, 104, .1); }

/* ---------- ikona serwera ---------- */

.srv-icon {
  flex: none;
  width: var(--size, 64px);
  height: var(--size, 64px);
  border-radius: calc(var(--size, 64px) / 6);
  background: var(--bg-2) url(favicon.svg) center / 70% no-repeat;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px var(--line-2);
  overflow: hidden;
}
.srv-icon img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.is-offline .srv-icon { filter: grayscale(1) brightness(.75); }

/* ---------- MOTD ---------- */

.motd {
  padding: 10px 14px;
  background: var(--motd-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Crect width='4' height='4' fill='%23ffffff' fill-opacity='.015'/%3E%3Crect x='4' y='4' width='4' height='4' fill='%23ffffff' fill-opacity='.015'/%3E%3C/svg%3E");
  border: 1px solid #000;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
  color: #aaaaaa;
  font: 21px/1.1 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 2px 2px 0 #2a2a2a;
}
.motd:empty::before { content: 'Brak opisu'; color: #555; }
.is-offline .motd { opacity: .45; filter: saturate(.4); }
.mc-b { font-weight: 700; }
.mc-i { font-style: italic; }
.mc-u { text-decoration: underline; }
.mc-s { text-decoration: line-through; }
.mc-u.mc-s { text-decoration: underline line-through; }

/* ---------- status ---------- */

.pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  background: rgba(138, 150, 163, .12);
  color: var(--muted);
  white-space: nowrap;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.online { background: rgba(95, 208, 104, .12); color: var(--green); }
.pill.online i { animation: pulse 2s infinite; }
.pill.offline { background: rgba(255, 95, 95, .12); color: var(--red); }
.pill.pending i { animation: blink 1s infinite; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.online { background: var(--green); animation: pulse 2s infinite; }
.dot.offline { background: var(--red); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--line);
  color: var(--text);
  vertical-align: middle;
}
.badge.java { background: rgba(255, 170, 77, .15); color: var(--orange); }
.badge.bedrock { background: rgba(106, 168, 255, .15); color: var(--blue); }
.badge.auto, .badge.muted { color: var(--muted); }

.bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green-2), var(--green)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }

.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.signal i { width: 4px; border-radius: 1px; background: var(--line-2); }
.signal i:nth-child(1) { height: 25%; }
.signal i:nth-child(2) { height: 50%; }
.signal i:nth-child(3) { height: 75%; }
.signal i:nth-child(4) { height: 100%; }
.signal.q4 i, .signal.q3 i:nth-child(-n+3) { background: var(--green); }
.signal.q2 i:nth-child(-n+2) { background: var(--yellow); }
.signal.q1 i:nth-child(1) { background: var(--red); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--green);
}
.live i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }
.live.off { color: var(--muted); }
.live.off i { animation: blink 1s infinite; }

/* ---------- gracze ---------- */

.players { display: flex; flex-wrap: wrap; gap: 6px; }
.player {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px 0 3px;
  border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 13px;
  max-width: 100%;
}
.player img, .player .face { width: 22px; height: 22px; border-radius: 4px; image-rendering: pixelated; flex: none; }
.player .face { display: grid; place-items: center; background: #3a6b8a; color: #fff; font-size: 11px; font-weight: 700; }
.player.text { padding-left: 10px; font: 18px/1 var(--mono); background: var(--motd-bg); color: #aaa; }
.player.more { color: var(--muted); padding-left: 10px; }

/* ---------- wykres ---------- */

.spark { display: block; width: 100%; height: 64px; overflow: visible; }
.spark .cursor { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }

.tooltip {
  position: fixed;
  z-index: 50;
  padding: 6px 10px;
  border-radius: 8px;
  background: #050607;
  color: #e8edf2;
  border: 1px solid #323c48;
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.tooltip b { color: #5fd068; }
.tooltip .off { color: #ff5f5f; }

/* ---------- powiadomienia ---------- */

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  padding: 10px 16px;
  border-radius: 10px;
  background: #050607;
  color: #e8edf2;
  border: 1px solid #323c48;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: pop .25s ease;
}
.toast.err { border-color: rgba(255, 95, 95, .5); color: #ffb3b3; }
.toast.ok { border-color: rgba(95, 208, 104, .5); }

/* ---------- animacje ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .3; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-2deg); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(95, 208, 104, .6); }
  70% { box-shadow: 0 0 0 7px rgba(95, 208, 104, 0); }
  100% { box-shadow: 0 0 0 0 rgba(95, 208, 104, 0); }
}

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