/* ═══════════════════════════════════════════════════════════════
   WawShopScan — Dark Premium Theme
   Brand colors from Lynxon TECH: #7052ef (purple), #221c3f (navy)
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg-base:      #09071a;
  --bg-surface:   #110e27;
  --bg-elevated:  #1a1540;
  --bg-hover:     #221d4a;

  --accent:       #7052ef;
  --accent-hover: #846aff;
  --accent-muted: #5a3fd4;
  --accent-glow:  rgba(112, 82, 239, 0.35);
  --accent-subtle:rgba(112, 82, 239, 0.08);
  --accent-border:rgba(112, 82, 239, 0.12);
  --accent-border-hover:rgba(112, 82, 239, 0.38);

  --text-primary:   #eae6f5;
  --text-secondary: #9790b0;
  --text-muted:     #5e5880;

  --success:  #34d399;
  --warning:  #fbbf24;
  --error:    #f87171;
  --facebook: #4599ff;

  --r-sm:   6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-pill:100px;

  --ease: cubic-bezier(.4, 0, .2, 1);
  --t-fast: .18s var(--ease);
  --t-med:  .28s var(--ease);
}


/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }


/* ── Selection & Scrollbar ──────────────────────────────────── */
::selection {
  background: rgba(112, 82, 239, 0.35);
  color: #fff;
}
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-muted); }


/* ── Background Atmosphere ──────────────────────────────────── */
html {
  background: var(--bg-base);
  min-height: 100vh;
}

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: transparent;
  color: var(--text-primary);
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Purple radial glow behind header area */
body::before {
  content: '';
  position: fixed;
  top: -280px;
  left: 50%;
  translate: -50% 0;
  width: 900px;
  height: 620px;
  background:
    radial-gradient(ellipse 60% 55% at 50% 40%, rgba(112, 82, 239, 0.13) 0%, transparent 100%),
    radial-gradient(ellipse 40% 30% at 65% 30%, rgba(132, 106, 255, 0.06) 0%, transparent 100%);
  pointer-events: none;
  z-index: -2;
}

/* Subtle noise texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
  background-size: 200px;
  pointer-events: none;
  z-index: 10000;
  opacity: 0.35;
  mix-blend-mode: overlay;
}


/* ═══════════════════════ HEADER ═══════════════════════════════ */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 24px 0 28px;
  margin-bottom: 20px;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent 0%, var(--accent-border-hover) 50%, transparent 100%) 1;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.header-logo {
  height: 46px;
  width: auto;
  filter: drop-shadow(0 0 14px rgba(112, 82, 239, 0.35));
  transition: filter var(--t-med);
}
.header-logo:hover {
  filter: drop-shadow(0 0 24px rgba(112, 82, 239, 0.55));
}

header h1 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #f0ecff 20%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

/* ═══════════════════ SUBTITLE ═══════════════════════════════ */
.subtitle {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  margin-top: 1px;
}


/* ═══════════════════ TAB NAV ═══════════════════════════════ */
.tab-nav {
  position: relative;
  display: flex;
  padding: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-lg);
  margin-bottom: 6px;
}

/* Sliding pill indicator */
.tab-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-muted) 100%);
  border-radius: var(--r-md);
  box-shadow:
    0 0 20px var(--accent-glow),
    0 2px 10px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: transform .35s cubic-bezier(.4, 0, .1, 1);
  z-index: 0;
}
.tab-nav[data-active="buy"] .tab-indicator {
  transform: translateX(100%);
}

.tab-btn {
  flex: 1;
  position: relative;
  z-index: 1;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 11px 24px;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: color .3s cubic-bezier(.4, 0, .1, 1);
  user-select: none;
}
.tab-btn:hover {
  color: var(--text-secondary);
}
.tab-btn.active {
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}


/* ═══════════════════ REFRESH BUTTON ══════════════════════════ */
#refresh-btn {
  padding: 10px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: all var(--t-fast);
  box-shadow: 0 0 0 0 transparent;
  position: relative;
  overflow: hidden;
}
#refresh-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
  pointer-events: none;
}
#refresh-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 24px var(--accent-glow), 0 4px 12px rgba(0,0,0,0.3);
  transform: translateY(-1px);
}
#refresh-btn:active {
  transform: translateY(0);
  box-shadow: 0 0 12px var(--accent-glow);
}
#refresh-btn:disabled {
  background: var(--accent-muted);
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}


/* ═══════════════════ SPINNER ═════════════════════════════════ */
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--accent-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none; }


/* ═══════════════════ SOURCE FILTERS ══════════════════════════ */
.source-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0 18px;
}
.source-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--accent-border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  user-select: none;
  transition: all var(--t-fast);
}
.source-filters label:hover {
  border-color: var(--accent-border-hover);
  background: var(--bg-elevated);
}
.source-filters label.active {
  border-color: var(--accent-border-hover);
  background: rgba(112, 82, 239, 0.1);
  color: var(--text-primary);
  box-shadow: 0 0 12px rgba(112, 82, 239, 0.08);
}
.source-filters input { display: none; }


/* ═══════════════════ FACEBOOK CARD ══════════════════════════ */
.facebook-card {
  background: linear-gradient(135deg, rgba(69, 153, 255, 0.1) 0%, rgba(69, 153, 255, 0.03) 100%);
  border: 1px solid rgba(69, 153, 255, 0.15);
  border-radius: var(--r-lg);
  padding: 14px 24px;
  margin-bottom: 20px;
  text-align: center;
  transition: all var(--t-med);
}
.facebook-card:hover {
  border-color: rgba(69, 153, 255, 0.35);
  background: linear-gradient(135deg, rgba(69, 153, 255, 0.14) 0%, rgba(69, 153, 255, 0.05) 100%);
  box-shadow: 0 0 20px rgba(69, 153, 255, 0.08);
}
.facebook-card a {
  color: var(--facebook);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}
.facebook-card a:hover { color: #7ab8ff; }


/* ═══════════════════ LISTINGS GRID ══════════════════════════ */
.listings {
  display: grid;
  gap: 10px;
}


/* ═══════════════════ LISTING CARD ════════════════════════════ */
.listing-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-surface);
  border-radius: var(--r-md);
  padding: 16px 18px;
  border: 1px solid var(--accent-border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  transition: all var(--t-med);
  animation: cardIn .45s var(--ease) both;
}

/* Left accent bar on hover */
.listing-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  border-radius: 0 2px 2px 0;
  transform: scaleY(0);
  transition: transform var(--t-med);
  transform-origin: center;
}
.listing-card:hover::before {
  transform: scaleY(1);
}

.listing-card:hover {
  border-color: var(--accent-border-hover);
  background: var(--bg-elevated);
  box-shadow:
    0 4px 24px rgba(112, 82, 239, 0.06),
    0 0 0 1px rgba(112, 82, 239, 0.06);
}

/* Staggered entrance */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.listing-card:nth-child(1)  { animation-delay:   0ms; }
.listing-card:nth-child(2)  { animation-delay:  35ms; }
.listing-card:nth-child(3)  { animation-delay:  70ms; }
.listing-card:nth-child(4)  { animation-delay: 105ms; }
.listing-card:nth-child(5)  { animation-delay: 140ms; }
.listing-card:nth-child(6)  { animation-delay: 175ms; }
.listing-card:nth-child(7)  { animation-delay: 210ms; }
.listing-card:nth-child(n+8){ animation-delay: 250ms; }


/* ═══════════════════ SOURCE BADGE ════════════════════════════ */
.source-badge {
  font-size: 0.62rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  color: white;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}


/* ═══════════════════ LISTING INFO ════════════════════════════ */
.listing-info { min-width: 0; }

.listing-title {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.listing-details {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}


/* ═══════════════════ LISTING ACTIONS ═════════════════════════ */
.listing-actions {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}
.listing-actions a {
  padding: 7px 18px;
  background: var(--accent-subtle);
  color: var(--accent-hover);
  text-decoration: none;
  border-radius: var(--r-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  transition: all var(--t-fast);
}
.listing-actions a:hover {
  background: rgba(112, 82, 239, 0.14);
  border-color: var(--accent-border-hover);
  color: #fff;
  box-shadow: 0 0 14px rgba(112, 82, 239, 0.1);
}


/* ═══════════════════ SOURCE FALLBACK / ERROR ═════════════════ */
.source-fallback {
  background: rgba(251, 191, 36, 0.04);
  border: 1px solid rgba(251, 191, 36, 0.15);
  border-radius: var(--r-md);
  padding: 14px 18px;
  font-size: 0.8rem;
  color: var(--warning);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
}
.fallback-text { font-size: 0.8rem; }
.fallback-link {
  padding: 7px 16px;
  background: rgba(251, 191, 36, 0.08);
  color: var(--warning);
  text-decoration: none;
  border-radius: var(--r-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all var(--t-fast);
}
.fallback-link:hover {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.25);
}


/* ═══════════════════ STATUS BAR ══════════════════════════════ */
.status-bar {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0;
  margin-top: 24px;
  border-top: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent 0%, var(--accent-border) 50%, transparent 100%) 1;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
}


/* ═══════════════════ SKELETON LOADING ════════════════════════ */
.skeleton-card {
  background: var(--bg-surface);
  border-radius: var(--r-md);
  padding: 16px;
  border: 1px solid var(--accent-border);
  height: 72px;
  animation: shimmer 2s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.15; }
}


/* ═══════════════════ DEEP SCAN INDICATORS ════════════════════ */
.scan-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.scan-indicator.scanning {
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent-border);
  border-top-color: var(--accent);
  animation: spin .75s linear infinite;
}
.scan-indicator.matched {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}
.scan-indicator.no-match {
  background: var(--text-muted);
}
.scan-indicator.rejected {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.3);
}
.scan-indicator.error {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.3);
}
.scan-indicator[title] {
  cursor: help;
}


/* ═══════════════════ NO-MATCH SECTION ════════════════════════ */
.no-match-section {
  margin-top: 28px;
}
.no-match-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  user-select: none;
  transition: all var(--t-fast);
}
.no-match-header:hover {
  background: var(--bg-elevated);
  border-color: var(--accent-border-hover);
  color: var(--text-secondary);
}
.no-match-header .chevron {
  transition: transform .2s var(--ease);
  font-size: 0.65rem;
}
.no-match-header.expanded .chevron {
  transform: rotate(90deg);
}
.no-match-listings {
  display: none;
  margin-top: 10px;
}
.no-match-listings.visible {
  display: grid;
  gap: 10px;
}
.no-match-listings .listing-card {
  opacity: 0.3;
}
.no-match-listings .listing-card:hover {
  opacity: 0.65;
}


/* ═══════════════════ SCAN PROGRESS ══════════════════════════ */
.scan-progress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.scan-progress .mini-spinner {
  width: 11px;
  height: 11px;
  border: 2px solid var(--accent-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  display: inline-block;
}


/* ═══════════════════ RESPONSIVE ══════════════════════════════ */
@media (max-width: 700px) {
  body { padding: 14px 16px; }
  header { padding: 18px 0 22px; }
  .header-logo { height: 38px; }
  header h1 { font-size: 1.25rem; }
  .subtitle { font-size: 0.72rem; }
  .tab-btn { font-size: 0.8rem; padding: 9px 16px; }
  .tab-indicator { width: calc(50% - 4px); }
  #refresh-btn { padding: 9px 20px; font-size: 0.8rem; }

  .listing-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .listing-card::before { display: none; }
  .listing-title { white-space: normal; }
  .listing-actions { justify-content: flex-start; }
  .source-fallback { grid-template-columns: 1fr; gap: 10px; }
}
