/* CSS Custom Properties */
:root {
  --primary: #0066FF;
  --primary-hover: #0052CC;
  --primary-light: #E8F0FE;
  --secondary: #6B7280;
  --background: #FFFFFF;
  --surface: #F9FAFB;
  --surface-hover: #F3F4F6;
  --border: #E5E7EB;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --transition: 150ms ease;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #3B82F6;
    --primary-hover: #60A5FA;
    --primary-light: #1E3A5F;
    --secondary: #9CA3AF;
    --background: #0F172A;
    --surface: #1E293B;
    --surface-hover: #334155;
    --border: #334155;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --success: #34D399;
    --warning: #FBBF24;
    --error: #F87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  }
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p { color: var(--text-secondary); }

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn-full {
  width: 100%;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-full);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* Inputs */
.input {
  width: 100%;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}

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

.input::placeholder {
  color: var(--text-muted);
}

.email-input {
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

/* Layout */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--background);
  border-bottom: 1px solid var(--border);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.logo-img {
  height: 32px;
  width: auto;
}

.search-container {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  font-size: 0.875rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: all var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Navigation */
.nav {
  background-color: var(--background);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 60px;
  z-index: 99;
}

.nav-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.nav-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}

.nav-btn:hover {
  color: var(--text-primary);
  background-color: var(--surface-hover);
}

.nav-btn.active {
  color: var(--primary);
  background-color: var(--primary-light);
}

/* Markets Section */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.view-options {
  display: flex;
  gap: 0.25rem;
}

.view-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.view-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.view-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Markets List */
.markets-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.market-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: all var(--transition);
}

.market-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.market-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.market-category {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background-color: var(--primary-light);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.market-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.market-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.market-outcomes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.outcome {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.outcome-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.outcome-price {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.outcome-percent {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.outcome-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.outcome-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.outcome-btn.yes:hover {
  border-color: var(--success);
  color: var(--success);
  background-color: rgba(16, 185, 129, 0.1);
}

.outcome-btn.no:hover {
  border-color: var(--error);
  color: var(--error);
  background-color: rgba(239, 68, 68, 0.1);
}

.market-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.sidebar-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.download-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.download-links img {
  height: 40px;
  width: auto;
}

.breaking-news {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.news-item {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.news-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.news-rank {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.news-title {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.news-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hot-topics {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.topic-item:last-child {
  border-bottom: none;
}

.topic-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topic-rank {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 1.5rem;
  text-align: center;
}

.topic-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.topic-volume {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.explore-link {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Footer */
.footer {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  margin-top: auto;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
}

.footer-links a {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-social {
  display: flex;
  gap: 1rem;
}

.footer-social a {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.footer-social a:hover {
  color: var(--primary);
}

.copyright {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
  animation: fadeIn 150ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background-color: var(--background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
  position: relative;
  animation: slideUp 200ms ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.login-modal h2,
.otp-modal h2,
.wallet-loader-modal h2,
.connection-failed-modal h2 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.login-modal p,
.otp-modal > p,
.wallet-loader-modal .wallet-status,
.connection-failed-modal p {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background-color: var(--background);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-google:hover {
  background-color: var(--surface-hover);
  border-color: var(--text-muted);
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border);
}

.email-input {
  margin-bottom: 1rem;
}

.otp-inputs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.otp-input {
  width: 48px;
  height: 56px;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--background);
  color: var(--text-primary);
  transition: all var(--transition);
}

.otp-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.resend-link {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.resend-link button {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.resend-link button:hover {
  text-decoration: underline;
}

.login-footer {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

.login-footer a {
  color: var(--text-secondary);
  margin: 0 0.5rem;
}

.login-footer a:hover {
  color: var(--primary);
}

/* Magic Loader */
.magic-loader-modal {
  text-align: center;
}

.magic-logo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.magic-spinner {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 3px solid transparent;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.magic-logo-img {
  width: 60px;
  height: 60px;
  z-index: 1;
}

.magic-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.magic-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Wallet Loader */
.wallet-loader-modal {
  text-align: center;
}

.wallet-logo {
  margin-bottom: 1.5rem;
}

.wallet-logo img {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
}

.wallet-status {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Connection Failed */
.connection-failed-modal {
  text-align: center;
}

.failed-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.failed-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* OTP Inputs */
.otp-inputs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.otp-input {
  width: 48px;
  height: 56px;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--background);
  color: var(--text-primary);
  transition: all var(--transition);
}

.otp-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Responsive */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  
  .sidebar-card:last-child {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .header-content {
    padding: 0.75rem 1rem;
  }
  
  .search-container {
    display: none;
  }
  
  .nav-content {
    padding: 0 1rem;
  }
  
  .container {
    padding: 0 1rem;
  }
  
  .layout {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  
  .market-outcomes {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    grid-template-columns: 1fr;
  }
  
  .sidebar-card:last-child {
    grid-column: span 1;
  }
  
  .modal-content {
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }
}

/* Utility Classes */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.w-full { width: 100%; }