/* Orienteering Terrain Analysis Portal — Shared Styles
   Light theme matching the original CLI report styling */

:root {
  /* Core palette — matches old race_report.py / runner_report.py */
  --bg: #f5f5f5;
  --bg-card: #fff;
  --bg-hover: #f9f9f9;
  --bg-secondary: #f1f5f9;
  --border: #e0e0e0;
  --text: #222;
  --text-primary: #1e293b;
  --text-muted: #777;
  --accent: #1565c0;
  --accent-bg: #e3f2fd;
  --accent-hover: #1976d2;
  --success: #2e7d32;
  --warning: #f57c00;
  --danger: #d32f2f;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ===== Navigation ===== */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1.5rem;
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff !important;
  text-decoration: none !important;
}

.top-nav a { color: rgba(255,255,255,0.85); }
.top-nav a:hover { color: #fff; text-decoration: none; }

.nav-user {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
}

.nav-whatsnew {
  position: relative;
  font-size: 0.85rem;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  width: 8px;
  height: 8px;
  background: #ff5252;
  border-radius: 50%;
  border: 1.5px solid #0d47a1;
}

/* ===== Main content ===== */
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--accent);
  border-bottom: 2px solid var(--accent-bg);
  padding-bottom: 6px;
}

h3 {
  font-size: 1.05em;
  margin: 14px 0 8px;
  color: #444;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* ===== Stat cards (dashboard + reports) ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.85rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

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

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.1rem;
}

/* ===== Quick links (dashboard) ===== */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s, border-color 0.15s;
  border: 1px solid transparent;
  text-decoration: none !important;
  color: var(--text) !important;
}

.link-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-color: var(--accent);
}

.link-icon {
  font-size: 1.5rem;
}

/* ===== Dashboard sections ===== */
.dashboard-sections { margin-top: 2rem; }
.dash-section { margin-bottom: 2.5rem; }

/* ===== Data tables ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin: 0.5rem 0;
}

.data-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 2px solid var(--border);
  color: #555;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f9f9f9; }

.nowrap { white-space: nowrap; }
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.r { text-align: right; }
.c { text-align: center; }

/* ===== Utility color classes ===== */
.bad { color: var(--danger); font-weight: 600; }
.ok { color: var(--warning); font-weight: 600; }
.good { color: var(--success); font-weight: 600; }

/* ===== Friend chips ===== */
.friend-chip {
  display: inline-block;
  background: var(--accent-bg);
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  margin-right: 0.25rem;
  color: var(--accent);
  text-decoration: none !important;
  cursor: default;
}
a.friend-chip { cursor: pointer; }
a.friend-chip:hover {
  background: #bbdefb;
  border-color: var(--accent);
  text-decoration: none !important;
}

/* ===== Friend management buttons ===== */
.btn-remove {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.5rem;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.btn-remove:hover {
  background: #fef2f2;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-add {
  background: var(--accent-bg);
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  color: var(--accent);
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-add:hover {
  background: var(--accent);
  color: #fff;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ===== Forms ===== */
.login-container {
  max-width: 400px;
  margin: 4rem auto;
  text-align: center;
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.login-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #555;
}

.form-group input,
.search-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
}

.form-group input:focus,
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(21,101,192,0.15);
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}

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

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

/* ===== Search ===== */
.search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.search-input {
  flex: 1;
}

.results-count {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.search-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: -1rem;
  margin-bottom: 1rem;
}

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* ===== Empty states ===== */
.empty-state {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
  font-style: italic;
}

/* ===== Placeholder ===== */
.placeholder-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
  margin: 2rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ===== Person Picker (typeahead) ===== */
.pp-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
}

/* Inside compare form fields, wrapper should not constrain width */
.compare-form .field .pp-wrapper { flex: none; width: 100%; }
.compare-form .field .pp-wrapper input { width: 100%; }

.pp-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 280px;
  max-width: 90vw;
  margin-top: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 200;
  max-height: 360px;
  overflow-y: auto;
}

.pp-item {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(120px, 1fr) 60px;
  align-items: baseline;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.875rem;
  border-bottom: 1px solid #f0f0f0;
}

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

.pp-item:hover, .pp-item.pp-active {
  background: var(--accent-bg);
}

.pp-item.pp-empty {
  grid-template-columns: 1fr;
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
}

.pp-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
}

.pp-club {
  color: var(--text-muted);
  font-size: 0.85em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
}

.pp-events {
  color: var(--text-muted);
  font-size: 0.8em;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== Suggestion Box Widget ===== */
.suggest-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 200;
  transition: background 0.15s;
}
.suggest-fab:hover { background: var(--accent-hover); }

.suggest-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.suggest-dialog {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.suggest-dialog h3 { margin-bottom: 0.25rem; }
.suggest-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.suggest-dialog textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.95rem;
  resize: vertical;
}
.suggest-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

/* ===== Request Access Form ===== */
.request-access {
  max-width: 400px;
  margin: 2rem auto 0;
  text-align: center;
}
.request-access h2 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}
.request-access-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-top: 0.75rem;
}

/* ===== Admin Page ===== */
.admin-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.admin-section h2 {
  font-size: 1.15rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.stat-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.stat-box {
  background: var(--bg-secondary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  text-align: center;
  min-width: 120px;
}
.stat-box .stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-box .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.badge-pending {
  display: inline-block;
  background: var(--warning);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-weight: 600;
}
.badge-approved {
  display: inline-block;
  background: var(--success);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-weight: 600;
}
.badge-denied {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-weight: 600;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .content { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-links { grid-template-columns: 1fr; }
  .search-form { flex-direction: column; }
  .top-nav { flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 1rem; }
  .nav-left { flex-wrap: wrap; }
  .suggest-fab { bottom: 1rem; right: 1rem; }
  .stat-row { gap: 0.75rem; }
}
