/* AI Configuration Styles */

.ai-config-card {
  background: var(--surface-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.ai-config-card h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-config-card .no-config {
  color: var(--text-secondary);
  margin: 0 0 1rem 0;
  font-style: italic;
}

.ai-config-card .config-display {
  margin-bottom: 1rem;
}

.ai-config-card .config-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.ai-config-card .config-item:last-of-type {
  border-bottom: none;
}

.ai-config-card .config-item label {
  font-weight: 500;
  color: var(--text-secondary);
}

.ai-config-card .config-item span {
  font-weight: 600;
  color: var(--text-color);
}

.ai-config-card .config-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* AI Configuration Card Buttons */
.ai-config-card .configure-ai-btn,
.ai-config-card .edit-ai-btn,
.ai-config-card .delete-ai-btn {
  background: var(--surface-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-config-card .configure-ai-btn:hover,
.ai-config-card .edit-ai-btn:hover {
  background-color: var(--surface-offset);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.ai-config-card .delete-ai-btn,
.ai-config-card .config-actions .danger-btn {
  background: var(--danger-color);
  color: white;
  border: 1px solid var(--danger-color);
}

.ai-config-card .delete-ai-btn:hover,
.ai-config-card .config-actions .danger-btn:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.ai-config-card .configure-ai-btn:active,
.ai-config-card .edit-ai-btn:active,
.ai-config-card .delete-ai-btn:active {
  transform: translateY(0) scale(0.98);
}

[data-theme="dark"] .ai-config-card .configure-ai-btn,
[data-theme="dark"] .ai-config-card .edit-ai-btn {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .ai-config-card .configure-ai-btn:hover,
[data-theme="dark"] .ai-config-card .edit-ai-btn:hover {
  background-color: #273548;
  border-color: #475569;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* AI Configuration Modal */

.ai-config-modal-content {
  max-width: 600px;
}

.ai-config-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.ai-config-tabs .tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: var(--bg-color);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.ai-config-tabs .tab-btn:hover {
  background: var(--surface-offset);
  color: var(--text-color);
}

.ai-config-tabs .tab-btn.active {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
}

.password-wrapper input {
  flex: 1;
  padding-right: 3rem;
}

.password-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: auto !important;
}

.password-toggle .eye-icon,
.password-toggle .eye-off-icon {
  stroke: var(--text-color);
  transition: stroke 0.2s;
  pointer-events: none;
}

.password-toggle.hidden {
  display: none;
}

.eye-icon.hidden,
.eye-off-icon.hidden {
  display: none;
}

.form-help {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.form-help a {
  color: var(--primary-color);
  text-decoration: none;
}

.form-help a:hover {
  text-decoration: underline;
}

/* Test Connection Status */

.ai-status-section {
  margin-top: 1.5rem;
}

.test-connection-btn {
  margin-right: auto;
  background: linear-gradient(
    135deg,
    rgba(239, 246, 255, 0.85) 0%,
    rgba(244, 249, 255, 0.7) 100%
  );
  color: var(--text-color);
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .test-connection-btn {
  background: linear-gradient(
    135deg,
    rgba(30, 64, 175, 0.35) 0%,
    rgba(37, 99, 235, 0.25) 100%
  );
  border-color: rgba(96, 165, 250, 0.25);
  color: #f1f5f9;
}

.test-connection-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(239, 246, 255, 0.95) 0%,
    rgba(244, 249, 255, 0.85) 100%
  );
  border-color: rgba(59, 130, 246, 0.35);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .test-connection-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(30, 64, 175, 0.45) 0%,
    rgba(37, 99, 235, 0.35) 100%
  );
  border-color: rgba(96, 165, 250, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.test-connection-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Cancel Button for AI Configuration Modal */
.ai-config-modal-content .cancel-btn {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-color);
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .ai-config-modal-content .cancel-btn {
  background: #1e293b;
  border-color: #334155;
}

.ai-config-modal-content .cancel-btn:hover {
  background-color: var(--surface-offset);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .ai-config-modal-content .cancel-btn:hover {
  background-color: #273548;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.ai-config-modal-content .cancel-btn:active {
  transform: translateY(0) scale(0.98);
}

.test-status {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.test-status.testing {
  background: var(--bg-color);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.test-status.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #34d399;
}

.test-status.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #f87171;
}

.test-status small {
  display: block;
  margin-top: 0.25rem;
  opacity: 0.8;
}

[data-theme="dark"] .test-status.success {
  background: #064e3b;
  color: #a7f3d0;
  border-color: #059669;
}

[data-theme="dark"] .test-status.error {
  background: #7f1d1d;
  color: #fecaca;
  border-color: #dc2626;
}

/* Ollama Status Badge in AI Config Card */

.ollama-status-wrapper {
  align-items: center;
}

.ollama-status-badge-small {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-color);
  border: 1px solid var(--border-color);
}

.status-indicator-small {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator-small.running {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-indicator-small.model_missing {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.status-indicator-small.not_running {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.status-indicator-small.loading {
  background: #6b7280;
  animation: pulse-small 1.5s ease-in-out infinite;
}

.status-text-small {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-color);
}

@keyframes pulse-small {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Responsive */

@media (max-width: 768px) {
  .ai-config-tabs {
    flex-wrap: wrap;
  }

  .ai-config-tabs .tab-btn {
    flex: 1;
    min-width: 120px;
  }

  .config-actions {
    flex-direction: column;
  }

  .config-actions button {
    width: 100%;
  }
}
