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

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

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

.modal-content-large { 
    background: white; 
    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: #333; 
}

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

.modal-content label { 
    display: block; 
    margin-bottom: 5px; 
    color: #666; 
    font-weight: 500; 
}

.modal-content input, 
.modal-content select,
.modal-content textarea { 
    width: 100%; 
    padding: 10px; 
    border: 1px solid #ddd; 
    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: white; 
    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: #666; 
}

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

.preview-info { 
    text-align: center; 
    color: #666; 
    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: white;
    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 #e0e0e0;
    background: #f8f9fa;
}

.npc-manager-header h2 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

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

.npc-manager-header .close-btn:hover {
    background: #e0e0e0;
}

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

.npc-list-panel {
    width: 280px;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

.npc-list-panel h3 {
    margin: 0;
    padding: 10px 15px;
    font-size: 13px;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
    background: #f0f0f0;
}

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

.npc-list-footer {
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    gap: 10px;
}

.npc-list-footer .npc-count {
    font-size: 12px;
    color: #666;
}

.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: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.npc-list-item:hover {
    border-color: #3498db;
}

.npc-list-item.selected {
    border-color: #3498db;
    background: #ebf5fb;
    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: #e0e0e0;
}

.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: #333;
    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: #666;
    font-size: 13px;
}

.empty-npc-list .hint {
    font-size: 12px;
    color: #999;
    margin-top: 8px;
}

/* Map Preview Panel */
.npc-map-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.npc-map-panel h3 {
    margin: 0;
    padding: 10px 15px;
    font-size: 13px;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
    background: #f0f0f0;
}

.npc-map-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #f8f8f8;
    overflow: hidden;
}

.npc-map-preview canvas {
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

/* 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: #f0f0f0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

.npc-edit-header strong {
    color: #333;
}

.npc-edit-header .prototype-label {
    color: #888;
    font-size: 12px;
    margin-left: 10px;
}

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

.npc-edit-form .hint {
    color: #999;
    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: #666;
    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 #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.npc-edit-grid .form-group input:focus,
.npc-edit-grid .form-group select:focus {
    outline: none;
    border-color: #3498db;
}

.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 #e0e0e0;
    background: #fafafa;
}

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