/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  overflow-y: auto;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  padding: 30px;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content-large {
  background: var(--bg-card);
  padding: 30px;
  border-radius: 8px;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-large {
  max-width: 700px;
}

.modal-content h2,
.modal-content-large h2 {
  margin-bottom: 20px;
  color: var(--text-primary);
}

.modal-content .form-group {
  margin-bottom: 15px;
}

.modal-content label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
}

.modal-content textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

.modal-content .button-group,
.modal-content-large .button-group {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-content button,
.modal-content-large button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

/* Confirm Dialog */
.confirm-dialog {
  background: var(--bg-card);
  padding: 30px;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.confirm-dialog h3 {
  margin-bottom: 15px;
  color: #e74c3c;
}

.confirm-dialog p {
  margin-bottom: 20px;
  color: var(--text-secondary);
}

/* Phaser Preview Container */
#phaserContainer {
  width: 800px;
  height: 600px;
  margin: 20px auto;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #000;
}

.preview-info {
  text-align: center;
  color: var(--text-secondary);
  margin: 15px 0;
  font-size: 14px;
}

.preview-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.preview-controls button {
  padding: 8px 16px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.preview-controls button:hover {
  background: #2980b9;
}

/* ============================================
   NPC MANAGER MODAL
   ============================================ */

.modal-content-xlarge {
  background: var(--bg-card);
  padding: 0;
  border-radius: 8px;
  max-width: 1100px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.npc-manager-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.npc-manager-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
}

.npc-manager-header .close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 4px;
  line-height: 1;
}

.npc-manager-header .close-btn:hover {
  background: var(--bg-hover);
}

/* Top section: NPC list + Map preview side by side */
.npc-manager-top {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 280px;
  max-height: 350px;
}

.npc-list-panel {
  width: 280px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-tertiary);
}

.npc-list-panel h3 {
  margin: 0;
  padding: 10px 15px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-hover);
}

.npc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.npc-list-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.npc-list-footer .npc-count {
  font-size: 12px;
  color: var(--text-secondary);
}

.npc-list-footer .btn-primary {
  font-size: 12px;
  padding: 6px 12px;
}

.npc-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.npc-list-item:hover {
  border-color: var(--accent);
}

.npc-list-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  border-width: 2px;
}

.npc-list-item.disabled {
  opacity: 0.5;
}

.npc-list-item .npc-status {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
}

.npc-list-item .npc-status:hover {
  background: var(--bg-hover);
}

.npc-list-item:not(.disabled) .npc-status {
  color: #27ae60;
}

.npc-list-item.disabled .npc-status {
  color: #e74c3c;
}

.npc-list-item .npc-name {
  flex: 1;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.npc-list-item .npc-type {
  font-size: 10px;
  padding: 2px 6px;
}

.empty-npc-list {
  text-align: center;
  padding: 30px 15px;
  color: var(--text-secondary);
  font-size: 13px;
}

.empty-npc-list .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Map Preview Panel */
.npc-map-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

.npc-map-panel h3 {
  margin: 0;
  padding: 10px 15px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-hover);
}

.npc-map-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.npc-map-preview canvas {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
}

/* Bottom section: Edit form */
.npc-manager-bottom {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 200px;
}

.npc-edit-header {
  padding: 10px 20px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.npc-edit-header strong {
  color: var(--text-primary);
}

.npc-edit-header .prototype-label {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 10px;
}

.npc-edit-form {
  flex: 1;
  overflow-y: auto;
  padding: 15px 20px;
}

.npc-edit-form .hint {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 20px;
  font-size: 14px;
}

.npc-edit-form .error {
  color: #e74c3c;
  text-align: center;
  padding: 40px 20px;
}

.npc-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.npc-edit-grid .form-group {
  margin: 0;
}

.npc-edit-grid .form-group label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}

.npc-edit-grid .form-group input,
.npc-edit-grid .form-group select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.npc-edit-grid .form-group input:focus,
.npc-edit-grid .form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.npc-edit-grid .checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.npc-edit-grid .checkbox-group input[type="checkbox"] {
  width: auto;
}

.npc-edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 15px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.npc-edit-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
