/* Mobile-first responsive CSS for Forecast Club */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
  text-decoration: none;
}

nav {
  display: flex;
  gap: 16px;
}

nav a {
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 4px 8px;
  border-radius: var(--radius);
}

nav a:hover, nav a.active {
  color: var(--primary);
  background: var(--gray-100);
}

/* Main content */
main {
  padding: 24px 0;
}

/* Typography */
h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

p {
  margin-bottom: 16px;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-title {
  font-weight: 600;
  color: var(--gray-900);
}

.card-meta {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* Prediction cards */
.prediction-card {
  border-left: 4px solid var(--primary);
}

.prediction-card.resolved-yes {
  border-left-color: var(--success);
}

.prediction-card.resolved-no {
  border-left-color: var(--danger);
}

.prediction-card.ambiguous {
  border-left-color: var(--gray-400);
}

.prediction-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.prediction-title a {
  color: inherit;
  text-decoration: none;
}

.prediction-title a:hover {
  color: var(--primary);
}

.prediction-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.prediction-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
}

.badge-open {
  background: var(--primary);
  color: white;
}

.badge-yes {
  background: var(--success);
  color: white;
}

.badge-no {
  background: var(--danger);
  color: white;
}

.badge-ambiguous {
  background: var(--gray-400);
  color: white;
}

.badge-locked {
  background: var(--warning);
  color: white;
}

/* Lock-in info */
.lock-in-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: white;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.help-text {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Probability input */
.probability-input {
  display: flex;
  align-items: center;
  gap: 12px;
}

.probability-input input[type="range"] {
  flex: 1;
}

.probability-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 60px;
  text-align: right;
}

/* Forecast list */
.forecast-list {
  list-style: none;
}

.forecast-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

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

.forecast-user {
  font-weight: 500;
}

.forecast-prob {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.forecast-score {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* Leaderboard */
.leaderboard {
  list-style: none;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: white;
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.leaderboard-rank {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-400);
  width: 40px;
}

.leaderboard-rank.gold { color: #fbbf24; }
.leaderboard-rank.silver { color: #9ca3af; }
.leaderboard-rank.bronze { color: #d97706; }

.leaderboard-user {
  flex: 1;
}

.leaderboard-name {
  font-weight: 600;
}

.leaderboard-forecasts {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.leaderboard-score {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

/* Calibration chart */
.calibration-chart {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* Auth pages */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 100px);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 24px;
  text-align: center;
}

.auth-card h1 {
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--gray-500);
  margin-bottom: 24px;
}

/* Messages */
.message {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.message-success {
  background: #dcfce7;
  color: #166534;
}

.message-error {
  background: #fee2e2;
  color: #991b1b;
}

.message-info {
  background: #dbeafe;
  color: #1e40af;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
}

.empty-state h2 {
  color: var(--gray-700);
  margin-bottom: 8px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--gray-200);
}

.tab {
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--gray-700);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Group selector */
.group-selector {
  margin-bottom: 24px;
}

.group-selector select {
  font-weight: 500;
}

/* HTMX loading indicator */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator {
  opacity: 1;
}

.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* Desktop styles */
@media (min-width: 768px) {
  .container {
    max-width: 720px;
  }

  h1 {
    font-size: 2rem;
  }

  .prediction-stats {
    gap: 32px;
  }
}
