/* PolyView — Light theme matching Polymarket's design */

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

:root {
  --bg-base:        #f1f2f5;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f8f9fc;
  --bg-nav:         #ffffff;
  --bg-filter:      #ffffff;
  --bg-input:       #f4f5f8;

  --border:         #e2e6ef;
  --border-light:   #edf0f7;

  --text-primary:   #1a1f36;
  --text-secondary: #536078;
  --text-muted:     #8c9ab0;

  --accent:         #0052f4;
  --accent-hover:   #1a66ff;
  --accent-dim:     rgba(0,82,244,.08);
  --accent-text:    #0052f4;

  --green:          #12b76a;
  --green-bg:       rgba(18,183,106,.10);
  --green-border:   rgba(18,183,106,.25);
  --red:            #f04438;
  --red-bg:         rgba(240,68,56,.10);
  --red-border:     rgba(240,68,56,.25);
  --yellow:         #dc6803;
  --yellow-bg:      rgba(220,104,3,.10);

  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.06);

  --font:           'Inter', 'Segoe UI', system-ui, sans-serif;
  --nav-h:          60px;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: #cdd2dd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Topbar notice ─────────────────────────────────────────────────────── */
.topbar-notice {
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  text-align: center;
  padding: 7px 16px;
  font-size: .78rem;
  color: #1d4ed8;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ── Language Bar ──────────────────────────────────────────────────────── */
.lang-bar {
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  padding: 5px 24px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: .78rem;
  color: var(--text-muted);
}

.lang-bar .lang-label {
  color: var(--text-secondary);
  margin-right: 4px;
  font-size: .73rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 600;
}

.lang-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 500;
  transition: all .15s;
  cursor: pointer;
}
.lang-btn:hover {
  background: var(--bg-input);
  border-color: var(--border);
  color: var(--text-primary);
}
.lang-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

/* ── Navigation ────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 28px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.02em;
  flex-shrink: 0;
}
.nav-logo svg { width: 28px; height: 28px; }

.nav-links { display: flex; gap: 2px; flex: 1; }

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .88rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg-input); color: var(--text-primary); }
.nav-link.active { background: var(--accent-dim); color: var(--accent-text); font-weight: 600; }

.nav-right { display: flex; align-items: center; gap: 12px; }

.nav-search { position: relative; display: flex; align-items: center; }
.nav-search svg {
  position: absolute; left: 10px;
  color: var(--text-muted);
  pointer-events: none;
  width: 15px; height: 15px;
}
.nav-search input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px 7px 32px;
  color: var(--text-primary);
  font-size: .86rem;
  width: 240px;
  outline: none;
  transition: border .15s, box-shadow .15s, background .15s;
}
.nav-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,82,244,.10);
  background: #fff;
}
.nav-search input::placeholder { color: var(--text-muted); }

/* ── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 44px 24px 32px;
  background: linear-gradient(to bottom, #fff 0%, var(--bg-base) 100%);
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.2;
  margin-bottom: 10px;
  color: var(--text-primary);
}
.hero h1 span { color: var(--accent); }
.hero p { color: var(--text-secondary); font-size: .95rem; max-width: 520px; margin: 0 auto; }

/* ── Filters bar ───────────────────────────────────────────────────────── */
.filters-bar {
  background: var(--bg-filter);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  top: var(--nav-h);
  z-index: 90;
}

.filter-group { display: flex; align-items: center; gap: 5px; }

.filter-label {
  font-size: .73rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
  font-weight: 600;
}

.filter-chip {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
  cursor: pointer;
  font-family: var(--font);
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-dim); }
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 5px 30px 5px 10px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
  transition: border .15s;
  font-family: var(--font);
}
.filter-select:focus { border-color: var(--accent); }

.filter-spacer { flex: 1; }

.filter-reset {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  transition: all .15s;
  font-family: var(--font);
}
.filter-reset:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }

/* ── Main content ──────────────────────────────────────────────────────── */
.main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; }

/* ── Chart section ─────────────────────────────────────────────────────── */
.chart-section {
  margin-bottom: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 3px; height: 15px;
  background: var(--accent);
  border-radius: 2px;
}

.chart-container { position: relative; height: 250px; }

/* ── Markets grid ──────────────────────────────────────────────────────── */
.markets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.markets-count { font-size: .82rem; color: var(--text-muted); font-weight: 500; }

.markets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(560px, 1fr));
  gap: 14px;
}

/* ── Market card — two-column Polymarket layout ────────────────────────── */
.market-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .12s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  overflow: hidden;
}
.market-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Body: left (outcomes) + right (chart) */
.card-body {
  display: flex;
  flex: 1;
  padding: 18px 18px 12px;
  gap: 0;
  min-height: 170px;
}

.card-left {
  flex: 0 0 44%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 16px;
  border-right: 1px solid var(--border-light);
  min-width: 0;
}

.card-right {
  flex: 1;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* Header inside card */
.card-header { display: flex; gap: 10px; align-items: flex-start; }

.card-header-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.card-img {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.card-img-placeholder {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-text);
  font-size: .92rem;
  font-weight: 700;
  border: 1px solid rgba(0,82,244,.15);
}

.card-question {
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-category {
  font-size: .70rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .03em;
}

/* Outcomes list (left side) */
.card-outcomes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.outcome-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  padding: 2px 0;
}

.outcome-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.outcome-name {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .87rem;
}

.outcome-val {
  font-weight: 800;
  color: var(--text-primary);
  font-size: .97rem;
  flex-shrink: 0;
  min-width: 42px;
  text-align: right;
}

/* Chart right side */
.card-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: .71rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.legend-item strong { color: var(--text-primary); font-weight: 700; }

.card-chart-wrap {
  position: relative;
  flex: 1;
  min-height: 90px;
}

.card-chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Card footer */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 18px 13px;
  border-top: 1px solid var(--border-light);
  font-size: .76rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-stat { display: flex; align-items: center; gap: 6px; }
.card-stat-label { font-size: .74rem; color: var(--text-muted); }
.card-stat-value { font-weight: 700; color: var(--text-secondary); }

.badge-resolved {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .70rem; background: var(--yellow-bg); color: var(--yellow);
  padding: 1px 7px; border-radius: 20px; font-weight: 600;
  border: 1px solid rgba(220,104,3,.2);
}

.badge-resolved {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .70rem;
  background: var(--yellow-bg);
  color: var(--yellow);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid rgba(220,104,3,.2);
}

/* ── State messages ────────────────────────────────────────────────────── */
.state-msg { text-align: center; padding: 64px 24px; color: var(--text-muted); }
.state-msg .icon { font-size: 2.5rem; margin-bottom: 12px; }
.state-msg h3 { font-size: 1.05rem; color: var(--text-secondary); margin-bottom: 6px; }
.state-msg p { font-size: .87rem; }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Load more ─────────────────────────────────────────────────────────── */
.load-more-wrap { text-align: center; margin-top: 28px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 32px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font);
  transition: background .15s, transform .1s, box-shadow .15s;
  cursor: pointer;
  min-width: 120px;
  display: inline-block;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Market detail ─────────────────────────────────────────────────────── */
.market-detail { max-width: 900px; margin: 0 auto; padding: 28px 24px 64px; }

.breadcrumb {
  font-size: .82rem; color: var(--text-muted);
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 6px;
}
.breadcrumb a { color: var(--accent-text); font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; }

.detail-header { margin-bottom: 24px; }
.detail-title {
  font-size: clamp(1.2rem, 2.5vw, 1.65rem);
  font-weight: 800; line-height: 1.3;
  letter-spacing: -.015em; margin-bottom: 10px;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: .82rem; color: var(--text-muted); margin-top: 10px; }
.detail-meta span { display: flex; align-items: center; gap: 5px; }

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.detail-outcomes { display: flex; flex-direction: column; gap: 8px; }
.detail-outcome-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.detail-outcome-name { flex: 1; font-weight: 600; font-size: .92rem; }
.detail-outcome-pct { font-size: 1.25rem; font-weight: 800; }
.detail-outcome-bar-wrap { flex: 2; }
.detail-outcome-bar { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.detail-outcome-fill { height: 100%; border-radius: 4px; transition: width .4s; }

.detail-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat-box {
  background: var(--bg-input); border-radius: var(--radius-sm);
  padding: 14px; text-align: center;
  border: 1px solid var(--border);
}
.stat-box-label { font-size: .70rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.stat-box-value { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); }

/* ── Footer ────────────────────────────────────────────────────────────── */
footer {
  background: var(--bg-nav);
  border-top: 1px solid var(--border);
  padding: 24px; text-align: center;
  font-size: .78rem; color: var(--text-muted); line-height: 1.7;
}
footer a { color: var(--accent-text); font-weight: 500; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .markets-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .nav { gap: 14px; padding: 0 14px; }
  .nav-search input { width: 160px; }
  .filters-bar { padding: 8px 14px; }
  .main { padding: 18px 14px 48px; }
  .hero { padding: 30px 14px 24px; }
  .markets-grid { grid-template-columns: 1fr; }
  .lang-bar { padding: 5px 14px; flex-wrap: wrap; }
  .card-body { padding: 14px 14px 10px; min-height: 140px; }
  .card-left { flex: 0 0 48%; padding-right: 12px; }
  .card-right { padding-left: 12px; }
}

@media (max-width: 560px) {
  .nav-search { display: none; }
  .hero h1 { font-size: 1.4rem; }
  .card-body { flex-direction: column; min-height: unset; }
  .card-left {
    flex: unset; width: 100%;
    padding-right: 0; padding-bottom: 12px;
    border-right: none; border-bottom: 1px solid var(--border-light);
  }
  .card-right { padding-left: 0; padding-top: 10px; min-height: 110px; }
}
