/* Layout Rebuild - No Overlaps */
.game-container {
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: row;
  width: 900px;
  height: 600px;
  position: relative;
}

.main-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
}

.office {
  flex: 1;
  position: relative;
  background: linear-gradient(180deg, var(--bg-wall) 0%, var(--bg-wall) 65%, var(--carpet) 65%, var(--carpet) 100%);
  width: 100% !important;
}

.ops-panel {
  height: 80px;
  background: #111;
  border-top: 2px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
}

.console-panel {
  height: 80px;
  background: #000;
  border-top: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
}

.status-bar {
  height: 28px;
  background: linear-gradient(180deg, #2a2a4a 0%, #1a1a2e 100%);
  border-top: 2px solid var(--ui-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 20px;
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
}

.info-panel {
  width: 220px;
  height: 100%;
  position: relative !important;
  border-left: 2px solid var(--ui-border);
}

@media (max-width: 768px) {
  .screen {
    flex-direction: column;
    width: 100vw;
    height: 100vh;
  }
  
  .office {
    height: auto;
    flex: 1;
  }
  
  .info-panel {
    display: none !important;
  }

  .console-panel { height: 25%; }
  .ops-panel { height: 15%; }
}

/* Windows */
.window {
  position: absolute;
  top: 20px;
  width: 120px;
  height: 100px;
  background: var(--window);
  border: 6px solid var(--desk-wood);
  box-shadow: inset 0 0 20px rgba(255,255,255,0.3);
}

.window::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: var(--desk-wood);
  transform: translateX(-50%);
}

.window::before {
  content: '';
  position: absolute;
  top: 50%;
  width: 100%;
  height: 4px;
  background: var(--desk-wood);
  transform: translateY(-50%);
  z-index: 1;
}

.window:nth-child(1) { left: 40px; }
.window:nth-child(2) { left: 200px; }
.window:nth-child(3) { right: 200px; }
.window:nth-child(4) { right: 40px; }

/* Floor carpet pattern */
.office::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 35%;
  background: 
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 40px,
      rgba(0,0,0,0.1) 40px,
      rgba(0,0,0,0.1) 42px
    );
  pointer-events: none;
}

/* Desks */
.desk {
  position: absolute;
  width: 90px;
  height: 60px;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
  z-index: 20;
}

.desk:hover {
  transform: scale(1.05);
  filter: brightness(1.2);
}

.desk.selected {
  filter: brightness(1.3) drop-shadow(0 0 8px var(--agent-selected));
}

.desk-body {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 35px;
  background: linear-gradient(180deg, var(--desk-wood) 0%, var(--desk-dark) 100%);
  border-radius: 2px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.desk-top {
  position: absolute;
  bottom: 32px;
  left: -4px;
  width: calc(100% + 8px);
  height: 8px;
  background: linear-gradient(180deg, #a0522d 0%, var(--desk-wood) 100%);
  border-radius: 2px;
}

.desk-monitor {
  position: absolute;
  bottom: 38px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 28px;
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 2px;
}

.desk-monitor::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 14px;
  background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
}

.desk-monitor::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 6px;
  background: #333;
  border-radius: 0 0 2px 2px;
}

.desk-label {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: #ddd;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.desk-context-pct {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 14px;
  line-height: 1;
  text-shadow: 0 1px 2px #000;
}

.desk-state-indicator {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ui-dark);
}

.desk-state-indicator.working { 
  background: var(--agent-working); 
  box-shadow: 0 0 8px var(--agent-working), 0 0 12px rgba(39, 174, 96, 0.5);
  animation: glow-working 1.5s ease-in-out infinite;
}
.desk-state-indicator.idle { 
  background: var(--agent-idle);
  box-shadow: 0 0 4px var(--agent-idle);
}
.desk-state-indicator.ooo { 
  background: var(--agent-ooo); 
  opacity: 0.6;
}

@keyframes glow-working {
  0%, 100% { box-shadow: 0 0 8px var(--agent-working), 0 0 12px rgba(39, 174, 96, 0.5); }
  50% { box-shadow: 0 0 12px var(--agent-working), 0 0 20px rgba(39, 174, 96, 0.7); }
}

/* Context Progress Bar */
.desk-progress {
  position: absolute;
  bottom: 2px;
  left: 4px;
  right: 4px;
  height: 4px;
  background: rgba(0,0,0,0.4);
  border-radius: 2px;
  overflow: hidden;
}

.desk-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3498db, #2980b9);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.desk-last-active {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--ui-text-dim);
  white-space: nowrap;
}

/* Agents - BIG GEESE */
.agent {
  position: absolute;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  z-index: 15;
  transition: left 0.4s ease-out, top 0.4s ease-out;
  cursor: pointer;
}

/* Sleeping/ooo - grayed out */
.agent.idle .agent-sprite,
.agent.ooo .agent-sprite,
.agent.snoring {
  filter: grayscale(0.7) brightness(0.8);
}

/* Bobbing animation - slight up/down movement */
.agent.bobbing {
  animation: bob 1.5s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* Snoring animation for idle >15 min */
.agent.snoring {
  animation: snore 2s ease-in-out infinite;
}

@keyframes snore {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-2px) rotate(-3deg); }
  75% { transform: translateY(-2px) rotate(3deg); }
}

.agent.snoring::after {
  content: '💤';
  position: absolute;
  top: -8px;
  right: -12px;
  font-size: 16px;
  animation: snore-z 1.5s ease-in-out infinite;
}

@keyframes snore-z {
  0% { opacity: 0; transform: translateY(4px) scale(0.8); }
  50% { opacity: 1; transform: translateY(-2px) scale(1); }
  100% { opacity: 0; transform: translateY(-8px) scale(0.8); }
}

.agent:hover {
  transform: scale(1.2);
}

.agent.working {
  animation: heartbeat 0.8s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.agent-bubble {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  color: #333;
  padding: 3px 8px;
  font-size: 10px;
  border-radius: 10px;
  white-space: nowrap;
  font-family: sans-serif;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  animation: bubble-pop 0.2s ease-out;
  z-index: 25;
}

.agent-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid white;
}

@keyframes bubble-pop {
  from { transform: translateX(-50%) scale(0); }
  to { transform: translateX(-50%) scale(1); }
}

/* Info Panel (right side) */
.info-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 180px;
  height: 100%;
  background: linear-gradient(180deg, #1e1e2e 0%, #16162a 100%);
  border-left: 2px solid var(--ui-border);
  padding: 10px;
  overflow-y: auto;
  z-index: 30;
}

.info-panel h3 {
  font-size: 12px;
  color: var(--ui-highlight);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Token Bar in Info Panel */
.token-bar-container {
  margin-bottom: 12px;
}

.token-bar {
  height: 8px;
  background: rgba(0,0,0,0.4);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  position: relative;
}

.token-input {
  position: absolute;
  height: 100%;
  background: #3498db;
  left: 0;
  border-radius: 4px 0 0 4px;
}

.token-output {
  position: absolute;
  height: 100%;
  background: #e74c3c;
  left: 0;
  border-radius: 4px;
  opacity: 0.8;
}

.token-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--ui-text-dim);
  margin-top: 4px;
}

.sort-controls {
  display: flex;
  gap: 4px;
}

.sort-btn {
  background: #222;
  border: 1px solid #444;
  color: #888;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
}

.sort-btn:hover {
  background: #333;
  color: #0f0;
}

.info-panel .agent-info {
  margin-bottom: 16px;
}

.info-panel .info-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 4px;
}

.info-panel .info-label { color: var(--ui-text-dim); }
.info-panel .info-value { color: var(--ui-text); font-family: monospace; }

/* Radar - Left side */
.radar {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 100px;
  height: 80px;
  background: rgba(0,20,0,0.9);
  border: 2px solid #0f0;
  border-radius: 4px;
  overflow: hidden;
}

.radar-title {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 8px;
  color: #0f0;
  font-family: monospace;
  z-index: 5;
}

.radar-grid {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    linear-gradient(90deg, rgba(0,255,0,0.15) 1px, transparent 1px),
    linear-gradient(rgba(0,255,0,0.15) 1px, transparent 1px);
  background-size: 20px 16px;
}

.radar-dots {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

.radar-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.radar-dot.working { 
  background: var(--agent-working); 
  box-shadow: 0 0 8px var(--agent-working), 0 0 12px rgba(39, 174, 96, 0.6);
  animation: radar-pulse 1.5s ease-in-out infinite;
}

@keyframes radar-pulse {
  0%, 100% { box-shadow: 0 0 6px var(--agent-working); }
  50% { box-shadow: 0 0 12px var(--agent-working), 0 0 18px rgba(39, 174, 96, 0.8); }
}
.radar-dot.idle { background: var(--agent-idle); }
.radar-dot.ooo { background: var(--agent-ooo); }

.radar-sweep {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50%;
  height: 2px;
  background: linear-gradient(90deg, rgba(0,255,0,0.8), transparent);
  transform-origin: left center;
  animation: sweep 3s linear infinite;
}

@keyframes sweep {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Cleanup - Replaced with flex layout */
.status-bar-unused-v6 {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 180px;
  height: 28px;
  background: linear-gradient(180deg, #2a2a4a 0%, #1a1a2e 100%);
  border-top: 2px solid var(--ui-border);
  font-size: 11px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 20px;
}

.status-bar .stat {
  display: flex;
  gap: 6px;
}

.status-bar .stat-label { color: var(--ui-text-dim); }
.status-bar .stat-value { color: var(--ui-text); }
.status-bar .stat-value.active { color: var(--agent-working); }
.status-bar .stat-value.idle { color: var(--agent-idle); }
.status-bar .stat-value.ooo { color: var(--agent-ooo); }

/* Click feedback */
.click-feedback {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--agent-selected);
  border-radius: 50%;
  animation: click-ripple 0.4s ease-out forwards;
  pointer-events: none;
}

@keyframes click-ripple {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

/* Files List in Info Panel */
.files-list {
  max-height: 250px;
  overflow-y: auto;
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
  padding: 4px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  font-size: 10px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s;
}

.file-item:hover {
  background: rgba(255,255,255,0.1);
}

.file-icon {
  flex-shrink: 0;
  font-size: 12px;
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ui-text);
}

.file-size {
  color: var(--ui-text-dim);
  font-size: 9px;
  flex-shrink: 0;
}

.file-item.expanded .file-header {
  border-bottom: 1px solid var(--ui-border);
  margin-bottom: 4px;
  padding-bottom: 4px;
}

/* File Preview Modal Overlay */
.file-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.file-modal-overlay.active {
  display: flex;
}

.file-modal {
  background: #0a0a0a;
  border: 2px solid #0f0;
  border-radius: 8px;
  width: 80%;
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0,255,0,0.3);
}

.file-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
  border-radius: 6px 6px 0 0;
}

.file-modal-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f0;
}

.file-modal-close {
  background: none;
  border: none;
  color: #666;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.file-modal-close:hover {
  color: #f00;
}

.file-modal-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-size: 13px;
  font-family: 'Consolas', 'Monaco', monospace;
  color: #0f0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.file-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================
   PANELS - Console & Ops
   Desktop: shown by default, Mobile: Stacked
   ============================================ */

.console-panel {
  display: flex;
}

.ops-panel {
  display: flex;
}

/* Cleanup - Replaced with flex layout */
.status-bar-unused-final {
  display: flex;
}

/* ============================================
   MOBILE RESPONSIVE
   Proper stacking: Ops → Status → Console → Office
   ============================================ */

@media (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
    overflow: hidden;
  }

  .game-container {
    width: 100vw;
    height: 100vh;
    border: none;
    border-radius: 0;
  }

  .screen {
    width: 100vw;
    height: 100vh;
    position: relative;
  }

  /* Hide desktop-only elements */
  .info-panel {
    display: none !important;
  }

  .header-bar {
    display: none;
  }

  /* Office fills space above panels */
  .office {
    width: 100%;
    height: calc(100% - 50px - 28px - 30%);
    position: absolute;
    top: 0;
    left: 0;
  }

/* Ops Panel - BOTTOM, 50px */
.ops-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: rgba(20, 20, 35, 0.98);
  border-top: 1px solid var(--ui-border);
  z-index: 80;
  flex-direction: column;
  display: flex;
}

.ops-header {
  font-size: 8px;
  color: var(--ui-highlight);
  padding: 2px 8px;
  background: rgba(0,0,0,0.3);
}

.ops-content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  font-size: 10px;
  font-family: monospace;
}

/* Status Bar - ABOVE ops, 28px */
/* Cleanup - Replaced with flex layout */
.status-bar-unused-v4 {
  position: absolute;
  bottom: 50px;
  left: 0;
  right: 0;
  height: 28px;
  background: rgba(0, 0, 0, 0.9);
  border-bottom: 1px solid var(--ui-border);
  border-top: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 8px;
  font-size: 10px;
  z-index: 90;
}

/* Console Panel - ABOVE status, 30% */
.console-panel {
  position: absolute;
  bottom: calc(50px + 28px);
  left: 0;
  right: 0;
  height: 30%;
  background: rgba(10, 10, 18, 0.95);
  border-top: 2px solid var(--ui-highlight);
  z-index: 100;
  font-family: 'Courier New', monospace;
  display: flex;
  flex-direction: column;
}
  background: rgba(10, 10, 18, 0.95);
  border-top: 2px solid var(--ui-highlight);
  z-index: 100;
  font-family: 'Courier New', monospace;
  display: flex;
  flex-direction: column;
}

.console-header {
  font-size: 9px;
  background: var(--ui-highlight);
  color: #000;
  padding: 2px 8px;
  font-weight: bold;
}

.console-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  font-size: 11px;
}
}

/* Small mobile */
@media (max-width: 480px) {
  .office {
    height: calc(100% - 45px - 24px - 40%);
  }

  .ops-panel {
    height: 45px;
  }

/* Cleanup - Replaced with flex layout */
.status-bar-unused-v5 {
    bottom: 45px;
    height: 24px;
    font-size: 9px;
    gap: 6px;
  }

  .console-panel {
    bottom: calc(45px + 24px);
    height: 40%;
  }
}
