/*
 * My Fitness Journey — Application Styles
 */

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

:root {
  --primary:       #e85d04;
  --primary-dark:  #c44e03;
  --primary-light: #fde8d8;
  --success:       #2d9653;
  --danger:        #dc2626;
  --text:          #1a1a2e;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --bg:            #f9fafb;
  --white:         #ffffff;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

/* ─── Navigation ─── */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: 1px;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* ─── Layout ─── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ─── Cards ─── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
  font-family: inherit;
}

.btn-primary              { background: var(--primary); color: var(--white); }
.btn-primary:hover        { background: var(--primary-dark); }
.btn-secondary            { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover      { background: var(--border); }
.btn-danger               { background: var(--danger); color: var(--white); }
.btn-danger:hover         { background: #b91c1c; }
.btn-sm                   { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

/* ─── Flash messages ─── */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.flash-notice { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-alert  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ─── Forms ─── */
.form-group   { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,93,4,0.12);
}

textarea.form-control {
  min-height: 220px;
  resize: vertical;
}

/* ─── Mood badges ─── */
.mood-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.mood-great   { background: #d1fae5; color: #065f46; }
.mood-good    { background: #dbeafe; color: #1e40af; }
.mood-neutral { background: #f3f4f6; color: #4b5563; }
.mood-tough   { background: #fef3c7; color: #92400e; }
.mood-hard    { background: #fee2e2; color: #991b1b; }

/* ─── Mood selector in form ─── */
.mood-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mood-option input[type="radio"] { display: none; }

.mood-option input[type="radio"]:checked + label {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

.mood-option label { cursor: pointer; }

/* ─── Entry list ─── */
.entry-list { display: flex; flex-direction: column; gap: 0.625rem; }

.entry-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.entry-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(232,93,4,0.1);
}

.entry-date {
  min-width: 46px;
  text-align: center;
  background: var(--primary-light);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  flex-shrink: 0;
}
.entry-date-day { display: block; font-size: 1.3rem; font-weight: 800; color: var(--primary); line-height: 1.1; }
.entry-date-mon { display: block; font-size: 0.6rem; font-weight: 700; color: var(--primary); text-transform: uppercase; }

.entry-meta     { flex: 1; min-width: 0; }
.entry-title    { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-preview  { font-size: 0.8125rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Entry body (show page) ─── */
.entry-body { line-height: 1.85; font-size: 1rem; white-space: pre-wrap; }

/* ─── Habit list ─── */
.habit-list { display: flex; flex-direction: column; gap: 0.5rem; }

.habit-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}
.habit-row.completed { border-color: #86efac; background: #f0fdf4; }

.inline-form { display: inline; }

.habit-check {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  transition: all 0.15s;
  flex-shrink: 0;
  cursor: pointer;
  color: transparent;
}
.habit-check.done { background: var(--success); border-color: var(--success); color: var(--white); }

/* Make button_to form's button look like the habit-check div */
.inline-form button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.habit-name { font-weight: 600; font-size: 0.9375rem; }
.habit-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.1rem; }

/* ─── Dashboard grid ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

/* ─── Stat grid ─── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 0;
}

.stat-card {
  text-align: center;
  padding: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-number { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label  { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* ─── Section headings ─── */
.section-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ─── Empty state ─── */
.empty-state   { text-align: center; padding: 3rem 1.5rem; }
.empty-icon    { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-title   { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.4rem; }
.empty-desc    { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.25rem; }

/* ─── Utility ─── */
.text-muted { color: var(--text-muted); font-size: 0.875rem; }
a           { color: var(--primary); }

/* ─── Auth pages ─── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 60%, #fde8d8 100%);
  padding: 1rem;
}

.auth-card {
  background: var(--white);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}

.auth-title    { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.25rem; }
.auth-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 2rem; }
.auth-footer   { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-muted); }
.auth-footer a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* ─── Template grid ─── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.template-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}

.template-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(232,93,4,0.12);
}

.template-name {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.template-prompt {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}

.template-prompt-link {
  text-decoration: none;
  color: inherit;
  display: block;
  flex: 1;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .nav { padding: 0 1rem; }
  .container { padding: 1rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .stat-number { font-size: 1.5rem; }
  .nav-links .nav-link:not(:last-child) { display: none; }
}
