/* ============================================
   ChainStore Component Library
   Reusable UI component styles
   ============================================ */

/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  z-index: var(--z-toast);
  border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus { top: 0; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* === Container === */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-4);
}
@media (min-width: 1024px) {
  .container { padding: 0 var(--space-5); }
}

/* === Navbar === */
.navbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--header-height);
  padding: 0 var(--space-4);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-tertiary);
}
.navbar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--c-purple-800);
  white-space: nowrap;
}
.navbar__logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
}
.navbar__search {
  flex: 1;
  max-width: 400px;
  height: 36px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-tertiary);
  background: var(--bg-secondary);
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.navbar__search:focus { border-color: var(--color-primary); }
.navbar__actions { display: flex; gap: var(--space-2); align-items: center; margin-left: auto; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn--primary { background: var(--color-primary); color: var(--text-inverse); }
.btn--primary:hover:not(:disabled) { background: var(--color-primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn--secondary { background: var(--bg-primary); color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn--secondary:hover:not(:disabled) { background: var(--color-primary-light); }

.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover:not(:disabled) { background: var(--bg-secondary); color: var(--text-primary); }

.btn--danger { background: var(--color-error); color: #fff; }
.btn--danger:hover:not(:disabled) { filter: brightness(1.1); }

.btn--sm { min-height: 32px; padding: 6px 14px; font-size: var(--text-xs); }
.btn--lg { min-height: 48px; padding: 12px 28px; font-size: var(--text-base); }
.btn--block { width: 100%; }

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1.4;
}
.badge--verified { background: var(--color-success-light); color: var(--c-teal-800); border: 1px solid var(--c-teal-100); }
.badge--nft { background: var(--color-nft-light); color: var(--c-pink-800); border: 1px solid var(--c-pink-600); }
.badge--escrow { background: var(--color-primary-light); color: var(--c-purple-800); border: 1px solid var(--c-purple-100); }
.badge--warning { background: var(--color-warning-light); color: var(--c-amber-800); border: 1px solid var(--c-amber-100); }
.badge--info { background: var(--color-info-light); color: var(--c-blue-800); border: 1px solid var(--c-blue-100); }

/* === Price Display === */
.price { display: flex; flex-direction: column; gap: 2px; }
.price__crypto { font-size: var(--text-xl); font-weight: var(--font-weight-semibold); color: var(--c-purple-800); font-family: var(--font-mono); }
.price__fiat { font-size: var(--text-xs); color: var(--text-tertiary); }
.price__gas { font-size: var(--text-xs); color: var(--color-warning); }

/* === Cards === */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
}
.card--hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card__body { padding: var(--space-4); }

/* === Product Card === */
.product-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
  cursor: pointer;
}
.product-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product-card__image { height: 140px; position: relative; overflow: hidden; }
.product-card__badge { position: absolute; top: 8px; left: 8px; z-index: 1; }
.product-card__fav {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-primary); border: 1px solid var(--border-tertiary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition-fast);
}
.product-card__fav:hover { border-color: var(--color-error); }
.product-card__fav.active { background: var(--color-error-light); }
.product-card__info { padding: var(--space-3); }
.product-card__title { font-size: var(--text-sm); font-weight: var(--font-weight-medium); margin-bottom: 2px; }
.product-card__sub { font-size: var(--text-xs); color: var(--text-tertiary); margin-bottom: var(--space-2); }

/* === Grid === */
.grid { display: grid; gap: var(--space-4); }
.grid--products { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .grid--products { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .grid--products { grid-template-columns: repeat(4, 1fr); } }

.grid--2 { grid-template-columns: 1fr; }
@media (min-width: 768px) { .grid--2 { grid-template-columns: 1fr 1fr; } }

/* === Wallet Button === */
.wallet-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}
.wallet-btn:hover { border-color: var(--color-primary); }
.wallet-btn.active { border: 1.5px solid var(--color-primary); background: var(--color-primary-light); }
.wallet-btn__icon { width: 36px; height: 36px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.wallet-btn__icon--mm { background: var(--color-primary-light); }
.wallet-btn__icon--wc { background: var(--color-info-light); }
.wallet-btn__icon--cb { background: var(--color-success-light); }
.wallet-btn__text { flex: 1; text-align: left; }
.wallet-btn__name { font-size: var(--text-sm); font-weight: var(--font-weight-medium); }
.wallet-btn__desc { font-size: var(--text-xs); color: var(--text-tertiary); }

/* === Stepper === */
.stepper { display: flex; align-items: center; justify-content: center; gap: 4px; }
.stepper__step { display: flex; align-items: center; gap: var(--space-2); }
.stepper__circle {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: var(--font-weight-medium);
}
.stepper__step--done .stepper__circle { background: var(--color-success); color: #fff; }
.stepper__step--current .stepper__circle { background: var(--color-primary); color: #fff; }
.stepper__step--todo .stepper__circle { background: var(--bg-secondary); color: var(--text-tertiary); }
.stepper__line { width: 40px; height: 2px; }
.stepper__line--done { background: var(--c-teal-200); }
.stepper__line--todo { background: var(--bg-tertiary); }
.stepper__label { font-size: var(--text-xs); color: var(--text-secondary); }

/* === Language Switcher === */
.lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  min-height: 32px;
}
.lang-switcher:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.lang-switcher--open { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(83,74,183,0.12); }
.lang-switcher__globe {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--text-tertiary);
  position: relative; flex-shrink: 0;
  background: radial-gradient(circle at 30% 30%, var(--bg-primary) 2px, transparent 2px),
              linear-gradient(0deg, transparent 45%, var(--text-tertiary) 45%, var(--text-tertiary) 55%, transparent 55%),
              linear-gradient(90deg, transparent 45%, var(--text-tertiary) 45%, var(--text-tertiary) 55%, transparent 55%);
  background-size: 100% 100%;
}
.lang-switcher__current { font-weight: var(--font-weight-medium); color: var(--text-primary); white-space: nowrap; }
.lang-switcher__arrow {
  width: 0; height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid var(--text-tertiary);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}
.lang-switcher--open .lang-switcher__arrow { transform: rotate(180deg); }

.lang-switcher__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  z-index: var(--z-dropdown, 1000);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all var(--transition-fast);
  max-height: 360px;
  overflow-y: auto;
}
.lang-switcher--open .lang-switcher__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.lang-switcher__option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  white-space: nowrap;
}
.lang-switcher__option:hover { background: var(--bg-secondary); }
.lang-switcher__option--active { background: var(--color-primary-light); color: var(--color-primary); font-weight: var(--font-weight-medium); }
.lang-switcher__flag {
  width: 20px; height: 14px; border-radius: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.lang-switcher__check {
  margin-left: auto;
  font-size: 12px;
  color: var(--color-primary);
}

/* === Timeline === */
.timeline { list-style: none; padding: 0; }
.timeline__item { display: flex; gap: var(--space-4); padding-bottom: var(--space-5); position: relative; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 11px; color: #fff;
}
.timeline__dot--done { background: var(--color-success); }
.timeline__dot--current { background: var(--color-warning); }
.timeline__dot--todo { background: var(--bg-primary); border: 1.5px solid var(--border-tertiary); color: var(--text-tertiary); }
.timeline__item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 24px;
  bottom: 0;
  width: 2px;
  background: var(--border-tertiary);
}
.timeline__item--done:not(:last-child)::before { background: var(--c-teal-200); }
.timeline__item--current:not(:last-child)::before { background: var(--border-tertiary); }
.timeline__content { flex: 1; }
.timeline__title { font-size: var(--text-sm); font-weight: var(--font-weight-medium); }
.timeline__title--done, .timeline__title--current { color: var(--text-primary); }
.timeline__title--todo { color: var(--text-tertiary); }
.timeline__meta { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }

/* === Address / Hash Display === */
.address {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-primary);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}
.address:hover { opacity: 0.7; }

/* === Metric Card === */
.metric-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.metric-card__label { font-size: var(--text-xs); color: var(--text-tertiary); margin-bottom: var(--space-1); }
.metric-card__value { font-size: var(--text-2xl); font-weight: var(--font-weight-semibold); color: var(--c-purple-800); }
.metric-card__sub { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: var(--space-1); }

/* === Tab Bar === */
.tabbar {
  display: flex;
  gap: var(--space-5);
  padding: 0 var(--space-4);
  height: var(--tabbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-tertiary);
  overflow-x: auto;
}
.tabbar__item {
  display: flex;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  padding-top: 2px;
}
.tabbar__item:hover { color: var(--text-primary); }
.tabbar__item.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: var(--font-weight-medium); }

/* === Section Title === */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-lg);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  margin: var(--space-5) 0 var(--space-3);
}

/* === Callout === */
.callout {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
}
.callout--info { background: var(--color-primary-light); border-left: 3px solid var(--color-primary); }
.callout--warn { background: var(--color-warning-light); border-left: 3px solid var(--color-warning); }
.callout--success { background: var(--color-success-light); border-left: 3px solid var(--color-success); }

/* === Footer === */
.footer {
  background: var(--bg-secondary);
  padding: var(--space-6) var(--space-4);
  margin-top: var(--space-6);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}
@media (min-width: 768px) {
  .footer { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
.footer__brand { font-size: var(--text-lg); font-weight: var(--font-weight-semibold); color: var(--c-purple-800); }
.footer__col-title { font-size: var(--text-sm); font-weight: var(--font-weight-medium); margin-bottom: var(--space-2); }
.footer__link { display: block; font-size: var(--text-xs); color: var(--text-tertiary); padding: 2px 0; }

/* === Utility === */
.text-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-content; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.hidden { display: none; }
.w-full { width: 100%; }

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
