/**
 * MCP Server Components Styles
 *
 * Styles for MCP Server UI components.
 */

/* ============ MCPServerCard ============ */

.mcp-server-card {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all 0.15s ease;
}

.mcp-server-card:hover {
  box-shadow: var(--shadow-sm);
}

.mcp-server-card__header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mcp-server-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--color-primary-bg);
  border-radius: var(--radius-md);
  color: var(--color-primary);
  flex-shrink: 0;
}

.mcp-server-card__title {
  flex: 1;
  min-width: 0;
}

.mcp-server-card__name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
}

.mcp-server-card__status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
}

.mcp-server-card__subtitle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.mcp-server-card__subtitle code {
  font-size: 0.75rem;
  background: var(--color-background);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
}

.mcp-server-card__menu-toggle {
  padding: 0.25rem;
  color: var(--color-text-secondary);
  background: none;
  border: none;
}

.mcp-server-card__menu-toggle::after {
  display: none;
}

.mcp-server-card__menu-toggle:hover {
  color: var(--color-text);
  background: var(--color-background);
  border-radius: var(--radius-sm);
}

.mcp-server-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.mcp-server-card__description {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.25rem;
}

.mcp-server-card__detail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.mcp-server-card__detail-label {
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.mcp-server-card__detail-value {
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mcp-server-card__detail-value code {
  font-size: 0.75rem;
  background: var(--color-background);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
}

.mcp-server-card__error {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.mcp-server-card__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

/* ============ MCPServerToolList ============ */

.mcp-tool-list {
  display: flex;
  flex-direction: column;
}

.mcp-tool-list--loading,
.mcp-tool-list--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--color-text-secondary);
  text-align: center;
}

.mcp-tool-list__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.mcp-tool-list__count {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.mcp-tool-list__actions {
  font-size: 0.8rem;
}

.mcp-tool-list__items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mcp-tool-list__item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: default;
}

.mcp-tool-list__item[role="checkbox"] {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.mcp-tool-list__item[role="checkbox"]:hover {
  background: var(--color-background);
}

.mcp-tool-list__item--selected {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.mcp-tool-list__checkbox {
  margin-top: 0.125rem;
  flex-shrink: 0;
}

.mcp-tool-list__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.mcp-tool-list__content {
  flex: 1;
  min-width: 0;
}

.mcp-tool-list__name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mcp-tool-list__name code {
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--color-background);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
}

.mcp-tool-list__description {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* Compact mode */
.mcp-tool-list--compact .mcp-tool-list__item {
  padding: 0.375rem 0.5rem;
}

.mcp-tool-list--compact .mcp-tool-list__name code {
  font-size: 0.75rem;
}

/* ============ TransportConfigForm ============ */

.transport-config-form {
  display: flex;
  flex-direction: column;
}

.transport-type-selector {
  display: flex;
  gap: 0.75rem;
}

.transport-type-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.transport-type-option:hover {
  border-color: var(--color-primary);
}

.transport-type-option.active {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.transport-type-option:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.transport-type-option svg {
  color: var(--color-primary);
  flex-shrink: 0;
}

.transport-type-option__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
}

.transport-type-option__desc {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

/* ============ MCP Servers Page ============ */

.mcp-servers-page {
  height: 100%;
  overflow-y: auto;
  padding: 1.5rem;
}

.mcp-servers-page__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.mcp-servers-page__title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.mcp-servers-page__subtitle {
  color: var(--color-text-secondary);
  margin: 0.25rem 0 0;
}

.mcp-servers-page__actions {
  display: flex;
  gap: 0.5rem;
}

.mcp-servers-page__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1rem;
}

.mcp-servers-page__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--color-text-secondary);
}

.mcp-servers-page__empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

.mcp-servers-page__empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.5rem;
}

.mcp-servers-page__empty-text {
  margin: 0 0 1rem;
  max-width: 320px;
}

.mcp-servers-page__empty-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============ MCPTemplateCard ============ */

.mcp-template-card {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mcp-template-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.mcp-template-card:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.mcp-template-card--selected {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.mcp-template-card__header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mcp-template-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--color-primary-bg);
  border-radius: var(--radius-md);
  color: var(--color-primary);
  flex-shrink: 0;
}

.mcp-template-card__title {
  flex: 1;
  min-width: 0;
}

.mcp-template-card__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.mcp-template-card__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mcp-template-card__category {
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.4rem;
}

.mcp-template-card__popularity {
  display: flex;
  align-items: center;
  gap: 1px;
}

.mcp-template-card__popularity .star-filled {
  color: #f59e0b;
  fill: #f59e0b;
}

.mcp-template-card__popularity .star-empty {
  color: var(--color-border);
}

.mcp-template-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mcp-template-card__description {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mcp-template-card__requirements {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mcp-template-card__requirement {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  background: var(--color-background);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
}

.mcp-template-card__requirement--prereq {
  color: #6366f1;
  background: #eef2ff;
}

.mcp-template-card__requirement--env {
  color: #f59e0b;
  background: #fffbeb;
}

.mcp-template-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: auto;
}

.mcp-template-card__tag {
  display: inline-block;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  background: var(--color-background);
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
}

.mcp-template-card__footer {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

.mcp-template-card__link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  text-decoration: none;
}

.mcp-template-card__link:hover {
  color: var(--color-primary);
}

/* ============ MCPTemplateSelector ============ */

.mcp-template-selector-modal .modal-dialog {
  max-width: 1000px;
}

.mcp-template-selector__toolbar {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-background);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mcp-template-selector__search {
  position: relative;
  display: flex;
  align-items: center;
}

.mcp-template-selector__search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--color-text-muted);
  pointer-events: none;
}

.mcp-template-selector__search-input {
  padding-left: 2.25rem;
  padding-right: 2rem;
}

.mcp-template-selector__search-clear {
  position: absolute;
  right: 0.5rem;
  padding: 0.25rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mcp-template-selector__search-clear:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.mcp-template-selector__categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.mcp-template-selector__category-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.mcp-template-selector__category-tab:hover {
  color: var(--color-text);
  background: var(--color-background);
}

.nav-pills .mcp-template-selector__category-tab.active {
  color: white;
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.mcp-template-selector__category-count {
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
}

.nav-pills .mcp-template-selector__category-tab.active .mcp-template-selector__category-count {
  background: rgba(255, 255, 255, 0.2);
}

.mcp-template-selector__body {
  padding: 1rem;
  max-height: 60vh;
  overflow-y: auto;
}

.mcp-template-selector__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.mcp-template-selector__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
  color: var(--color-text-secondary);
}

.mcp-template-selector__empty svg {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.mcp-template-selector__empty h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.5rem;
}

.mcp-template-selector__empty p {
  margin: 0;
  font-size: 0.85rem;
}

.mcp-template-selector__footer-info {
  flex: 1;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* ============ Template Required Fields ============ */

.template-required-fields {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.template-required-fields__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
}

.template-required-fields__description {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

/* Prerequisites Section */
.template-required-fields__prerequisites {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.template-required-fields__prereq-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.template-required-fields__prereq-list {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.template-required-fields__prereq-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #6366f1;
  background: #eef2ff;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s ease;
}

.template-required-fields__prereq-badge:hover {
  background: #e0e7ff;
  color: #4f46e5;
}

/* Setup Instructions */
.template-required-fields__instructions {
  margin-bottom: 1rem;
  padding: 0.75rem;
  font-size: 0.85rem;
}

.template-required-fields__instructions-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.template-required-fields__instructions-text {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--color-text);
}

.template-required-fields__section {
  margin-top: 0.5rem;
}

/* ============ Connector Auth Toggle ============ */

.connector-auth-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.connector-auth-toggle .form-check {
  margin: 0;
  padding-left: 1.5rem;
}

.connector-auth-toggle .form-check-input {
  margin-top: 0.25rem;
}

.connector-auth-toggle__label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text);
}

.connector-auth-toggle__label svg {
  color: var(--color-text-secondary);
}

.connector-auth-toggle .badge {
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.2rem 0.4rem;
}

/* Connector select wrapper */
.connector-select-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.connector-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

.connector-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}

/* Connector field with icon */
.connector-field-with-icon {
  position: relative;
}

.connector-field-with-icon__icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.connector-field-with-icon .form-select,
.connector-field-with-icon .form-control {
  padding-left: 2.25rem;
}

/* Animation for spinner */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 1s linear infinite;
}
