/* =========================================================================
   LA AGENCIA — SIMULADOR ISOMÉTRICO 32-BIT (#view-agency-hq)
   ========================================================================= */

#view-agency-hq.active {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  background-color: #080b0f;
  overflow: hidden;
}

.iso-viewport {
  --void: #080b0f;
  --panel-bg: rgba(14, 20, 26, 0.94);
  --panel-border: #334652;
  --ink: #05070a;
  --gold: #e6b83a;
  --gold-hi: #ffec94;
  --green: #4ce668;
  --red: #e0463c;
  --cyan: #6ce8e8;
  --font-ui: 'Silkscreen', monospace;
  --font-title: 'Press Start 2P', monospace;

  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--void);
  color: #e6edf2;
  font-family: var(--font-ui);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  touch-action: none;
}

#viewCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: grab;
}

#viewCanvas.is-grabbing {
  cursor: grabbing;
}

#viewCanvas.is-hovering {
  cursor: pointer;
}

#viewCanvas.is-editing {
  cursor: crosshair;
}

/* =========================================================================
   BOTONES PIXEL ART
   ========================================================================= */
.iso-viewport .px-btn {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 10px;
  color: #dce6ed;
  background-color: #1c2933;
  border: 2px solid var(--ink);
  box-shadow: inset 1px 1px 0 #415969, inset -1px -1px 0 #0d141a;
  padding: 4px 8px;
  cursor: pointer;
  line-height: 1.1;
  text-shadow: 1px 1px 0 var(--ink);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.iso-viewport .px-btn:hover:not(:disabled) {
  background-color: #283a47;
  color: #ffffff;
}

.iso-viewport .px-btn:active:not(:disabled) {
  box-shadow: inset 1px 1px 0 #0d141a, inset -1px -1px 0 #415969;
  transform: translateY(1px);
}

.iso-viewport .px-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.iso-viewport .px-btn-gold {
  background-color: #362810;
  color: var(--gold-hi);
  box-shadow: inset 1px 1px 0 #8a6418, inset -1px -1px 0 #1a1205;
}
.iso-viewport .px-btn-gold:hover:not(:disabled) { background-color: #4d3916; }

.iso-viewport .px-btn-green {
  background-color: #13361e;
  color: #88ffa0;
  box-shadow: inset 1px 1px 0 #2d8046, inset -1px -1px 0 #091c0f;
}
.iso-viewport .px-btn-green:hover:not(:disabled) { background-color: #1b4d2b; }

.iso-viewport .px-btn-cyan {
  background-color: #12333d;
  color: #aef7ff;
  box-shadow: inset 1px 1px 0 #2b7a8c, inset -1px -1px 0 #07181f;
}
.iso-viewport .px-btn-cyan:hover:not(:disabled) { background-color: #184957; }

.iso-viewport .px-btn-red {
  background-color: #3d1414;
  color: #ff9c94;
  box-shadow: inset 1px 1px 0 #8f2d27, inset -1px -1px 0 #1a0707;
}

.iso-viewport .px-btn.active {
  background-color: #1a5463;
  color: #c2ffff;
  border-color: var(--cyan);
}

/* =========================================================================
   HUD SUPERIOR FLOTANTE
   ========================================================================= */
.iso-topbar {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.iso-topbar-left,
.iso-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background-color: var(--panel-bg);
  border: 2px solid var(--ink);
  box-shadow: inset 0 2px 0 var(--panel-border), 0 3px 0 rgba(0, 0, 0, 0.72);
  padding: 4px 7px;
  pointer-events: auto;
}

.iso-title {
  font-family: var(--font-title);
  font-size: 9px;
  color: var(--gold-hi);
  text-shadow: 2px 2px 0 var(--ink);
  padding: 0 4px;
}

.iso-pill {
  background: #0c1218;
  border: 2px solid var(--ink);
  box-shadow: inset 1px 1px 0 #243440;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 700;
  color: #cbd5e1;
  white-space: nowrap;
}

.iso-pill.is-cash { color: #6ee787; border-color: #175c30; }
.iso-pill.is-team { color: #ffec94; border-color: #694e14; }

.iso-mini-badge {
  background: #090d12;
  border: 1px solid #8a6418;
  color: var(--gold-hi);
  padding: 1px 4px;
  font-size: 9px;
}

/* =========================================================================
   PANEL DE TAREAS (ESQUINA SUPERIOR IZQUIERDA)
   ========================================================================= */
.iso-tasks-panel {
  position: absolute;
  top: 52px;
  left: 10px;
  width: min(295px, 86vw);
  max-height: calc(100% - 108px);
  z-index: 22;
  background-color: var(--panel-bg);
  border: 2px solid var(--ink);
  box-shadow: inset 0 2px 0 var(--panel-border), 0 4px 0 rgba(0, 0, 0, 0.78);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.iso-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  background: #101820;
  border-bottom: 2px solid var(--ink);
  font-family: var(--font-title);
  font-size: 9px;
  color: var(--gold-hi);
  text-shadow: 1px 1px 0 var(--ink);
}

.iso-close-x {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 11px;
  width: 20px;
  height: 20px;
  background: #3d1414;
  color: #ffb8b3;
  border: 2px solid var(--ink);
  cursor: pointer;
  line-height: 1;
}

.iso-tasks-body {
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.iso-task-card {
  background: #111820;
  border: 2px solid #243440;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.iso-task-card.is-ready {
  border-color: var(--gold);
  background: #1c190d;
}

.iso-task-card.is-done {
  opacity: 0.55;
  border-color: #193b25;
}

.iso-task-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #eef4f8;
}

.iso-task-reward {
  color: var(--green);
  font-size: 9px;
  white-space: nowrap;
}

.iso-task-desc {
  font-size: 9px;
  color: #96adb8;
  line-height: 1.3;
}

.iso-task-prog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.iso-prog-track {
  flex: 1;
  height: 7px;
  background: #070a0e;
  border: 1px solid #263542;
  overflow: hidden;
}

.iso-prog-fill {
  height: 100%;
  background: var(--cyan);
  transition: width 0.2s steps(6);
}

.iso-task-card.is-ready .iso-prog-fill {
  background: var(--gold);
}

.iso-task-count {
  font-size: 9px;
  color: #cbd5e1;
}

/* =========================================================================
   DRAWER LATERAL DERECHO (SALAS / NIVELES / MUEBLES)
   ========================================================================= */
.iso-side-drawer {
  position: absolute;
  top: 52px;
  right: 10px;
  width: min(335px, 90vw);
  max-height: calc(100% - 142px);
  z-index: 24;
  background-color: var(--panel-bg);
  border: 2px solid var(--ink);
  box-shadow: inset 0 2px 0 var(--panel-border), 0 4px 0 rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.iso-drawer-body {
  padding: 9px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.iso-card {
  background: #10171f;
  border: 2px solid #283947;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.iso-card.is-highlight {
  border-color: var(--gold);
}

.iso-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.iso-card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-hi);
}

.iso-lvl-tag {
  font-family: var(--font-title);
  font-size: 8px;
  color: #88ffa0;
  background: #102b19;
  border: 1px solid #276e3f;
  padding: 2px 5px;
}

.iso-card-sub {
  font-size: 9px;
  color: #9eb3bf;
  line-height: 1.35;
}

.iso-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}

.iso-shop-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

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

.iso-inv-slot {
  background: #0d141c;
  border: 2px solid #2d4252;
  padding: 5px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: #e6edf2;
  font-family: var(--font-ui);
  font-size: 8px;
  font-weight: 700;
  text-align: center;
}

.iso-inv-slot:hover {
  border-color: var(--gold);
  background: #1a180e;
}

.iso-inv-slot canvas,
.iso-shop-icon canvas {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.iso-shop-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.iso-shop-icon {
  width: 44px;
  height: 44px;
  background: #090e14;
  border: 2px solid #243440;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Fichas del menú de Plantilla */
.iso-team-card {
  background: #10171f;
  border: 2px solid #283947;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.iso-team-card.is-occupied { border-color: #2b6e78; }
.iso-team-card.is-locked { opacity: 0.78; border-color: #3a3018; }

.iso-team-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.iso-team-mii-box {
  width: 38px;
  height: 46px;
  background: #0a1016;
  border: 2px solid #1e2d38;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.iso-team-mii-box canvas {
  width: 32px;
  height: 40px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.iso-team-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.iso-team-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iso-team-meta {
  font-size: 9px;
  color: var(--cyan);
}

.iso-team-stats {
  font-size: 9px;
  color: #9eb3bf;
}

.iso-team-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* =========================================================================
   BARRA FLOTANTE DE MODO EDICIÓN
   ========================================================================= */
.iso-edit-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  z-index: 23;
  background-color: rgba(18, 26, 34, 0.96);
  border: 2px solid var(--gold);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.8);
  padding: 5px 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
}

.iso-edit-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--gold-hi);
}

.iso-edit-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* =========================================================================
   CONTROLES DE CÁMARA Y BARRA TERMINAL INFERIOR
   ========================================================================= */

.term-led {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  background-color: var(--green);
  border: 1px solid var(--ink);
}

.term-led.gold { background-color: var(--gold); }
.term-led.red { background-color: var(--red); }
.term-led.cyan { background-color: var(--cyan); }

@media (max-width: 820px) {
  
  .iso-title { display: none; }
  
  .iso-edit-bar { bottom: 86px; }
}

/* Barra superior: admite todos los accesos de la Agencia */
.iso-topbar-right { flex-wrap: wrap; justify-content: flex-end; }

/* En pantallas estrechas la barra superior ocupa dos filas */
@media (max-width: 1200px) {
  .iso-tasks-panel, .iso-side-drawer { top: 96px !important; }
}
