/* Prophet Margin — Mobile-first family prediction market */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #22263a;
  --border: #2a2e3d;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --accent: #6c5ce7;
  --accent-hover: #7c6ef7;
  --green: #00b894;
  --red: #e17055;
  --yellow: #fdcb6e;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

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

header .header-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

header .balance {
  color: var(--green);
  font-weight: 600;
}

header .user-name {
  color: var(--text-muted);
}

/* Navigation */
nav {
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

nav .nav-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
}

nav button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

nav button:hover, nav button.active {
  color: var(--accent);
}

nav button .nav-icon {
  font-size: 20px;
  line-height: 1;
}

/* Main content area */
main {
  padding-bottom: 80px;
  padding-top: 16px;
}

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.card:hover { background: var(--surface-hover); }

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Probability display */
.prob-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin: 10px 0;
  overflow: hidden;
}

.prob-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.prob-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.prob-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

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

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

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover { border-color: var(--accent); }

.btn-group {
  display: flex;
  gap: 8px;
}

.btn-group .btn { flex: 1; }

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

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-open { background: rgba(0, 184, 148, 0.15); color: var(--green); }
.badge-closed { background: rgba(253, 203, 110, 0.15); color: var(--yellow); }
.badge-resolved { background: rgba(108, 92, 231, 0.15); color: var(--accent); }
.badge-voided { background: rgba(225, 112, 85, 0.15); color: var(--red); }

/* Trade panel */
.trade-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}

.trade-toggle {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
}

.trade-toggle button {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}

.trade-toggle button.active-buy {
  background: var(--green);
  color: white;
}

.trade-toggle button.active-sell {
  background: var(--red);
  color: white;
}

.trade-preview {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
  font-size: 13px;
}

.trade-preview .preview-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.trade-preview .preview-label { color: var(--text-muted); }

/* Quantity slider */
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* Leaderboard */
.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.leaderboard-row:last-child { border-bottom: none; }

.leaderboard-rank {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  margin-right: 12px;
  color: var(--text-muted);
}

.leaderboard-rank.top-3 { color: var(--yellow); }

.leaderboard-name { flex: 1; font-weight: 500; }

.leaderboard-profit {
  font-weight: 600;
  font-size: 15px;
}

.leaderboard-profit.positive { color: var(--green); }
.leaderboard-profit.negative { color: var(--red); }

/* Comments */
.comment {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child { border-bottom: none; }

.comment-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.comment-author { font-weight: 600; }
.comment-time { color: var(--text-muted); }
.comment-body { font-size: 14px; }

.comment-replies {
  margin-left: 20px;
  border-left: 2px solid var(--border);
  padding-left: 12px;
}

/* Position cards */
.position-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.position-shares {
  font-weight: 600;
}

.position-shares.long { color: var(--green); }
.position-shares.short { color: var(--red); }

/* Auth screen */
.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 8px;
  color: var(--accent);
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.auth-tabs button {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.auth-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.error-msg {
  background: rgba(225, 112, 85, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}

/* Section headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* Loading */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Back button */
.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.back-btn:hover { color: var(--text); }

/* Market detail sections */
.detail-section {
  margin-top: 20px;
}

.detail-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
}

/* Category filter */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
}

.filter-bar button {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.filter-bar button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Responsive */
@media (min-width: 768px) {
  .container { padding: 0 24px; }
  .card { padding: 20px; }
}
