/* ==========================================================================
   Terraria Pixel Art Boss Workbench Stylesheet
   ========================================================================== */
:root {
  --tr-blue-bg: rgba(24, 34, 68, 0.92);
  --tr-blue-border-light: #5c7cfa;
  --tr-blue-border-dark: #101935;
  --tr-slot-bg: rgba(34, 48, 94, 0.88);
  --tr-slot-active: rgba(255, 209, 59, 0.92);
  --tr-gold: #ffd13b;
  --tr-gold-dark: #b8860b;
  --tr-green: #52b788;
  --tr-red: #ef476f;
  --tr-text: #f8f9fa;
  --tr-muted: #adb5bd;
  --pixel-shadow: 2px 2px 0px #000000;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0b0f19;
  font-family: "Courier New", "Microsoft YaHei", "PingFang SC", monospace;
  color: var(--tr-text);
  image-rendering: pixelated;
}

#worldCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: grab;
  image-rendering: pixelated;
}

#worldCanvas:active {
  cursor: grabbing;
}

/* ==========================================================================
   Top-Left Terraria Hotbar HUD
   ========================================================================== */
#hud-top-left {
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

#hud-top-left > * {
  pointer-events: auto;
}

.hud-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.terraria-logo {
  font-size: 18px;
  font-weight: 900;
  color: #ffe066;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #5f3dc4;
  background: rgba(16, 25, 53, 0.85);
  border: 2px solid #4c6ef5;
  padding: 4px 10px;
  box-shadow: 3px 3px 0 #000;
}

.pixel-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  background: rgba(18, 28, 58, 0.9);
  border: 2px solid #748ffc;
  color: #fff3bf;
  text-shadow: 1px 1px 0 #000;
  box-shadow: 2px 2px 0 #000;
}

.hotbar {
  display: flex;
  gap: 6px;
}

.hotbar-slot {
  position: relative;
  width: 66px;
  height: 66px;
  background: var(--tr-slot-bg);
  border: 3px solid #4dabf7;
  box-shadow: inset -2px -2px 0 #182347, inset 2px 2px 0 #74c0fc, 3px 3px 0 #000;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 0.08s ease;
}

.hotbar-slot:hover {
  transform: translateY(-2px);
  border-color: var(--tr-gold);
  background: rgba(54, 74, 138, 0.95);
}

.hotbar-slot.active {
  border-color: #ffe066;
  background: linear-gradient(180deg, rgba(102, 77, 18, 0.95), rgba(59, 43, 10, 0.95));
  box-shadow: inset 0 0 8px rgba(255, 224, 102, 0.5), 3px 3px 0 #000;
}

.slot-num {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 11px;
  font-weight: 900;
  color: #ffd43b;
  text-shadow: 1px 1px 0 #000;
}

.slot-icon {
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(2px 2px 0 #000);
}

.slot-label {
  font-size: 11px;
  font-weight: 700;
  color: #f1f3f5;
  text-shadow: 1px 1px 0 #000;
}

.controls-hint {
  font-size: 12px;
  color: #d0ebff;
  background: rgba(12, 18, 38, 0.82);
  border: 2px solid #364fc7;
  padding: 5px 10px;
  text-shadow: 1px 1px 0 #000;
  box-shadow: 2px 2px 0 #000;
}

/* ==========================================================================
   Top-Right Terraria Hearts & Coins HUD
   ========================================================================== */
#hud-top-right {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-hearts {
  background: rgba(18, 28, 58, 0.9);
  border: 2px solid #ff6b6b;
  padding: 5px 10px;
  box-shadow: 3px 3px 0 #000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-title {
  font-size: 12px;
  font-weight: bold;
  color: #ffc9c9;
  text-shadow: 1px 1px 0 #000;
}

.hearts-row {
  font-size: 15px;
  letter-spacing: 2px;
  filter: drop-shadow(1px 1px 0 #000);
}

.stat-coins-bar {
  display: flex;
  gap: 8px;
  background: rgba(18, 28, 58, 0.9);
  border: 2px solid #fcc419;
  padding: 6px 12px;
  box-shadow: 3px 3px 0 #000;
}

.coin-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 1px 1px 0 #000;
}

.coin-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border: 1px solid #000;
}

.coin-dot.plat { background: #e5f4ff; box-shadow: 0 0 4px #74c0fc; }
.coin-dot.gold { background: #ffd43b; box-shadow: 0 0 4px #fcc419; }
.coin-dot.silver { background: #ced4da; }

/* ==========================================================================
   Terraria Buttons & Panels
   ========================================================================== */
.terraria-btn {
  background: #364fc7;
  color: #fff;
  border: 2px solid #748ffc;
  box-shadow: inset -2px -2px 0 #182347, inset 2px 2px 0 #91a7ff, 2px 2px 0 #000;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
  transition: transform 0.06s;
}

.terraria-btn:hover {
  filter: brightness(1.15);
  border-color: var(--tr-gold);
}

.terraria-btn:active {
  transform: translate(1px, 1px);
}

.terraria-btn.sm {
  padding: 5px 9px;
  font-size: 12px;
}

.terraria-btn.gold {
  background: #d97706;
  border-color: #fde047;
  box-shadow: inset -2px -2px 0 #78350f, inset 2px 2px 0 #fef08a, 2px 2px 0 #000;
}

.terraria-btn.green {
  background: #2b8a3e;
  border-color: #69db7c;
  box-shadow: inset -2px -2px 0 #14451e, inset 2px 2px 0 #b2f2bb, 2px 2px 0 #000;
}

.terraria-btn.blue {
  background: #1971c2;
  border-color: #4dabf7;
  box-shadow: inset -2px -2px 0 #0b3963, inset 2px 2px 0 #a5d8ff, 2px 2px 0 #000;
}

.terraria-btn.danger {
  background: #c92a2a;
  border-color: #ff8787;
  box-shadow: inset -2px -2px 0 #661010, inset 2px 2px 0 #ffc9c9, 2px 2px 0 #000;
}

.terraria-panel {
  background: var(--tr-blue-bg);
  border: 3px solid var(--tr-blue-border-light);
  box-shadow: inset -3px -3px 0 var(--tr-blue-border-dark), inset 3px 3px 0 #91a7ff, 5px 5px 0 #000;
}

/* ==========================================================================
   Right Sidebar Panel
   ========================================================================== */
#sidebar-panel {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 375px;
  max-height: calc(100vh - 80px);
  z-index: 25;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#sidebar-panel.collapsed {
  transform: translateX(410px);
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #3b5bdb;
  padding-bottom: 8px;
}

.panel-header h2 {
  font-size: 16px;
  color: var(--tr-gold);
  text-shadow: 2px 2px 0 #000;
}

.icon-close-btn {
  background: #c92a2a;
  border: 2px solid #ff8787;
  color: #fff;
  width: 24px;
  height: 24px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.tab-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid #4263eb;
  color: #cbd5e1;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}

.tab-btn.active {
  background: #3b5bdb;
  border-color: var(--tr-gold);
  color: #fff;
}

.count-pill {
  background: #f59f00;
  color: #000;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 900;
  text-shadow: none;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.tab-content.active {
  display: flex;
}

.quick-actions-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.scroll-list {
  overflow-y: auto;
  max-height: calc(100vh - 245px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.scroll-list::-webkit-scrollbar {
  width: 6px;
}
.scroll-list::-webkit-scrollbar-thumb {
  background: #4dabf7;
}

/* Department & Employee Cards in Sidebar */
.dept-card {
  background: rgba(13, 21, 45, 0.9);
  border: 2px solid #4c6ef5;
  padding: 8px;
  box-shadow: 2px 2px 0 #000;
}

.dept-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  cursor: pointer;
}

.dept-card-title {
  font-size: 13px;
  font-weight: 800;
  color: #ffe066;
  text-shadow: 1px 1px 0 #000;
}

.emp-mini-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.emp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(30, 44, 88, 0.78);
  border: 1px solid #3b5bdb;
  padding: 5px 7px;
  font-size: 12px;
  cursor: pointer;
}

.emp-row:hover {
  border-color: var(--tr-gold);
  background: rgba(45, 66, 130, 0.9);
}

.emp-status-tag {
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid #000;
  font-weight: bold;
}

.emp-status-tag.working {
  background: #e67700;
  color: #fff;
}

.emp-status-tag.idle {
  background: #2b8a3e;
  color: #fff;
}

/* Task Card in Sidebar */
.task-card {
  background: rgba(15, 24, 52, 0.92);
  border: 2px solid #4dabf7;
  padding: 8px;
  box-shadow: 2px 2px 0 #000;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.task-card.rarity-purple { border-color: #cc5de8; }
.task-card.rarity-orange { border-color: #ff922b; }
.task-card.rarity-rainbow { border-color: #fcc419; }

.task-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: bold;
}

.task-reward {
  color: #ffd43b;
  font-weight: 900;
}

.task-meta {
  font-size: 11px;
  color: #a5d8ff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pixel-progress-outer {
  width: 100%;
  height: 10px;
  background: #0b1124;
  border: 1px solid #5c7cfa;
  overflow: hidden;
}

.pixel-progress-inner {
  height: 100%;
  background: linear-gradient(90deg, #40c057, #8ce99a);
  transition: width 0.2s linear;
}

/* Revenue Log Card */
.revenue-summary-card {
  background: rgba(11, 18, 38, 0.95);
  border: 2px solid var(--tr-gold);
  padding: 10px;
  text-align: center;
  box-shadow: 2px 2px 0 #000;
}

.rev-label {
  font-size: 11px;
  color: #adb5bd;
}

.rev-big {
  font-size: 22px;
  font-weight: 900;
  color: #ffd43b;
  text-shadow: 2px 2px 0 #000;
  margin: 4px 0;
}

.rev-sub {
  font-size: 11px;
  color: #69db7c;
}

.log-item {
  font-size: 12px;
  background: rgba(20, 31, 64, 0.8);
  border-left: 3px solid var(--tr-gold);
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-footer-actions {
  padding-top: 6px;
  border-top: 1px solid #364fc7;
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   Bottom-Left Entity Inspector
   ========================================================================== */
#entity-inspector {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 330px;
  z-index: 25;
  padding: 12px;
}

.hidden {
  display: none !important;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #4c6ef5;
  padding-bottom: 6px;
  margin-bottom: 8px;
  font-weight: 900;
  color: var(--tr-gold);
}

.insp-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 8px 0;
  font-size: 12px;
}

.insp-stat-box {
  background: rgba(12, 19, 41, 0.9);
  border: 1px solid #3b5bdb;
  padding: 5px 7px;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.72);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.terraria-modal {
  width: 440px;
  max-width: 94vw;
  background: var(--tr-blue-bg);
  border: 3px solid var(--tr-gold);
  box-shadow: inset -3px -3px 0 #101935, inset 3px 3px 0 #ffe066, 6px 6px 0 #000;
  padding: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #4c6ef5;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.modal-header h3 {
  color: var(--tr-gold);
  font-size: 16px;
  text-shadow: 2px 2px 0 #000;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: bold;
  color: #d0ebff;
  margin: 10px 0 5px;
  text-shadow: 1px 1px 0 #000;
}

.pixel-input, .pixel-select {
  width: 100%;
  background: #0d152d;
  border: 2px solid #4c6ef5;
  color: #fff;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  box-shadow: inset 2px 2px 0 #000;
}

.pixel-input:focus, .pixel-select:focus {
  outline: none;
  border-color: var(--tr-gold);
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.theme-option {
  background: #111b3a;
  border: 2px solid #364fc7;
  padding: 7px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.theme-option input {
  display: none;
}

.theme-option.selected {
  border-color: var(--tr-gold);
  background: #23356e;
}

.theme-swatch, .skin-dot {
  width: 14px;
  height: 14px;
  border: 1px solid #000;
  flex-shrink: 0;
}

.swatch-wood { background: #8d5b34; }
.swatch-stone { background: #6c757d; }
.swatch-gold { background: #f59f00; }
.swatch-crystal { background: #cc5de8; }
.swatch-obsidian { background: #3b2854; }
.swatch-jungle { background: #40916c; }

.icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}

.icon-pick {
  background: #111b3a;
  border: 2px solid #364fc7;
  font-size: 18px;
  padding: 5px 0;
  cursor: pointer;
}

.icon-pick.selected {
  border-color: var(--tr-gold);
  background: #2b4185;
}

.rarity-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.rarity-chip {
  background: #111b3a;
  border: 2px solid #364fc7;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rarity-chip input { display: none; }
.rarity-chip.selected { border-color: #fff; background: #263875; }
.rarity-chip.r-blue { color: #74c0fc; }
.rarity-chip.r-purple { color: #e599f7; }
.rarity-chip.r-orange { color: #ffa94d; }
.rarity-chip.r-rainbow { color: #ffe066; }

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
