/* ── NetTopo Lab Simulator — Styles ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-hover: #1e293b;
  --border: #2a3548;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --purple: #a855f7;
  --panel-width: 320px;
}

body { font-family: 'Inter', sans-serif; background: var(--bg-primary); color: var(--text-primary); overflow: hidden; height: 100vh; }

/* ── Header ── */
#lab-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 52px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { color: var(--accent); text-decoration: none; font-weight: 700; font-size: 16px; }
.badge { background: var(--purple); color: #fff; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; letter-spacing: 1px; }
.header-actions { display: flex; gap: 8px; }

/* ── Buttons ── */
.btn {
  padding: 7px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500;
  transition: all .2s; display: inline-flex; align-items: center; gap: 5px;
}
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: linear-gradient(135deg, #0ea5e9, #38bdf8); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #0284c7, #0ea5e9); transform: translateY(-1px); }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Layout ── */
#app-container { display: flex; height: calc(100vh - 52px); margin-top: 52px; }
#canvas-container { flex: 1; position: relative; background: var(--bg-primary); }
#three-canvas { width: 100%; height: 100%; display: block; }

/* ── Stats Bar ── */
#stats-bar {
  position: absolute; top: 12px; left: 12px; display: flex; gap: 12px;
  background: rgba(17,24,39,.85); backdrop-filter: blur(8px);
  padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border); font-size: 13px;
}
.status-up { color: var(--green); }
.status-down { color: var(--red); }
.status-warn { color: var(--yellow); }
#controls-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(17,24,39,.7); backdrop-filter: blur(6px);
  padding: 6px 16px; border-radius: 8px; font-size: 11px; color: var(--text-muted);
}

/* ── Tooltip ── */
#tooltip {
  position: absolute; pointer-events: none; background: rgba(17,24,39,.95);
  backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; font-size: 12px; z-index: 50; white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
#tooltip .tt-host { font-weight: 600; color: var(--accent); }
#tooltip .tt-ip { color: var(--text-secondary); }

/* ── Side Panel ── */
#side-panel {
  width: var(--panel-width); background: var(--bg-secondary); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 20px; flex-shrink: 0;
}
.hidden { display: none !important; }
#panel-empty { text-align: center; padding-top: 60px; color: var(--text-muted); }
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }
#panel-empty h3 { margin-bottom: 8px; color: var(--text-secondary); }

#device-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
#device-icon { font-size: 36px; }
#device-header h3 { font-size: 16px; margin-bottom: 2px; }
#device-type-badge { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.field-group { margin-bottom: 14px; }
.field-group label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.field-input {
  width: 100%; padding: 8px 12px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-primary); font-family: 'Inter', monospace; font-size: 13px;
  transition: border-color .2s;
}
.field-input:focus { outline: none; border-color: var(--accent); }
.field-input[readonly] { opacity: .7; cursor: default; }
.status-toggle { display: flex; align-items: center; gap: 10px; }
.status-badge { padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.status-badge.up { background: rgba(34,197,94,.15); color: var(--green); }
.status-badge.down { background: rgba(239,68,68,.15); color: var(--red); }
.status-badge.warning { background: rgba(234,179,8,.15); color: var(--yellow); }
.panel-actions { margin: 16px 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
#device-loss, #device-uptime { font-size: 14px; font-weight: 500; }

/* ── Device List Drawer ── */
#device-list-toggle {
  position: fixed; bottom: 20px; right: calc(var(--panel-width) + 20px);
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; z-index: 50; box-shadow: 0 4px 16px rgba(56,189,248,.3);
  transition: transform .2s;
}
#device-list-toggle:hover { transform: scale(1.1); }
#device-list-drawer {
  position: fixed; bottom: 0; left: 0; right: var(--panel-width);
  height: 220px; background: var(--bg-secondary); border-top: 1px solid var(--border);
  z-index: 90; overflow-y: auto; padding: 14px 20px;
}
#device-list-drawer h3 { margin-bottom: 10px; font-size: 14px; }
#device-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.dl-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--bg-card); border-radius: 6px; cursor: pointer; font-size: 12px;
  border: 1px solid transparent; transition: all .15s;
}
.dl-item:hover { border-color: var(--accent); background: var(--bg-hover); }
.dl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dl-dot.up { background: var(--green); }
.dl-dot.down { background: var(--red); }
.dl-dot.warning { background: var(--yellow); }
.dl-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-ip { color: var(--text-muted); font-size: 11px; }

/* ── Animations ── */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.saving { animation: pulse .8s infinite; }

/* ── Responsive ── */
@media (max-width: 768px) {
  #side-panel { display: none; }
  #device-list-toggle { right: 20px; }
  #device-list-drawer { right: 0; }
}

/* ── Tutorial Overlay ── */
/* Show/hide controlled by inline display:flex/none in JS */
#tutorial-overlay {
  /* position/z-index set inline in HTML */
  background: transparent;
}
#tutorial-backdrop {
  /* position set inline in HTML */
  backdrop-filter: blur(6px);
}
.tut-card {
  display: flex; align-items: flex-start; gap: 14px;
  background: rgba(26,34,53,.95); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 22px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  animation: tutSlideIn .5s ease-out both;
  width: 100%;
}
.tut-step1 { animation-delay: .1s; border-left: 3px solid var(--accent); }
.tut-step2 { animation-delay: .3s; border-left: 3px solid var(--yellow); }
.tut-step3 { animation-delay: .5s; border-left: 3px solid var(--green); }
.tut-num {
  font-size: 28px; line-height: 1; flex-shrink: 0;
  width: 40px; text-align: center;
}
.tut-text { font-size: 14px; line-height: 1.6; color: var(--text-secondary); }
.tut-text strong { color: var(--text-primary); font-size: 15px; }
.tut-text em { color: var(--accent); font-style: normal; font-weight: 600; }

#tut-dismiss {
  animation: tutSlideIn .5s ease-out .7s both;
  padding: 12px 36px; font-size: 15px; border-radius: 12px;
  margin-top: 8px;
}
@keyframes tutSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
