/* Overlay backdrop */
.nm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: nmFadeIn 0.2s ease-in;
}

@keyframes nmFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Main content container */
.nm-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 960px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: nmSlideUp 0.3s ease-out;
}

@keyframes nmSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Header */
.nm-header {
  padding: 20px 24px;
  border-bottom: 2px solid #667eea;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.nm-header h2 {
  margin: 0;
  color: #667eea;
  font-size: 22px;
}

.nm-close-button {
  background: none;
  border: none;
  font-size: 32px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.nm-close-button:hover {
  background: #f5f5f5;
  color: #333;
}

/* Body - two panels */
.nm-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left panel */
.nm-list-panel {
  width: 250px;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.nm-add-btn {
  margin: 12px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.nm-add-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

.nm-list {
  flex: 1;
  overflow-y: auto;
}

.nm-list-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.nm-list-item:hover {
  background: #f5f5ff;
}

.nm-list-item--active {
  background: #eef0ff;
  border-left: 3px solid #667eea;
}

.nm-list-item-info {
  flex: 1;
  min-width: 0;
}

.nm-list-item-name {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nm-list-item-meta {
  display: block;
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

.nm-edit-btn {
  background: none;
  border: none;
  color: #999;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.nm-edit-btn:hover {
  color: #667eea;
  background: #f0f0ff;
}

.nm-loading {
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.nm-empty {
  padding: 16px;
  text-align: center;
  color: #999;
  font-size: 13px;
}

/* Right panel */
.nm-form-panel {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

.nm-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 15px;
  padding: 40px;
  text-align: center;
}

.nm-form {
  padding: 20px 24px;
}

.nm-form-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
}

.nm-error {
  background-color: #fee;
  color: #c33;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #fcc;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Form grid */
.nm-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.nm-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nm-form-group label {
  font-weight: 600;
  color: #555;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nm-form-group input[type="text"],
.nm-form-group input[type="number"],
.nm-form-group select {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.nm-form-group input:focus,
.nm-form-group select:focus {
  outline: none;
  border-color: #667eea;
}

.nm-form-group input:disabled,
.nm-form-group select:disabled {
  background-color: #f5f5f5;
  cursor: not-allowed;
}

/* Sections */
.nm-section {
  margin-bottom: 20px;
}

.nm-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e0e0e0;
}

.nm-section-header h3 {
  margin: 0;
  font-size: 14px;
  color: #667eea;
  font-weight: 600;
}

.nm-section-add {
  background: none;
  border: 1px solid #667eea;
  color: #667eea;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.nm-section-add:hover {
  background: #667eea;
  color: white;
}

.nm-section-add:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Fields table */
.nm-fields-table {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}

.nm-fields-header {
  display: grid;
  grid-template-columns: 2fr 2fr 1.2fr 40px 32px;
  gap: 6px;
  padding: 6px 8px;
  background: #f8f8fc;
  font-size: 11px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nm-fields-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1.2fr 40px 32px;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid #f0f0f0;
  align-items: center;
}

.nm-fields-row input[type="text"] {
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}

.nm-fields-row input[type="text"]:focus {
  outline: none;
  border-color: #667eea;
}

.nm-fields-row select {
  padding: 5px 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}

.nm-fields-row select:focus {
  outline: none;
  border-color: #667eea;
}

.nm-fields-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  justify-self: center;
}

.nm-remove-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.nm-remove-btn:hover:not(:disabled) {
  color: #c33;
  background: #fee;
}

.nm-remove-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Entries */
.nm-entries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nm-entry {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.nm-entry--inactive {
  opacity: 0.5;
  background: #fafafa;
}

.nm-entry-fields {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nm-entry-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
  flex: 1;
}

.nm-entry-field label {
  font-size: 11px;
  color: #888;
  font-weight: 500;
}

.nm-entry-field input[type="text"],
.nm-entry-field input[type="number"],
.nm-entry-field select {
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}

.nm-entry-field input:focus,
.nm-entry-field select:focus {
  outline: none;
  border-color: #667eea;
}

.nm-entry-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 4px;
}

.nm-entry-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.nm-entry-save {
  background: #667eea;
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.nm-entry-save:hover {
  background: #5568d3;
}

.nm-entry-toggle {
  background: #e8f5e9;
  color: #2e7d32;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.nm-entry-toggle:hover {
  background: #c8e6c9;
}

.nm-entry-toggle--inactive {
  background: #fff3e0;
  color: #e65100;
}

.nm-entry-toggle--inactive:hover {
  background: #ffe0b2;
}

/* Form actions */
.nm-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.nm-form-actions-right {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.nm-cancel-btn {
  padding: 8px 20px;
  background: white;
  border: 1px solid #ddd;
  color: #666;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.nm-cancel-btn:hover:not(:disabled) {
  border-color: #999;
  color: #333;
}

.nm-save-btn {
  padding: 8px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.nm-save-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

.nm-save-btn:disabled,
.nm-cancel-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.nm-delete-btn {
  padding: 8px 16px;
  background: white;
  border: 1px solid #e57373;
  color: #c33;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.nm-delete-btn:hover:not(:disabled) {
  background: #fee;
}

.nm-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
  .nm-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .nm-body {
    flex-direction: column;
  }

  .nm-list-panel {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }

  .nm-form-grid {
    grid-template-columns: 1fr;
  }
}
