/* Form Components and Validation */

/* Profile Form Modal */
.profile-form-modal {
  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: 10000;
  backdrop-filter: blur(8px);
}

.profile-form-container {
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  width: 90vw;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.profile-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
}

.profile-form-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.profile-form-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-form-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.profile-form-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* Form Groups and Labels */
.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-label.required::after {
  content: ' *';
  color: var(--danger-color);
}

/* Form Inputs */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  font-size: 14px;
  color: var(--text-primary);
  transition: all 0.3s ease;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* API Key Field with Toggle */
.api-key-field {
  position: relative;
}

.api-key-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.api-key-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.api-key-input {
  padding-right: 40px;
}

/* Form Actions */
.profile-form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 24px 32px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.form-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 100px;
}

.form-btn.primary {
  background: var(--primary-color);
  color: white;
}

.form-btn.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 122, 204, 0.3);
}

.form-btn.secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.form-btn.secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.form-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Success/Error Messages */
.form-message {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}

.form-message.success {
  background: rgba(40, 167, 69, 0.1);
  color: var(--accent-color);
  border: 1px solid rgba(40, 167, 69, 0.3);
}

.form-message.error {
  background: rgba(220, 53, 69, 0.1);
  color: var(--danger-color);
  border: 1px solid rgba(220, 53, 69, 0.3);
}

/* Form Validation */
.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-error {
  font-size: 12px;
  color: var(--danger-color);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-error::before {
  content: '⚠️';
  font-size: 10px;
}

/* JSON Validation Styles */
.json-input {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  tab-size: 2;
}

.json-input.json-valid {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.json-input.json-invalid {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.json-validation-feedback {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.json-success {
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 6px;
}

.json-success::before {
  content: '✓';
  font-weight: bold;
  font-size: 14px;
}

.json-error {
  color: var(--danger-color);
  display: flex;
  align-items: center;
  gap: 6px;
}

.json-error::before {
  content: '✗';
  font-weight: bold;
  font-size: 14px;
}

/* JSON syntax highlighting for better UX */
.json-input:focus {
  background: var(--bg-primary);
}

.json-input:invalid {
  border-color: var(--danger-color);
}

/* Enhanced form textarea for JSON */
.form-textarea.json-input {
  resize: vertical;
  min-height: 120px;
  white-space: pre;
  word-wrap: break-word;
}

/* JSON validation feedback animations */
.json-validation-feedback {
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.json-validation-feedback:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

/* Uploaded Files List Styles */
.uploaded-files-container {
  margin-top: 4px;
  margin-bottom: 4px;
  display: none;
}

.files-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.file-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: #f0f0f0;
  border: 1px solid #d0d0d0;
  border-radius: 12px;
  font-size: 11px;
  color: #555;
  max-width: 150px;
}

.file-item:hover {
  background: #e8e8e8;
}

.file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.file-remove-btn {
  background: #999;
  color: white;
  border: none;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.file-remove-btn:hover {
  background: #666;
}

.file-remove-btn:active {
  transform: scale(0.9);
}