/* RunGod — Dark Theme Styles */

:root {
  --bg: #050505;
  --bg-card: #0d0d0d;
  --bg-input: #111111;
  --text: #FFFFFF;
  --text-secondary: #a0a0a0;
  --primary: #F58130;
  --primary-hover: #e0721f;
  --secondary: #54595F;
  --accent: #FFA532;
  --success: #4CAF50;
  --danger: #ef4444;
  --border: #1a1a1a;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1 { font-size: 1.75rem; font-weight: 600; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
p { line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }

/* Layout */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 80px;
  min-height: 100vh;
  min-height: 100dvh;
}

.page {
  padding: 16px;
  display: none;
  animation: fadeIn 0.2s ease;
}

.page.active { display: block; }

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

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--secondary);
}
.btn-secondary:hover { border-color: var(--primary); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-full { width: 100%; }

/* Inputs */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--secondary);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  transition: border-color 0.15s;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
}

.input-field::placeholder {
  color: var(--secondary);
}

select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2354595F' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row .input-group { flex: 1; }

/* Navigation Bar */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 12px;
  background: none;
  border: none;
  color: var(--secondary);
  font-family: var(--font);
  font-size: 0.7rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.nav-item.active { color: var(--primary); }

.nav-item svg {
  width: 22px;
  height: 22px;
}

/* Weather Widget */
.weather-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #1a1208 0%, #0d0d0d 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.weather-icon {
  width: 48px;
  height: 48px;
}

.weather-temp {
  font-size: 1.5rem;
  font-weight: 600;
}

.weather-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.weather-details {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

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

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Run List */
.run-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.run-date { font-size: 0.85rem; color: var(--text-secondary); }
.run-distance { font-weight: 600; font-size: 1.1rem; }
.run-pace { color: var(--accent); font-size: 0.9rem; }
.run-time { color: var(--text-secondary); font-size: 0.85rem; }

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  height: calc(100dvh - 140px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  margin-bottom: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-bubble.user {
  background: var(--primary);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-input);
  border: 1px solid var(--secondary);
  border-radius: 24px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  resize: none;
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-send-btn:disabled { opacity: 0.4; }

/* Training Plan */
.plan-week {
  margin-bottom: 16px;
}

.plan-week-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
}

.plan-week-header.current {
  border-color: var(--primary);
  background: linear-gradient(135deg, #1a0f05 0%, #0d0d0d 100%);
}

.plan-day {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

.plan-day-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.plan-day.rest .plan-day-num { background: var(--secondary); opacity: 0.5; }
.plan-day.run .plan-day-num { background: var(--primary); }

/* Achievements */
.achievement-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.achievement-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: all 0.2s;
}

.achievement-card.earned {
  border-color: var(--accent);
  background: linear-gradient(135deg, #1a1208 0%, #0d0d0d 100%);
}

.achievement-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.achievement-card.locked {
  opacity: 0.4;
}

.achievement-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.achievement-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.achievement-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.achievement-card.earned .achievement-badge {
  background: var(--accent);
  color: #000;
}

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

.auth-logo {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.auth-tagline {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.auth-form {
  width: 100%;
  max-width: 360px;
}

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-toggle a {
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}

/* Error / Toast */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 200;
  animation: slideDown 0.3s ease;
}

.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Chart container */
.chart-container {
  position: relative;
  height: 220px;
  margin: 12px 0;
}

/* Chart toggle buttons */
.chart-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.toggle-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 20px auto;
}

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

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-top: max(8px, env(safe-area-inset-top));
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--secondary); border-radius: 2px; }

/* Safe area for PWA */
@supports (padding: max(0px)) {
  .app-container {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* Utility */
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
