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

:root {
  --green: #00FF41;
  --green-dim: #00aa2b;
  --blue: #3498DB;
  --red: #e74c3c;
  --orange: #F39C12;
  --dark: #060a14;
  --mid: #0d1420;
  --border: #1a2a3a;
}

body {
  background: var(--dark);
  color: #c0c8d8;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 8px;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── CRT scanlines ──────────────────────────────────── */
#scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.07) 2px,
    rgba(0, 0, 0, 0.07) 4px
  );
  pointer-events: none;
  z-index: 999;
}

/* ── Header ─────────────────────────────────────────── */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #040810;
  border-bottom: 2px solid var(--green);
  color: var(--green);
  font-size: 9px;
  text-shadow: 0 0 10px var(--green);
  position: sticky;
  top: 0;
  z-index: 200;
}

#header-right {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 8px;
  color: var(--green-dim);
}

#global-status { color: var(--green-dim); }
#clock { color: var(--green); }

.blink-text { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── Office container ────────────────────────────────── */
#office-container {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 45px);
}

/* ── Back wall ───────────────────────────────────────── */
#back-wall {
  background: linear-gradient(to bottom, #0b1421, #121e2e);
  min-height: 60px;
  border-bottom: 4px solid #1a2e44;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 10px 30px;
  flex-wrap: wrap;
}

.wall-item {
  color: #2a4a6a;
  font-size: 6px;
  padding: 6px 12px;
  border: 1px solid #1a3a5a;
  background: #0a1220;
  white-space: nowrap;
}

.wall-logo {
  color: var(--green);
  font-size: 18px;
  border-color: var(--green);
  text-shadow: 0 0 20px var(--green);
  padding: 4px 16px;
  background: #040a10;
}

/* ── Office floor ────────────────────────────────────── */
#office-floor {
  flex: 1;
  background-color: #090e18;
  background-image:
    linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 56px 56px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 20px 30px;
  gap: 20px;
}

/* ── Room card ───────────────────────────────────────── */
.room-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, filter 0.2s ease;
}

.room-card:hover {
  transform: translateY(-5px);
  filter: drop-shadow(0 0 12px rgba(0,255,65,0.45));
}

.room-card.selected {
  filter: drop-shadow(0 0 16px var(--green));
}

/* ── Room canvas ─────────────────────────────────────── */
.room-canvas {
  display: block;
  image-rendering: pixelated;
  border: 2px solid #1a2a3a;
  border-bottom: none;
}

.room-card.selected .room-canvas {
  border-color: var(--green);
}

/* ── Status LED ──────────────────────────────────────── */
.status-led {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--dark);
  z-index: 3;
}

.status-led.online {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: led-pulse 2s ease-in-out infinite;
}

.status-led.offline {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
  50%       { opacity: 0.5; box-shadow: 0 0 3px var(--green); }
}

/* ── Nameplate ───────────────────────────────────────── */
.nameplate {
  font-size: 7px;
  text-align: center;
  padding: 6px 10px 4px;
  color: #8090b0;
  line-height: 2;
  background: #080e18;
  border: 2px solid #1a2a3a;
  border-top: none;
  width: 100%;
}

.room-card.selected .nameplate {
  border-color: var(--green);
  color: var(--green);
}

.nameplate .sub {
  font-size: 5px;
  color: #4a5a7a;
}

/* ── Side Panel ──────────────────────────────────────── */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 390px;
  height: 100vh;
  background: #040810;
  border-left: 2px solid var(--green);
  z-index: 400;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 12px;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: -12px 0 40px rgba(0,255,65,0.08);
}

#panel.open { transform: translateX(0); }

#panel-close {
  position: absolute;
  top: 12px;
  left: 12px;
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  font-family: inherit;
  font-size: 7px;
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.1s;
}

#panel-close:hover { background: var(--red); color: #fff; }

#panel-header {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-top: 36px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

#panel-char {
  image-rendering: pixelated;
  width: 80px;
  height: 120px;
  flex-shrink: 0;
}

#panel-name {
  font-size: 13px;
  color: var(--green);
  text-shadow: 0 0 10px var(--green);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

#panel-title-text {
  font-size: 6px;
  color: #3a6a9a;
  margin-bottom: 10px;
}

#panel-status-text {
  font-size: 7px;
  margin-bottom: 4px;
}

#panel-status-text.online  { color: var(--green); }
#panel-status-text.offline { color: var(--red); }

#panel-container-name {
  font-size: 5px;
  color: #2a3a5a;
  font-family: 'Courier New', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Action Buttons ──────────────────────────────────── */
#panel-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 6px;
  padding: 8px 10px;
  border: 2px solid;
  cursor: pointer;
  background: transparent;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.btn-warn  { color: var(--orange); border-color: var(--orange); }
.btn-warn:hover  { background: var(--orange); color: #000; }

.btn-info  { color: #7fb3d6; border-color: #4a80a0; }
.btn-info:hover  { background: #4a80a0; color: #fff; }

.btn-green { color: var(--green); border-color: var(--green); }
.btn-green:hover { background: var(--green); color: #000; }
.btn-green.active { background: var(--green); color: #000; }

.btn-blue  { color: var(--blue); border-color: var(--blue); }
.btn-blue:hover  { background: var(--blue); color: #fff; }

/* ── Logs Area ───────────────────────────────────────── */
#logs-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#logs-label {
  font-size: 6px;
  color: #3a6a9a;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#logs-mode {
  color: var(--orange);
  font-size: 5px;
}

#logs-output {
  flex: 1;
  background: #020508;
  border: 1px solid #0e1a28;
  padding: 10px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  line-height: 1.6;
  color: #70c870;
  white-space: pre-wrap;
  word-break: break-all;
}

#logs-output::-webkit-scrollbar { width: 6px; }
#logs-output::-webkit-scrollbar-track { background: #020508; }
#logs-output::-webkit-scrollbar-thumb { background: #1a3a2a; }

/* ── Toast ───────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #040810;
  border: 2px solid var(--green);
  color: var(--green);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 12px 24px;
  z-index: 1000;
  text-shadow: 0 0 8px var(--green);
  box-shadow: 0 0 20px rgba(0,255,65,0.2);
  display: none;
  white-space: nowrap;
}

#toast.warn {
  border-color: var(--orange);
  color: var(--orange);
  text-shadow: 0 0 8px var(--orange);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  #panel { width: 100vw; }
  #office-floor { gap: 14px; padding: 16px 10px; }
  .room-canvas { max-width: calc(100vw - 40px); height: auto; }
}
