@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --bg:           #080b10;
  --bg2:          #0d1117;
  --surface:      #111827;
  --surface2:     #1a2233;
  --surface3:     #1e2a3a;
  --ink:          #e2e8f0;
  --ink-dim:      #94a3b8;
  --accent:       #22d3a4;
  --accent-glow:  rgba(34, 211, 164, 0.25);
  --accent-dark:  #16a87e;
  --danger:       #f87171;
  --danger-dim:   #fecaca;
  --danger-bg:    rgba(248, 113, 113, 0.12);
  --warn:         #fbbf24;
  --warn-bg:      rgba(251, 191, 36, 0.12);
  --success-bg:   rgba(34, 211, 164, 0.12);
  --line:         rgba(255,255,255,0.07);
  --line2:        rgba(255,255,255,0.12);
  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    18px;
  --shadow-sm:    0 1px 6px rgba(0,0,0,0.4);
  --shadow:       0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.6);
  --transition:   0.18s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(34,211,164,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(99,102,241,0.06) 0%, transparent 60%);
  line-height: 1.6;
}

/* ── Layout ─────────────────────────────────────────────────── */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
  margin-bottom: 32px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #e2e8f0 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.kicker {
  margin: 0 0 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kicker::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.sub {
  margin: 10px 0 0;
  color: var(--ink-dim);
  font-size: 0.95rem;
}

/* ── Auth Panel ─────────────────────────────────────────────── */
.auth-panel {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 460px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(34,211,164,0.04) 0%, transparent 60%);
  pointer-events: none;
}

.auth-title {
  margin: 0 0 18px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.auth-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-input {
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  min-width: 160px;
  flex: 1 1 160px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-input::placeholder { color: var(--ink-dim); }

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Toolbar ────────────────────────────────────────────────── */
.toolbar {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

.muted {
  color: var(--ink-dim);
  font-size: 0.88rem;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  user-select: none;
}

.btn:hover {
  background: var(--surface3);
  border-color: var(--line2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-good {
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
  color: #071512;
  border-color: transparent;
  font-weight: 700;
}

.btn-good:hover {
  background: linear-gradient(135deg, var(--accent) 0%, #4eeece 100%);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(248,113,113,0.25);
}

.btn-danger:hover {
  background: rgba(248,113,113,0.22);
  box-shadow: 0 0 12px rgba(248,113,113,0.2);
}

/* ── Bots Grid ──────────────────────────────────────────────── */
.grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* ── Bot Card ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.card:hover {
  border-color: var(--line2);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card:hover::before { opacity: 1; }

/* Card Header */
.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.meta {
  margin: 5px 0;
  color: var(--ink-dim);
  font-size: 0.875rem;
}

.card-head .meta { margin: 0; }

/* Card 3-column layout */
.card-row {
  display: grid;
  grid-template-columns: 260px minmax(180px, 260px) 1fr;
  gap: 18px;
  align-items: start;
}

.card-col { min-width: 0; }

/* ── Skin Viewer Column ──────────────────────────────────────── */
.card-col-model {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* The fixed-size box — canvas MUST stay inside */
.model-wrap {
  width: 260px;
  height: 340px;
  border-radius: var(--radius);
  border: 1px solid var(--line2);
  background:
    radial-gradient(ellipse at 30% 20%, #1e2d4a 0%, #0d1a2e 55%, #080e1a 100%);
  overflow: hidden;          /* ← clips the canvas */
  position: relative;        /* ← stacking context  */
  flex-shrink: 0;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.4), var(--shadow-sm);
}

/* Inner div that skinview3d fills */
.skin-viewer {
  position: absolute;         /* ← fills the wrap exactly */
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--ink-dim);
}

/* Canvas produced by skinview3d — fill the viewer div, no overflow */
.skin-viewer canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  image-rendering: pixelated;
}

/* Fallback head image */
.skin-head {
  width: 80px;
  height: 80px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 8px;
}

/* ── Controls Column ──────────────────────────────────────────── */
.card-col-controls .meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-col-controls .meta::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.7rem;
  opacity: 0.6;
}

.actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions .btn {
  padding: 8px 12px;
  font-size: 0.83rem;
}

/* ── Status Badge ─────────────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.online {
  background: var(--success-bg);
  color: var(--accent);
  border: 1px solid rgba(34,211,164,0.25);
}

.status.online::before {
  animation: pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(34,211,164,0.5);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,211,164,0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(34,211,164,0); }
}

.status.reconnecting,
.status.connecting {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid rgba(251,191,36,0.25);
}

.status.stopped {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.25);
}

/* ── Log Box ──────────────────────────────────────────────────── */
.log-box {
  background: #060a0f;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 220px;
  max-height: 340px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.log-title {
  margin: 0 0 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.log-title::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.6;
}

.log-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--line2) transparent;
}

.log-list::-webkit-scrollbar {
  width: 4px;
}

.log-list::-webkit-scrollbar-thumb {
  background: var(--line2);
  border-radius: 4px;
}

.log-list li {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
}

.log-time {
  color: var(--ink-dim);
  opacity: 0.7;
}

.log-msg {
  color: #94b8a0;
  word-break: break-word;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .card-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card-col-model {
    justify-content: flex-start;
  }

  .model-wrap {
    width: 220px;
    height: 280px;
  }
}

@media (max-width: 520px) {
  .page { padding: 16px 12px 40px; }
  .model-wrap { width: 180px; height: 240px; }
}
