/* Settings Modal Styles - Modern Three-Tab Design */

/* Settings Modal Container */
.settings-modal-content {
  width: 92vw;
  max-width: 1000px;
  min-height: 75vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

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

.settings-header h3 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.5px;
}

/* Settings Title with Logo */
.settings-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.5px;
}

.settings-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

/* Tab Navigation */
.settings-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.settings-tab {
  flex: 1;
  padding: 16px 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  white-space: nowrap;
  min-width: 150px;
}

.settings-tab::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.settings-tab:hover {
  color: var(--text-primary);
  background: rgba(0, 122, 204, 0.05);
}

.settings-tab.active {
  color: var(--primary-color);
  background: var(--bg-primary);
}

.settings-tab.active::before {
  transform: scaleX(1);
}

/* Tab Content Container */
.settings-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.settings-tab-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  display: none;
}

.settings-tab-content.active {
  display: flex;
  flex-direction: column;
}

.settings-tab-content::-webkit-scrollbar {
  width: 8px;
}

.settings-tab-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.settings-tab-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.settings-tab-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Profile Cards */
.profiles-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.profile-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.profile-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.profile-card:hover {
  border-color: var(--primary-color);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 122, 204, 0.15);
}

.profile-card:hover::before {
  transform: scaleX(1);
}

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.profile-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-badge.default {
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.1), rgba(40, 167, 69, 0.2));
  color: var(--accent-color);
  border: 1px solid rgba(40, 167, 69, 0.3);
}

.profile-badge.active {
  background: linear-gradient(135deg, rgba(0, 122, 204, 0.1), rgba(0, 122, 204, 0.2));
  color: var(--primary-color);
  border: 1px solid rgba(0, 122, 204, 0.3);
}

.profile-badge.inactive {
  background: linear-gradient(135deg, rgba(108, 117, 125, 0.1), rgba(108, 117, 125, 0.2));
  color: var(--text-muted);
  border: 1px solid rgba(108, 117, 125, 0.3);
}

.profile-details {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.profile-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.profile-meta-item {
  display: flex;
  flex-direction: column;
}

.profile-meta-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.profile-meta-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
}

.profile-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.profile-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.profile-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.profile-btn.edit {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.profile-btn.edit:hover {
  background: var(--primary-color);
  color: white;
}

.profile-btn.delete {
  border-color: var(--danger-color);
  color: var(--danger-color);
}

.profile-btn.delete:hover {
  background: var(--danger-color);
  color: white;
}

.profile-btn.toggle {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.profile-btn.toggle:hover {
  background: var(--accent-color);
  color: white;
}

/* Add Profile Button */
.add-profile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 20px;
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 16px;
}

.add-profile-btn:hover {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, var(--bg-hover), var(--bg-secondary));
  color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 122, 204, 0.15);
}

.add-profile-btn svg {
  width: 20px;
  height: 20px;
}

/* Empty State */
.profiles-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
  color: var(--text-muted);
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  border-radius: 16px;
  border: 2px dashed var(--border-color);
  margin-bottom: 24px;
}

.profiles-empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.6;
}

.profiles-empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.profiles-empty-description {
  font-size: 15px;
  line-height: 1.6;
  opacity: 0.8;
  max-width: 320px;
}

/* 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-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-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;
}

/* Environment Variables Tab */
.env-variables-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.env-var-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.env-var-key,
.env-var-value {
  flex: 1;
}

.readonly-input {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}

.readonly-input:focus {
  outline: none !important;
  box-shadow: none !important;
  border-color: var(--border-color) !important;
}

.env-var-actions {
  display: flex;
  gap: 4px;
}

.env-var-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.env-var-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.env-var-btn.delete:hover {
  background: rgba(220, 53, 69, 0.1);
  color: var(--danger-color);
}

.add-env-var-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.add-env-var-btn:hover {
  border-color: var(--primary-color);
  background: rgba(0, 122, 204, 0.05);
  color: var(--primary-color);
}

/* Environment Variables Action Center */
.env-var-actions-center {
  display: flex;
  justify-content: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.save-env-vars-btn-modern {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 32px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 122, 204, 0.2);
  position: relative;
  overflow: hidden;
}

.save-env-vars-btn-modern::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.save-env-vars-btn-modern:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 122, 204, 0.3);
  background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
}

.save-env-vars-btn-modern:hover::before {
  left: 100%;
}

.save-env-vars-btn-modern:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(0, 122, 204, 0.2);
}

.save-env-vars-btn-modern .btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.save-env-vars-btn-modern .btn-text {
  font-weight: 600;
  letter-spacing: 0.5px;
}

.save-env-vars-btn-modern:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: 0 4px 12px rgba(0, 122, 204, 0.1) !important;
}

.save-env-vars-btn-modern:disabled::before {
  display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  .settings-modal-content {
    width: 95vw;
    max-height: 95vh;
    border-radius: 12px;
  }
  
  .settings-header {
    padding: 20px 24px;
  }
  
  .settings-header h3 {
    font-size: 20px;
  }
  
  .settings-tab {
    padding: 14px 20px;
    font-size: 14px;
    min-width: 120px;
  }
  
  .settings-tab-content {
    padding: 24px;
  }
  
  .profile-card {
    padding: 16px;
  }
  
  .profile-name {
    font-size: 16px;
  }
  
  .profile-meta {
    grid-template-columns: 1fr;
  }
  
  .profile-actions {
    flex-direction: column;
  }
  
  .profile-btn {
    width: 100%;
    justify-content: center;
  }
  
  .profile-form-container {
    width: 95vw;
  }
  
  .profile-form-header {
    padding: 20px 24px;
  }
  
  .profile-form-content {
    padding: 24px;
  }
  
  .profile-form-actions {
    padding: 20px 24px;
    flex-direction: column;
  }
  
  .form-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .settings-header {
    padding: 16px 20px;
  }
  
  .settings-header h3 {
    font-size: 18px;
  }
  
  .settings-tab {
    padding: 12px 16px;
    font-size: 13px;
    min-width: 100px;
  }
  
  .settings-tab-content {
    padding: 20px;
  }
  
  .profile-card {
    padding: 12px;
  }
  
  .profile-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .profile-badges {
    align-self: flex-end;
  }
  
  .env-var-item {
    flex-direction: column;
    gap: 8px;
  }
  
  .env-var-actions {
    align-self: flex-end;
  }
}

/* Loading States */
.profiles-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 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);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .profile-card,
  .form-input,
  .form-select,
  .form-textarea {
    border-width: 2px;
  }
  
  .settings-tab::before {
    height: 4px;
  }
}

/* Dark mode support (for future enhancement) */
@media (prefers-color-scheme: dark) {
  .profile-form-modal {
    backdrop-filter: blur(12px);
  }
}

/* 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);
}