/**
 * @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 {
  overflow: hidden;
  border: var(--fd-border-width) solid var(--fd-border);
  border-radius: var(--fd-radius-xl);
  background-color: var(--fd-card);
}

.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;
  color: var(--fd-primary);
  font-size: var(--fd-text-base);
  font-weight: var(--fd-font-weight-semibold);
}

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

.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;
  padding: var(--fd-space-4);
  cursor: pointer;
  transition:
    border-color var(--fd-transition-fast),
    box-shadow var(--fd-transition-fast),
    background-color var(--fd-transition-fast);
  border: var(--fd-border-width) solid var(--fd-border);
  border-radius: var(--fd-radius-lg);
  background-color: var(--fd-background);
  gap: var(--fd-space-3);
}

.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;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
}

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

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

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

/* 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;
  color: var(--fd-foreground);
  font-size: var(--fd-text-sm);
  font-weight: var(--fd-font-weight-semibold);
  line-height: var(--fd-line-height-normal);
}

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

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

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

.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);
}
