/**
 * СамНашёл — UI Kit Components
 * Эталон макета: v2 (см. layout.css)
 */

@import url("base.css");
@import url("layout.css");

/* —— Logo —— */
.sn-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}

.sn-logo__mark {
  width: 28px;
  height: 28px;
  background: var(--ink);
  border-radius: 6px;
  clip-path: polygon(0 0, 100% 0, 100% 55%, 55% 100%, 0 100%);
  flex-shrink: 0;
}

/* —— Buttons —— */
.sn-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 52px;
  padding: 0 28px;
  border-radius: var(--radius-btn);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    opacity var(--duration-fast) var(--ease-out);
}

.sn-btn--sm {
  height: 40px;
  padding: 0 18px;
  font-size: 0.65rem;
}

.sn-btn--primary {
  background: var(--accent);
  color: var(--ink);
}

.sn-btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.sn-btn--ghost {
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}

.sn-btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.65);
}

.sn-btn--outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--ink);
}

.sn-btn--outline:hover:not(:disabled) {
  background: var(--card);
}

.sn-btn--ink {
  background: var(--ink);
  color: #fff;
}

.sn-btn--ink:hover:not(:disabled) {
  opacity: 0.88;
}

.sn-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sn-btn--loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.sn-btn--loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sn-spin 0.6s linear infinite;
  color: var(--ink);
}

@keyframes sn-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .sn-btn--loading::after {
    animation: none;
    border-right-color: currentColor;
    opacity: 0.5;
  }
}

/* —— Badges / Match chips —— */
.sn-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}

.sn-badge--same,
.sn-badge--similar,
.sn-badge--analog {
  background: var(--match-chip-bg);
  color: var(--match-chip-ink);
  border-color: var(--match-chip-border);
}

.sn-badge--best {
  background: var(--match-best-bg);
  color: var(--match-best-ink);
  border-color: var(--match-best-border);
}

.sn-badge--neutral {
  background: var(--surface);
  color: var(--ink-muted);
}

/* —— Modal —— */
.sn-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--gutter);
}

.sn-modal[hidden] {
  display: none;
}

.sn-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.45);
  border: none;
  cursor: pointer;
}

.sn-modal__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: min(90vh, 720px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius-panel);
  padding: var(--space-8) var(--space-6);
  box-shadow: var(--shadow-md);
}

.sn-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--card);
  color: var(--ink-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.sn-modal__close:hover {
  background: var(--card-muted);
  color: var(--ink);
}

.sn-modal__title {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
  padding-right: 40px;
}

.sn-modal__lead {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  line-height: 1.45;
  margin-bottom: var(--space-6);
}

.sn-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.sn-modal__actions .sn-btn {
  flex: 1;
  min-width: 120px;
}

/* —— Pills —— */
.sn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-btn);
  background: var(--card);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.sn-pill strong {
  color: var(--ink);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

/* —— Form controls —— */
.sn-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sn-field__label {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
}

.sn-input {
  height: 52px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--card);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.sn-input::placeholder {
  color: var(--ink-subtle);
}

.sn-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.sn-input--error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-bg);
}

.sn-field__hint {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  line-height: 1.4;
}

.sn-field__error {
  font-size: var(--text-sm);
  color: var(--error);
  line-height: 1.4;
}

.sn-select {
  height: 40px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%230a0a0a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  appearance: none;
  font-size: 0.8rem;
  font-weight: 500;
}

.sn-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.sn-textarea,
.sn-input.sn-textarea,
.v2-suggest-textarea {
  height: auto;
  min-height: 88px;
  padding: 14px 18px;
  resize: vertical;
  line-height: 1.45;
}

/* —— Nav —— */
.sn-nav {
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.sn-nav__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* —— Tabs —— */
.sn-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sn-tab {
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink-muted);
  border: 1px solid transparent;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.sn-tab:hover {
  color: var(--ink);
}

.sn-tab[aria-selected="true"],
.sn-tab--active {
  background: var(--card);
  color: var(--ink);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.sn-tab__count {
  opacity: 0.7;
  margin-left: 2px;
}

/* —— Panel / Card shells —— */
.sn-panel {
  background: var(--surface);
  border-radius: var(--radius-panel);
  padding: var(--space-8) var(--space-6);
}

.sn-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  border: 1px solid transparent;
}

.sn-card--bordered {
  border-color: var(--border);
}

.sn-card--best {
  border-color: var(--match-best-border);
  box-shadow: 0 0 0 1px var(--match-best-border);
}

/* —— Alert / Status banners —— */
.sn-alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-btn);
  font-size: var(--text-sm);
  line-height: 1.45;
  border: 1px solid transparent;
}

.sn-alert--info {
  background: var(--info-bg);
  color: var(--info);
  border-color: rgba(30, 74, 122, 0.15);
}

.sn-alert--warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: rgba(138, 90, 0, 0.15);
}

.sn-alert--error {
  background: var(--error-bg);
  color: var(--error);
  border-color: rgba(155, 44, 44, 0.15);
}

.sn-alert--success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(45, 106, 62, 0.15);
}

.sn-alert__title {
  font-weight: 600;
  margin-bottom: 2px;
}

/* —— Empty state —— */
.sn-empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px dashed var(--border-strong);
}

.sn-empty__icon {
  font-size: 2rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.sn-empty__title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.sn-empty__text {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  max-width: 24rem;
  margin-inline: auto;
  line-height: 1.5;
}

/* —— Skeleton —— */
.sn-skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--card-muted) 50%,
    var(--surface) 100%
  );
  background-size: 200% 100%;
  animation: sn-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes sn-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sn-skeleton {
    animation: none;
    background: var(--surface);
  }
}

/* —— Toast —— */
.sn-toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-btn);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.sn-toast--visible {
  opacity: 1;
  pointer-events: auto;
}

.sn-toast__link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-left: 4px;
}

.sn-toast__link:hover {
  opacity: 0.85;
}

.sn-btn--saved {
  background: var(--ink) !important;
  color: #fff !important;
  border-color: var(--ink) !important;
}

/* —— Spec row (характеристики) —— */
.sn-spec-grid {
  display: grid;
  gap: var(--space-2);
}

.sn-spec-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--text-sm);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.sn-spec-row:last-child {
  border-bottom: none;
}

.sn-spec-row__key {
  color: var(--ink-muted);
}

.sn-spec-row__val {
  font-weight: 500;
  text-align: right;
}

.sn-spec-row__val--warn {
  color: var(--warning);
}

.sn-spec-row__val--match {
  color: var(--success);
}

/* —— Price block —— */
.sn-price {
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.sn-price--lg {
  font-size: 2rem;
}

.sn-price__unit {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.sn-price-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.sn-price-delta--save {
  background: var(--success-bg);
  color: var(--success);
}

.sn-price-delta--more {
  background: var(--error-bg);
  color: var(--error);
}

/* —— Offer card (product comparison) —— */
.sn-offer {
  display: grid;
  gap: var(--space-4);
}

.sn-offer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.sn-offer__store {
  font-size: var(--text-lg);
  font-weight: 600;
}

.sn-offer__title {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  line-height: 1.4;
}

.sn-offer__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.sn-offer__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sn-offer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.sn-offer__price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
}

/* —— Match trust panel —— */
.sn-trust {
  background: var(--card-muted);
  border-radius: var(--radius-btn);
  padding: var(--space-4);
  border: 1px solid var(--border);
}

.sn-trust__title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-bottom: var(--space-3);
}

.sn-trust__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sn-trust__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.sn-trust__icon--ok {
  color: var(--success);
  flex-shrink: 0;
}

.sn-trust__icon--warn {
  color: var(--warning);
  flex-shrink: 0;
}

/* —— Toolbar (sort + filter) —— */
.sn-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.sn-toolbar__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* —— Sticky mobile bar —— */
.sn-sticky-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  padding: var(--space-3) var(--gutter);
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-sticky);
}

@media (max-width: 767px) {
  .sn-sticky-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .sn-sticky-bar-spacer {
    height: 72px;
  }
}

/* —— Kit showcase layout —— */
.sn-kit-section {
  margin-bottom: var(--space-12);
}

.sn-kit-section__title {
  font-size: var(--text-2xl);
  font-weight: 500;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-2);
}

.sn-kit-section__desc {
  color: var(--ink-muted);
  margin-bottom: var(--space-6);
  max-width: 40rem;
  line-height: 1.55;
}

.sn-kit-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-4);
}

.sn-kit-grid {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 700px) {
  .sn-kit-grid--2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sn-kit-swatch {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.sn-kit-token-list {
  display: grid;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-family: ui-monospace, monospace;
}

.sn-kit-token-list code {
  color: var(--ink-muted);
}
