/* ═══════════════════════════════════════════════════
   FLOURISH — WORKOUT TRACKER
   Aesthetic: Warm "Sunday Morning Wellness"
   Palette: Linen, Sage, Terracotta, Dusty Blue
═══════════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;700&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Variables ── */
:root {
  /* Light theme */
  --bg:           #faf7f2;
  --bg-card:      #ffffff;
  --bg-nav:       #ffffff;
  --bg-input:     #f5f1eb;
  --text:         #2d2926;
  --text-mid:     #6b5f57;
  --text-muted:   #a89c93;
  --border:       #ede8e1;

  --sage:         #7a9e7e;
  --sage-light:   #e8f0e9;
  --sage-dark:    #5a7d5e;
  --coral:        #d4785a;
  --coral-light:  #faeee9;
  --coral-dark:   #b85f44;
  --blue:         #7499b8;
  --blue-light:   #e8f0f7;
  --gold:         #c9a84c;
  --gold-light:   #fdf5e4;

  --radius-sm:    8px;
  --radius-md:    16px;
  --radius-lg:    24px;
  --shadow-sm:    0 2px 8px rgba(45,41,38,.07);
  --shadow-md:    0 6px 24px rgba(45,41,38,.10);

  --nav-h:        68px;
  --header-h:     56px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg:           #1c1a18;
  --bg-card:      #272421;
  --bg-nav:       #1e1c1a;
  --bg-input:     #302e2b;
  --text:         #f0ebe4;
  --text-mid:     #c4b9b0;
  --text-muted:   #7a706a;
  --border:       #3a3633;
  --sage-light:   #263329;
  --coral-light:  #3a2820;
  --blue-light:   #1f2d38;
  --gold-light:   #2e2714;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .3s, color .3s;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ── App Shell ── */
#app {
  max-width: 540px;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
}
.app-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--sage-dark);
  letter-spacing: .02em;
}
.header-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  background: var(--bg-input);
  color: var(--text-mid);
  transition: background .2s, transform .15s;
  cursor: pointer;
}
.icon-btn:hover { background: var(--border); transform: scale(1.08); }
label.icon-btn { display: flex; }

/* ── Main content ── */
#main-content {
  padding-top: 8px;
  padding-bottom: calc(var(--nav-h) + 20px);
}
.page { display: none; }
.page.active { display: block; }
.page-inner { padding: 12px 16px; }

/* ── Page titles ── */
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.page-header-row .page-title { margin-bottom: 0; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: background .3s, border .3s;
}
.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* ── Greeting ── */
.greeting-block {
  padding: 14px 4px 10px;
}
.greeting-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.greeting-sub {
  font-size: .875rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Streak + Week cards row ── */
.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.streak-card {
  text-align: center;
  background: linear-gradient(135deg, var(--coral-light) 0%, var(--bg-card) 80%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 20px 12px;
}
.streak-flame { font-size: 2rem; line-height: 1; }
.streak-num {
  font-family: 'Playfair Display', serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--coral);
  line-height: 1.1;
}
.streak-label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.streak-best { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

.week-card {
  background: linear-gradient(135deg, var(--sage-light) 0%, var(--bg-card) 80%);
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px;
}
.week-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.week-fraction { font-family: 'Playfair Display', serif; font-size: 1.6rem; font-weight: 700; color: var(--sage-dark); }
.week-bar-wrap {
  height: 7px; background: var(--border); border-radius: 99px; overflow: hidden; margin: 4px 0;
}
.week-bar-fill {
  height: 100%; background: var(--sage); border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.week-pct { font-size: .8rem; color: var(--text-mid); }

/* ── Today card ── */
.today-card { }
.today-content { margin-bottom: 12px; }
.today-content .schedule-item { display: flex; align-items: center; gap: 8px; }
.today-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.quick-log-btn { width: 100%; }

/* ── Motivation card ── */
.motivation-card {
  background: linear-gradient(120deg, var(--gold-light), var(--sage-light));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: .9rem;
  color: var(--text-mid);
  font-style: italic;
  text-align: center;
  margin-bottom: 14px;
  font-weight: 500;
}

/* ── Activity list ── */
.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}
.activity-icon {
  font-size: 1.3rem; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0;
}
.activity-icon.swimming { background: var(--blue-light); }
.activity-icon.yoga { background: var(--sage-light); }
.activity-icon.resistance { background: var(--coral-light); }
.activity-text { flex: 1; }
.activity-name { font-weight: 600; font-size: .9rem; }
.activity-detail { font-size: .8rem; color: var(--text-muted); }
.activity-date { font-size: .78rem; color: var(--text-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: .9rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  transition: all .2s;
  cursor: pointer;
  border: none;
}
.btn-primary {
  background: var(--sage);
  color: #fff;
}
.btn-primary:hover { background: var(--sage-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(90,125,94,.35); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-mid);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
  background: var(--coral-light);
  color: var(--coral-dark);
}
.btn-danger:hover { background: var(--coral); color: #fff; }

.save-btn { width: 100%; margin-top: 8px; padding: 14px; font-size: 1rem; border-radius: var(--radius-md); }

/* ── Calendar ── */
.calendar-card { }
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cal-month-label {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem; font-weight: 700;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day-header {
  text-align: center;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 0;
}
.cal-day {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: background .15s;
  gap: 2px;
}
.cal-day:hover { background: var(--bg-input); }
.cal-day.empty { cursor: default; }
.cal-day.today { background: var(--sage-light); font-weight: 700; color: var(--sage-dark); }
.cal-day.has-scheduled::after {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--blue);
  position: absolute; bottom: 3px;
}
.cal-day.has-workout { background: var(--sage-light); }
.cal-day.has-workout .cal-day-num { color: var(--sage-dark); }
.cal-dot-row { display: flex; gap: 2px; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; }

/* ── Routine list ── */
.routine-list { display: flex; flex-direction: column; gap: 8px; }
.routine-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}
.routine-icon { font-size: 1.1rem; }
.routine-text { flex: 1; }
.routine-name { font-weight: 600; font-size: .88rem; }
.routine-days { font-size: .78rem; color: var(--text-muted); }
.routine-delete { color: var(--text-muted); font-size: .85rem; padding: 4px 8px; border-radius: 6px; }
.routine-delete:hover { background: var(--coral-light); color: var(--coral-dark); }

/* ── Type selector ── */
.type-selector {
  display: flex; gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto; padding-bottom: 2px;
}
.type-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: .85rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text-mid);
  transition: all .2s;
}
.type-btn.active {
  background: var(--sage);
  color: #fff;
  border-color: var(--sage);
}
.type-btn:hover:not(.active) { border-color: var(--sage); color: var(--sage-dark); }

/* ── Log date card ── */
.log-date-card { padding: 14px 18px; margin-bottom: 14px; }

/* ── Workout forms ── */
.workout-form { }
.form-group { margin-bottom: 12px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.form-input {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text);
  outline: none;
  transition: border .2s;
  appearance: auto;
}
.form-input:focus { border-color: var(--sage); }
textarea.form-input { resize: vertical; min-height: 60px; }

/* ── Swimming stroke rows ── */
.stroke-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.stroke-row {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 8px;
  align-items: center;
}
.remove-row-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.remove-row-btn:hover { background: var(--coral-light); color: var(--coral-dark); }

/* ── Exercise rows ── */
.exercise-block {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}
.exercise-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.exercise-name-input { flex: 1; }
.exercise-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.exercise-grid label { font-size: .75rem; color: var(--text-muted); display: block; margin-bottom: 3px; }

/* ── Progress / Charts ── */
.chart-card canvas { margin-top: 8px; }

.pr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pr-item {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.pr-exercise { font-size: .8rem; font-weight: 600; color: var(--text-mid); margin-bottom: 2px; }
.pr-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem; font-weight: 700; color: var(--coral);
}
.pr-detail { font-size: .75rem; color: var(--text-muted); }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 540px;
  height: var(--nav-h);
  background: var(--bg-nav);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(45,41,38,.06);
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-muted);
  transition: color .2s;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-btn.active { color: var(--sage-dark); }
.nav-btn:hover { color: var(--sage); }
.nav-icon { font-size: 1.25rem; }
.nav-label { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(45,41,38,.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 0 0 0;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0));
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .3s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem; font-weight: 700;
  margin-bottom: 18px;
}
.modal-actions {
  display: flex; gap: 10px; margin-top: 18px;
}
.modal-actions .btn { flex: 1; }

/* ── Day picker (routine modal) ── */
.day-picker {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.day-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: .82rem;
  font-weight: 600;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  color: var(--text-mid);
  transition: all .15s;
}
.day-btn.active {
  background: var(--sage);
  color: #fff;
  border-color: var(--sage);
}

/* ── Celebration overlay ── */
.celebrate-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(45,41,38,.55);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.celebrate-overlay.hidden { display: none; }
.celebrate-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  max-width: 300px; width: 100%;
  box-shadow: var(--shadow-md);
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { transform: scale(.7); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
.celebrate-emoji { font-size: 3.5rem; margin-bottom: 12px; }
.celebrate-msg {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem; font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}

/* ── Misc helpers ── */
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: .88rem; }

/* ── Responsive tweaks ── */
@media (min-width: 480px) {
  .stroke-row { grid-template-columns: 1fr 140px auto; }
  .exercise-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Workout type color dots ── */
.dot-swimming  { background: var(--blue); }
.dot-yoga      { background: var(--sage); }
.dot-resistance{ background: var(--coral); }
