/* ═══════════════════════════════════════════════
   TailLog · style.css
   Mobile-first · Bold & fun · Accessible
   ═══════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────── */
:root {
  --primary:       #FF6B35;
  --primary-dark:  #E55520;
  --secondary:     #2EC4B6;
  --secondary-dark:#1FA99D;
  --poo:           #8B5A2B;
  --poo-bg:        #FFF3E0;
  --poo-border:    #FFCC80;
  --wee:           #E6A800;
  --wee-bg:        #FFFDE7;
  --wee-border:    #FFE082;
  --food:          #2ECC71;
  --food-bg:       #E8F8F0;
  --food-border:   #A9DFBF;
  --success:       #2ECC71;
  --success-bg:    #E8F8F0;
  --danger:        #E74C3C;
  --danger-bg:     #FDEDEC;
  --dark:          #1A202C;
  --text:          #2D3748;
  --muted:         #718096;
  --light:         #E2E8F0;
  --bg:            #F7F8FC;
  --white:         #FFFFFF;
  --shadow:        0 2px 8px rgba(0,0,0,0.09);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.12);
  --radius:        12px;
  --radius-lg:     20px;
  --radius-xl:     28px;
  --nav-height:    64px;
  --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }

/* ── Typography ────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 800; color: var(--dark); line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 700; color: var(--dark); }
h3 { font-size: 1.05rem; font-weight: 700; color: var(--dark); }
p  { color: var(--text); }

/* ── Install FAB ───────────────────────────────── */
.install-fab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--secondary);
  color: white;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  transform: translateY(-50%) rotate(180deg);
  padding: 16px 10px;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  z-index: 90;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}
.install-fab:hover { background: var(--secondary-dark); text-decoration: none; }
.install-fab span { font-size: 0.7rem; }

/* ── Bottom Navigation ─────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--white);
  border-top: 1px solid var(--light);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.07);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a:hover { color: var(--primary); text-decoration: none; }
.nav-icon { font-size: 1.4rem; position: relative; display: inline-block; }
.nav-label { line-height: 1; }

.badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── Page wrapper ──────────────────────────────── */
.page {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 0 24px;
}

/* ── Top bar ───────────────────────────────────── */
.top-bar {
  background: var(--white);
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--light);
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar-logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
}
.top-bar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
}
.top-bar-actions { display: flex; gap: 8px; align-items: center; }
.top-bar-back {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.2;
}
.btn:active { transform: scale(0.97); }
.btn:hover  { text-decoration: none; }

.btn-primary  { background: var(--primary);   color: white; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-secondary{ background: var(--secondary);  color: white; }
.btn-secondary:hover{ background: var(--secondary-dark); }
.btn-outline  { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover  { background: var(--primary); color: white; }
.btn-ghost    { background: var(--light); color: var(--text); }
.btn-ghost:hover    { background: var(--light); filter: brightness(0.95); }
.btn-danger   { background: var(--danger); color: white; }
.btn-sm       { padding: 8px 14px; font-size: 0.85rem; min-height: 36px; }
.btn-lg       { padding: 16px 28px; font-size: 1.1rem; min-height: 56px; }
.btn-block    { width: 100%; }

/* ── Track buttons (big, colourful) ────────────── */
.track-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-radius: var(--radius-xl);
  border: none;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  font-size: 1.25rem;
  font-weight: 800;
  color: white;
  box-shadow: var(--shadow-lg);
  transition: transform 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 14px;
  min-height: 80px;
}
.track-btn:hover  { text-decoration: none; transform: translateY(-1px); box-shadow: 0 12px 28px rgba(0,0,0,0.15); }
.track-btn:active { transform: scale(0.98); box-shadow: var(--shadow); }
.track-btn-emoji  { font-size: 2.4rem; }
.track-btn-text   { display: flex; flex-direction: column; align-items: flex-start; }
.track-btn-label  { font-size: 1.25rem; font-weight: 800; }
.track-btn-sub    { font-size: 0.8rem; font-weight: 500; opacity: 0.85; margin-top: 2px; }

.track-btn-poo  { background: linear-gradient(135deg, #8B5A2B, #C4874B); }
.track-btn-wee  { background: linear-gradient(135deg, #C89100, #F4C430); }
.track-btn-food { background: linear-gradient(135deg, #1A8A4A, #2ECC71); }

/* ── Cards ─────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-body { padding: 16px 20px; }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--light);
  background: var(--bg);
}

/* ── Owner dashboard ───────────────────────────── */
.dashboard-header {
  padding: 20px 20px 0;
}
.dashboard-greeting {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--dark);
}
.dashboard-sub { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

.dog-tabs {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dog-tabs::-webkit-scrollbar { display: none; }
.dog-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 24px;
  background: var(--white);
  border: 2px solid var(--light);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.dog-tab.active, .dog-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

.track-buttons { padding: 8px 20px 0; }

.recent-events { padding: 0 20px; margin-top: 20px; }
.recent-events h3 { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.event-list { display: flex; flex-direction: column; gap: 8px; }
.event-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.event-icon {
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}
.event-icon-poo  { background: var(--poo-bg); }
.event-icon-wee  { background: var(--wee-bg); }
.event-icon-food { background: var(--food-bg); }
.event-details   { flex: 1; }
.event-title     { font-weight: 700; font-size: 0.95rem; color: var(--dark); }
.event-time      { font-size: 0.8rem; color: var(--muted); }
.event-note      { font-size: 0.8rem; color: var(--muted); font-style: italic; margin-top: 2px; }

/* ── Tracking form ─────────────────────────────── */
.track-page { padding: 20px; }
.track-page h1 { font-size: 1.5rem; margin-bottom: 4px; }
.track-page .dog-label { color: var(--muted); margin-bottom: 20px; }

.option-group { margin-bottom: 20px; }
.option-group label.group-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.option-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill-input { display: none; }
.pill-label {
  padding: 10px 16px;
  border-radius: 24px;
  border: 2px solid var(--light);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.pill-input:checked + .pill-label {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.pill-label:hover { border-color: var(--primary); }

/* Time picker row */
.time-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.time-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 24px;
  border: 2px solid var(--light);
  font-size: 0.9rem;
  transition: border-color 0.15s;
  min-height: 44px;
}
.time-toggle:hover { border-color: var(--primary); }
#custom-time-field { display: none; }
#custom-time-field.visible { display: flex; align-items: center; gap: 8px; }
input[type="datetime-local"] {
  padding: 10px 12px;
  border: 2px solid var(--light);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--white);
  min-height: 44px;
}
input[type="datetime-local"]:focus { border-color: var(--primary); outline: none; }

.notes-field {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--light);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font);
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s;
}
.notes-field:focus { border-color: var(--primary); outline: none; }

.track-submit { margin-top: 24px; }
.track-submit .btn { font-size: 1.1rem; min-height: 60px; }

/* ── Success screen ────────────────────────────── */
.success-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px;
  text-align: center;
  gap: 16px;
}
.success-screen.visible { display: flex; }
.success-screen.visible ~ .track-form { display: none; }
.success-emoji { font-size: 5rem; animation: pop 0.4s ease; }
.success-screen h2 { font-size: 1.5rem; }
.success-screen p  { color: var(--muted); }
@keyframes pop {
  0%   { transform: scale(0.3); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── History / Calendar ────────────────────────── */
.history-page { padding: 20px; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 24px;
}
.cal-day-header {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0;
  text-transform: uppercase;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  font-size: 0.8rem;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.cal-day.empty { background: transparent; cursor: default; }
.cal-day.today { border-color: var(--primary); color: var(--primary); }
.cal-day.selected { background: var(--primary); color: white; }
.cal-day.has-events::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}
.cal-day-dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.cal-dot-poo  { background: var(--poo); }
.cal-dot-wee  { background: var(--wee); }
.cal-dot-food { background: var(--food); }
.cal-day.selected .cal-dot { background: rgba(255,255,255,0.8); }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.month-nav h2 { font-size: 1.1rem; }

.day-events { margin-top: 8px; }
.day-events h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ── Profile page ──────────────────────────────── */
.profile-page { padding: 20px; }
.profile-section { margin-bottom: 28px; }
.profile-section h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--light);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--text);
  transition: border-color 0.15s;
  min-height: 48px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  outline: none;
}
.form-group input[disabled] { background: var(--bg); color: var(--muted); }
.form-hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* ── Dog card (profile) ────────────────────────── */
.dog-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.dog-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}
.dog-card-header h3 { color: white; font-size: 1.1rem; }
.dog-card-header p  { color: rgba(255,255,255,0.8); font-size: 0.85rem; }
.dog-card-body { padding: 16px 20px; }
.dog-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.dog-stat {
  text-align: center;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 8px;
}
.dog-stat-value { font-size: 1rem; font-weight: 800; color: var(--dark); }
.dog-stat-label { font-size: 0.7rem; color: var(--muted); font-weight: 600; }

/* ── Dog avatar ────────────────────────────────── */
.dog-avatar { border-radius: 50%; object-fit: cover; }
.dog-avatar-initials {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  flex-shrink: 0;
}

/* ── Messages ──────────────────────────────────── */
.messages-page { padding: 0; }
.thread-list { }
.thread-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--light);
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}
.thread-item:hover { background: var(--bg); text-decoration: none; }
.thread-info { flex: 1; min-width: 0; }
.thread-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-preview {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.thread-time { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.thread-unread .thread-name { color: var(--primary); }
.thread-unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.chat-page { display: flex; flex-direction: column; height: calc(100vh - var(--nav-height)); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.45;
}
.message-sent {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 6px;
}
.message-received {
  align-self: flex-start;
  background: var(--white);
  color: var(--text);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 6px;
}
.message-time {
  font-size: 0.7rem;
  opacity: 0.65;
  margin-top: 4px;
  text-align: right;
}
.message-received .message-time { text-align: left; }

.chat-input-bar {
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 1px solid var(--light);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  border: 2px solid var(--light);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-family: var(--font);
  resize: none;
  max-height: 120px;
  min-height: 44px;
  line-height: 1.4;
}
.chat-input:focus { border-color: var(--primary); outline: none; }
.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chat-send:hover { background: var(--primary-dark); }

/* ── Trainer dashboard ─────────────────────────── */
.trainer-page { padding: 20px; }
.owner-list { display: flex; flex-direction: column; gap: 12px; }
.owner-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.15s, transform 0.1s;
}
.owner-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); text-decoration: none; }
.owner-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.owner-card-info h3 { font-size: 1rem; margin-bottom: 2px; }
.owner-card-info p  { font-size: 0.82rem; color: var(--muted); }
.owner-card-body {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--light);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dog-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.last-event-badge {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Trainer owner-detail ──────────────────────── */
.detail-page { padding: 0 0 20px; }
.detail-dog-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.detail-dog-info h2 { color: white; font-size: 1.2rem; }
.detail-dog-info p  { color: rgba(255,255,255,0.8); font-size: 0.85rem; }
.detail-dog-tags    { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  color: white;
}

.chart-section { padding: 20px; }
.chart-section h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; }
.chart-wrap { background: var(--white); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 20px 20px;
}
.stat-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num   { font-size: 1.6rem; font-weight: 800; }
.stat-label { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; margin-top: 2px; }
.stat-poo   .stat-num { color: var(--poo); }
.stat-wee   .stat-num { color: var(--wee); }
.stat-food  .stat-num { color: var(--food); }

/* ── Flash messages ────────────────────────────── */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.flash-success { background: var(--success-bg); color: #1A6B3A; }
.flash-error   { background: var(--danger-bg);  color: #922B21; }

/* ── Auth pages ────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #FFF3EE 0%, #F7F8FC 60%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  margin-bottom: 20px;
}
.auth-sub { color: var(--muted); margin-bottom: 20px; margin-top: 4px; font-size: 0.95rem; }
.auth-links { margin-top: 16px; text-align: center; font-size: 0.9rem; }

/* ── Landing page ──────────────────────────────── */
body.landing-body { padding-bottom: 0; }
.landing { max-width: 640px; margin: 0 auto; }
.landing-hero {
  background: linear-gradient(160deg, var(--primary) 0%, #FF9A67 100%);
  padding: 64px 32px 48px;
  text-align: center;
  color: white;
}
.landing-logo {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: white;
}
.landing-tagline {
  font-size: 1.6rem;
  font-weight: 800;
  color: white;
  margin-bottom: 12px;
}
.landing-sub {
  color: rgba(255,255,255,0.85);
  font-size: 1rem;
  max-width: 360px;
  margin: 0 auto 28px;
  line-height: 1.6;
}
.landing-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.landing-actions .btn-outline {
  border-color: white;
  color: white;
}
.landing-actions .btn-outline:hover {
  background: white;
  color: var(--primary);
}
.landing-actions .btn-primary {
  background: white;
  color: var(--primary);
}
.landing-actions .btn-primary:hover {
  background: var(--bg);
}

.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 32px 20px;
}
.feature-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  box-shadow: var(--shadow);
}
.feature-icon { font-size: 1.8rem; margin-bottom: 10px; }
.feature-card h3 { font-size: 0.95rem; margin-bottom: 6px; }
.feature-card p  { font-size: 0.85rem; color: var(--muted); }
.landing-footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--light);
}

/* ── Install page ──────────────────────────────── */
.install-page { max-width: 600px; margin: 0 auto; padding: 24px 20px 40px; }
.back-link { color: var(--primary); font-weight: 600; display: inline-block; margin-bottom: 20px; }
.install-hero { text-align: center; padding: 20px 0 32px; }
.install-icon { font-size: 4rem; margin-bottom: 12px; }
.install-hero p { color: var(--muted); max-width: 380px; margin: 12px auto 0; }

.install-section { background: var(--white); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.install-platform { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.platform-icon { font-size: 2rem; }
.install-steps { padding-left: 0; display: flex; flex-direction: column; gap: 16px; }
.install-steps li { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  background: var(--primary);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.install-steps p { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.install-tip {
  display: flex;
  gap: 12px;
  background: var(--wee-bg);
  border: 2px solid var(--wee-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: var(--text);
}
.install-cta { text-align: center; }

/* ── Add owner form ────────────────────────────── */
.photo-upload-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.photo-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--light);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ── Utility ───────────────────────────────────── */
.text-muted    { color: var(--muted); }
.text-sm       { font-size: 0.85rem; }
.mt-4          { margin-top: 4px; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mt-24         { margin-top: 24px; }
.mb-16         { margin-bottom: 16px; }
.divider       { border: none; border-top: 1px solid var(--light); margin: 20px 0; }
.danger-zone   { border: 2px solid var(--danger-bg); border-radius: var(--radius); padding: 16px; }
.danger-zone h3{ color: var(--danger); }

/* ── View log button (dashboard) ───────────────── */
.view-log-wrap {
  padding: 12px 20px 0;
}
.view-log-btn {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  border: 1.5px solid var(--light);
  background: var(--white);
  border-radius: var(--radius-lg);
}
.view-log-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Log page: period pills ─────────────────────── */
.log-periods {
  display: flex;
  gap: 8px;
  padding: 16px 20px 8px;
}
.period-pill {
  padding: 8px 18px;
  border-radius: 24px;
  background: var(--white);
  border: 2px solid var(--light);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.period-pill:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.period-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Log page: date navigation ──────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 12px;
  gap: 8px;
}
.date-nav-btn {
  font-size: 1.6rem;
  font-weight: 300;
  color: var(--primary);
  text-decoration: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.date-nav-btn:hover { background: var(--bg); text-decoration: none; }
.date-nav-btn-disabled { color: var(--light); cursor: default; }
.date-nav-center {
  flex: 1;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  -webkit-tap-highlight-color: transparent;
}
.date-nav-label {
  font-size: 1rem;
  font-weight: 800;
  color: var(--dark);
}
.date-nav-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Log page: summary strip ────────────────────── */
.log-summary {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
}
.log-summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.88rem;
}
.log-summary-poo  { background: var(--poo-bg);  color: var(--poo); }
.log-summary-wee  { background: var(--wee-bg);  color: var(--wee); }
.log-summary-food { background: var(--food-bg); color: var(--food); }
.log-summary-emoji { font-size: 1rem; }
.log-summary-count { font-size: 0.9rem; }

/* ── Log page: vertical timeline ────────────────── */
.timeline {
  padding: 0 20px 8px;
}
.timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
}
.timeline-time {
  width: 52px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  padding-top: 10px;
  line-height: 1.2;
}
.timeline-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
.timeline-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.timeline-dot-poo  { background: var(--poo-bg);  border: 2px solid var(--poo-border); }
.timeline-dot-wee  { background: var(--wee-bg);  border: 2px solid var(--wee-border); }
.timeline-dot-food { background: var(--food-bg); border: 2px solid var(--food-border); }
.timeline-line {
  flex: 1;
  width: 2px;
  background: var(--light);
  min-height: 20px;
  margin: 4px 0;
}
.timeline-content {
  flex: 1;
  padding: 8px 0 24px;
}
.timeline-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--dark);
  line-height: 1.3;
}
.timeline-note {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 3px;
}

/* ── Log page: empty state ──────────────────────── */
.log-empty {
  padding: 48px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.log-empty-icon { font-size: 3rem; margin-bottom: 4px; }
.log-empty p { color: var(--muted); font-size: 0.95rem; }

/* ── Log page: weekly view ──────────────────────── */
.week-list {
  padding: 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.week-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.week-row:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); text-decoration: none; }
.week-row-today {
  border-left: 4px solid var(--primary);
}
.week-row-date {
  display: flex;
  flex-direction: column;
  width: 44px;
  flex-shrink: 0;
}
.week-row-dow {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.week-row-today .week-row-dow { color: var(--primary); }
.week-row-datelbl {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dark);
}
.week-row-counts {
  flex: 1;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.week-count-pill {
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 700;
}
.week-count-poo  { background: var(--poo-bg);  color: var(--poo); }
.week-count-wee  { background: var(--wee-bg);  color: var(--wee); }
.week-count-food { background: var(--food-bg); color: var(--food); }
.week-row-none { font-size: 0.82rem; color: var(--light); font-style: italic; }
.week-row-arrow { color: var(--light); font-size: 1.2rem; flex-shrink: 0; }
.week-row:hover .week-row-arrow { color: var(--primary); }

/* ── Log page: all time stats ───────────────────── */
.alltime-wrap {
  padding: 8px 20px;
}
.alltime-total {
  text-align: center;
  padding: 24px 20px 20px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.alltime-num {
  font-size: 3rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}
.alltime-lbl {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}
.alltime-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.alltime-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.alltime-emoji { font-size: 1.5rem; }
.alltime-type  { flex: 1; font-weight: 700; font-size: 1rem; color: var(--dark); }
.alltime-count { font-size: 1.6rem; font-weight: 900; }

/* ── Trainer detail: view tabs ─────────────────── */
.view-tabs {
  display: flex;
  border-bottom: 2px solid var(--light);
  background: var(--white);
}
.view-tab {
  flex: 1;
  text-align: center;
  padding: 14px 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.view-tab:hover { color: var(--primary); text-decoration: none; }
.view-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Trainer detail: event grid ─────────────────── */
.grid-scroll-wrap {
  overflow-x: auto;
  padding: 12px 0 4px;
  -webkit-overflow-scrolling: touch;
}
.event-grid {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 0.78rem;
}
.event-grid th, .event-grid td {
  border: 1px solid var(--light);
  padding: 5px 4px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}
.event-grid th {
  background: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 1;
}
.grid-date-col {
  position: sticky;
  left: 0;
  background: var(--white);
  z-index: 2;
  min-width: 48px;
  font-size: 0.72rem;
  text-align: left !important;
  padding-left: 8px !important;
}
.event-grid th.grid-date-col { background: var(--bg); z-index: 3; }
.grid-row-today .grid-date-col { background: #FFF7ED; }
.grid-row-today td { background: #FFFBF5; }
.grid-dow {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.grid-row-today .grid-dow { color: var(--primary); }
.grid-day { display: block; font-weight: 700; color: var(--dark); }
.grid-cell { min-width: 40px; }
.grid-dot { font-size: 0.85rem; line-height: 1; }
.grid-overflow { font-size: 0.65rem; color: var(--muted); font-weight: 700; }

/* ── Responsive: wider screens ─────────────────── */
@media (min-width: 640px) {
  .page, .landing, .install-page { padding-left: 24px; padding-right: 24px; }
  .features { grid-template-columns: repeat(3, 1fr); }
  .track-btn { min-height: 90px; }
  .track-btn-label { font-size: 1.4rem; }
}

/* ── Scrollbar (Webkit) ────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--light); border-radius: 3px; }

/* ── Profile lock screen ───────────────────────── */
.profile-lock {
  text-align: center;
  padding-top: 40px;
}
.profile-lock-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.profile-lock h2 {
  margin-bottom: 8px;
}
.profile-lock p {
  margin-bottom: 28px;
}

/* ── v2: Dog identity strip ─────────────────────── */
.dog-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 12px;
}
.dog-identity-info h2 { font-size: 1.2rem; margin: 0 0 2px; }
.dog-identity-info p  { font-size: 0.82rem; color: var(--muted); margin: 0; }
.dog-id-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--light);
  border-radius: 8px;
  padding: 2px 7px;
  vertical-align: middle;
  margin-left: 6px;
}

/* ── v2: Toilet tracking grid ───────────────────── */
.track-section { padding: 0 20px 16px; }
.track-heading {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 12px;
}
.toilet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.toilet-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 12px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  border: 2px solid transparent;
  transition: box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}
.toilet-btn:hover   { box-shadow: var(--shadow-lg); transform: translateY(-1px); text-decoration: none; }
.toilet-btn:active  { transform: scale(0.97); }
.toilet-wide        { grid-column: span 2; flex-direction: row; gap: 12px; padding: 14px 20px; }
.toilet-sym {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
}
.toilet-lbl {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
}
.toilet-lbl small { font-weight: 400; font-size: 0.75em; opacity: 0.8; }
.toilet-black {
  background: #F5F5F5;
  border-color: #D0D0D0;
  color: #1a1a1a;
}
.toilet-red {
  background: #FFF0EE;
  border-color: #FFBDB5;
  color: #CC2200;
}

/* ── v2: Event symbols (calendar/log) ───────────── */
.ev-sym { font-weight: 900; }
.ev-black { color: #1a1a1a; }
.ev-red   { color: #CC2200; }

/* ── v2: Manager section heading ────────────────── */
.section-heading {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 12px;
}

/* ── v2: Form inputs ────────────────────────────── */
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--light);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.form-input:focus { outline: none; border-color: var(--primary); }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* ── Hide install FAB when running as installed PWA */
@media (display-mode: standalone) {
  .install-fab { display: none !important; }
}
