/**
 * @file
 * FlowDrop Plugin Selector Component Styles
 *
 * A grid-based plugin selector with provider grouping.
 * Uses FlowDrop design tokens for consistent styling.
 */

/* ========================================================================
 * CONTAINER
 * ======================================================================== */

.fd-plugin-selector {
  display: flex;
  flex-direction: column;
  gap: var(--fd-space-6);
}

/* ========================================================================
 * PROVIDER GROUP
 * ======================================================================== */

.fd-plugin-selector__group {
  background-color: var(--fd-card);
  border: var(--fd-border-width) solid var(--fd-border);
  border-radius: var(--fd-radius-xl);
  overflow: hidden;
}

.fd-plugin-selector__group-header {
  display: flex;
  align-items: center;
  gap: var(--fd-space-3);
  padding: var(--fd-space-4) var(--fd-space-5);
  border-block-end: var(--fd-border-width) solid var(--fd-border);
  background-color: var(--fd-muted);
}

.fd-plugin-selector__group-title {
  flex: 1;
  margin: 0;
  font-size: var(--fd-text-base);
  font-weight: var(--fd-font-weight-semibold);
  color: var(--fd-primary);
}

.fd-plugin-selector__group-count {
  font-size: var(--fd-text-sm);
  color: var(--fd-muted-foreground);
  background-color: var(--fd-subtle);
  padding: var(--fd-space-1) var(--fd-space-2);
  border-radius: var(--fd-radius-full);
}

.fd-plugin-selector__group-content {
  padding: var(--fd-space-4);
}

/* ========================================================================
 * PLUGIN GRID
 * ======================================================================== */

.fd-plugin-selector__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--fd-space-4);
  align-items: stretch;
}

/* ========================================================================
 * PLUGIN CARD
 * ======================================================================== */

.fd-plugin-selector__card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--fd-space-3);
  padding: var(--fd-space-4);
  background-color: var(--fd-background);
  border: var(--fd-border-width) solid var(--fd-border);
  border-radius: var(--fd-radius-lg);
  cursor: pointer;
  transition:
    border-color var(--fd-transition-fast),
    box-shadow var(--fd-transition-fast),
    background-color var(--fd-transition-fast);
}

.fd-plugin-selector__card:hover {
  border-color: var(--fd-primary);
  box-shadow: var(--fd-shadow-sm);
}

/* Selected state */
.fd-plugin-selector__card--selected {
  border-color: var(--fd-primary);
  background-color: var(--fd-primary-muted);
  box-shadow: 0 0 0 1px var(--fd-primary);
}

/* Focus state for accessibility */
.fd-plugin-selector__card:focus-within {
  outline: 2px solid var(--fd-ring);
  outline-offset: 2px;
}

/* ========================================================================
 * RADIO INPUT
 * ======================================================================== */

.fd-plugin-selector__radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* ========================================================================
 * RADIO INDICATOR
 * ======================================================================== */

.fd-plugin-selector__indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  margin-block-start: 0.125rem;
  border: 2px solid var(--fd-border-strong);
  border-radius: var(--fd-radius-full);
  background-color: var(--fd-background);
  transition:
    border-color var(--fd-transition-fast),
    background-color var(--fd-transition-fast);
}

.fd-plugin-selector__indicator::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--fd-radius-full);
  background-color: transparent;
  transition: background-color var(--fd-transition-fast);
}

/* Hover state */
.fd-plugin-selector__card:hover .fd-plugin-selector__indicator {
  border-color: var(--fd-primary);
}

/* Selected state */
.fd-plugin-selector__card--selected .fd-plugin-selector__indicator {
  border-color: var(--fd-primary);
}

.fd-plugin-selector__card--selected .fd-plugin-selector__indicator::after {
  background-color: var(--fd-primary);
}

/* ========================================================================
 * CARD CONTENT
 * ======================================================================== */

.fd-plugin-selector__content {
  flex: 1;
  min-width: 0;
}

.fd-plugin-selector__title {
  margin: 0;
  font-size: var(--fd-text-sm);
  font-weight: var(--fd-font-weight-semibold);
  color: var(--fd-foreground);
  line-height: var(--fd-line-height-normal);
}

.fd-plugin-selector__description {
  margin: var(--fd-space-1) 0 0;
  font-size: var(--fd-text-xs);
  color: var(--fd-muted-foreground);
  line-height: var(--fd-line-height-normal);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========================================================================
 * STAGGER ANIMATION
 * ======================================================================== */

@keyframes fd-plugin-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fd-plugin-selector--stagger .fd-plugin-selector__card {
  animation: fd-plugin-fade-in var(--fd-transition-normal) ease-out backwards;
}

.fd-plugin-selector--stagger .fd-plugin-selector__card:nth-child(1) { animation-delay: 0ms; }
.fd-plugin-selector--stagger .fd-plugin-selector__card:nth-child(2) { animation-delay: 30ms; }
.fd-plugin-selector--stagger .fd-plugin-selector__card:nth-child(3) { animation-delay: 60ms; }
.fd-plugin-selector--stagger .fd-plugin-selector__card:nth-child(4) { animation-delay: 90ms; }
.fd-plugin-selector--stagger .fd-plugin-selector__card:nth-child(5) { animation-delay: 120ms; }
.fd-plugin-selector--stagger .fd-plugin-selector__card:nth-child(6) { animation-delay: 150ms; }
.fd-plugin-selector--stagger .fd-plugin-selector__card:nth-child(n+7) { animation-delay: 180ms; }

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .fd-plugin-selector--stagger .fd-plugin-selector__card {
    animation: none;
  }
}

/* ========================================================================
 * RESPONSIVE ADJUSTMENTS
 * ======================================================================== */

@media (max-width: 640px) {
  .fd-plugin-selector__grid {
    grid-template-columns: 1fr;
    gap: var(--fd-space-3);
  }

  .fd-plugin-selector__group-header {
    padding: var(--fd-space-3) var(--fd-space-4);
  }

  .fd-plugin-selector__group-content {
    padding: var(--fd-space-3);
  }

  .fd-plugin-selector__card {
    padding: var(--fd-space-3);
  }

  .fd-plugin-selector__description {
    -webkit-line-clamp: 3;
  }
}

/* ========================================================================
 * EMPTY STATE
 * ======================================================================== */

.fd-plugin-selector__empty {
  padding: var(--fd-space-8);
  text-align: center;
  color: var(--fd-muted-foreground);
  font-size: var(--fd-text-sm);
}
