:root {
  --bg: #eef2ff;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.site-header {
  background: linear-gradient(135deg, #1e1b4b, #4f46e5 60%, #7c3aed);
  color: #fff;
  padding: 24px 0 20px;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.brand .dot { color: #fbbf24; }
.tagline { margin: 4px 0 0; opacity: 0.92; font-size: 15px; }
.clock-box {
  text-align: right;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 8px 18px;
  min-width: 132px;
}
.clock-time { font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.clock-period { font-size: 13px; opacity: 0.9; }

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover { background: #f3f4f6; transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.active { background: #e0e7ff; border-color: var(--accent); color: var(--accent-dark); }
.speed-group, .jump-group { display: flex; gap: 6px; }
#time-slider {
  flex: 1;
  min-width: 160px;
  accent-color: var(--accent);
  cursor: pointer;
}
.slider-label { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.panel h2 { margin: 0 0 12px; font-size: 18px; }

.stage-panel { padding: 10px; }
.stage-wrap { position: relative; }
#scene {
  width: 100%;
  height: 560px;
  display: block;
  border-radius: 10px;
  touch-action: none;
  cursor: grab;
  background: #bfd9ff;
}
#scene:active { cursor: grabbing; }
@media (max-width: 900px) {
  #scene { height: 420px; }
}
.stage-hint {
  margin: 8px 4px 2px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.agent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 480px) {
  .agent-grid { grid-template-columns: 1fr; }
}
.agent-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}
.agent-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(79, 70, 229, 0.14); transform: translateY(-2px); }
.agent-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25); }
.agent-top { display: flex; align-items: center; gap: 8px; }
.agent-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}
.agent-name { font-weight: 800; font-size: 15px; }
.agent-role { font-size: 12px; color: var(--muted); margin-top: 1px; }
.agent-status {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-kerja { background: #dcfce7; color: #166534; }
.status-belajar { background: #fef3c7; color: #92400e; }
.status-istirahat { background: #f3f4f6; color: #6b7280; }
.agent-now { margin: 8px 0 0; font-size: 13px; color: var(--ink); }

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
  font-size: 13.5px;
}
.feed li {
  padding: 7px 4px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  gap: 8px;
}
.feed li:last-child { border-bottom: none; }
.feed .feed-time { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; color: var(--accent-dark); }
.feed .feed-empty { color: var(--muted); }

.detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 92vw);
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18);
  padding: 22px;
  overflow-y: auto;
  z-index: 40;
  animation: slideIn 0.25s ease both;
}
.detail[hidden] { display: none; }
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: #f3f4f6;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}
.detail-close:hover { background: #e5e7eb; }
.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-head .agent-dot { width: 20px; height: 20px; }
.detail-head h3 { margin: 0; font-size: 22px; }
.detail-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.detail-now { font-size: 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.detail-now span { color: var(--muted); }
.detail h4 { margin: 18px 0 8px; font-size: 15px; }
.schedule { list-style: none; margin: 0; padding: 0; }
.schedule li {
  display: flex;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
  border-radius: 6px;
}
.schedule li.current { background: #eef2ff; font-weight: 600; }
.schedule .sch-time { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; color: var(--accent-dark); }

.note { color: var(--muted); font-size: 13px; }
.note code { background: #e0e7ff; padding: 1px 6px; border-radius: 6px; font-size: 12px; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 18px 0 26px;
  color: var(--muted);
  font-size: 13px;
  background: #fff;
  margin-top: 10px;
}
.site-footer a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---- Denah kantor (minimap) ---- */
#minimap { width: 100%; height: auto; display: block; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
#minimap .map-room { stroke: #fff; stroke-width: 2; }
#minimap .map-room-label { font-size: 10px; font-weight: 800; fill: #475569; text-anchor: middle; font-family: inherit; }
#minimap .map-door { stroke: #fff; stroke-width: 4; }
#minimap .map-dot { stroke: #fff; stroke-width: 1.5; cursor: pointer; }
#minimap .map-dot.selected { stroke: #1f2937; stroke-width: 2.5; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.map-key { display: inline-flex; align-items: center; gap: 5px; }
.map-key i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0, 0, 0, 0.15); }

/* ---- Status berjalan + ruangan di kartu agen ---- */
.status-jalan { background: #e0e7ff; color: #3730a3; }
.agent-room { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }

/* Overlay loading aset 3D */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  z-index: 5;
}
.loading-box {
  background: #fff;
  border-radius: 14px;
  padding: 22px 28px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.loading-box p { margin: 12px 0 0; font-weight: 700; color: #1f2937; }
.loading-spin {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 4px solid #dbeafe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
