/* =========================================================
   PULSE — Shared Design System
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Colors */
  --bg-base:        #0B0F1A;
  --bg-surface:     #111827;
  --bg-card:        #1A2233;
  --bg-card-hover:  #1E2840;
  --border:         #2A3650;
  --border-subtle:  #1E2A3E;

  --text-primary:   #F0F4FF;
  --text-secondary: #8B9CC8;
  --text-muted:     #4B5A7A;

  --accent:         #3B82F6;
  --accent-dim:     rgba(59, 130, 246, 0.15);
  --accent-glow:    rgba(59, 130, 246, 0.35);

  --green:          #10B981;
  --green-dim:      rgba(16, 185, 129, 0.15);
  --yellow:         #F59E0B;
  --yellow-dim:     rgba(245, 158, 11, 0.15);
  --red:            #EF4444;
  --red-dim:        rgba(239, 68, 68, 0.15);

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.2);

  /* Nav */
  --nav-height: 72px;
  --header-height: 64px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* =========================================================
   LAYOUT
   ========================================================= */

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg-base);
}

/* Desktop: show side-by-side feel */
@media (min-width: 768px) {
  .app-shell {
    max-width: 600px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

@media (min-width: 1024px) {
  body {
    background: var(--bg-surface);
  }
  .app-shell {
    max-width: 480px;
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
  }
}

/* =========================================================
   HEADER
   ========================================================= */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 26, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #6366F1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -1px;
  color: white;
  box-shadow: var(--shadow-glow);
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-date {
  text-align: right;
}

.header-date .day {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.header-date .date {
  font-size: 12px;
  color: var(--text-muted);
}

/* =========================================================
   PAGE CONTENT
   ========================================================= */

.page-content {
  padding: var(--space-md);
  padding-bottom: calc(var(--nav-height) + var(--space-md));
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* =========================================================
   CARDS
   ========================================================= */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.card:active {
  transform: scale(0.99);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-dim);
  color: var(--accent);
}

/* =========================================================
   RECOVERY CARD
   ========================================================= */

.recovery-card {
  background: linear-gradient(135deg, #0F1F3D 0%, #1A2233 100%);
  border-color: var(--accent);
  position: relative;
  overflow: hidden;
}

.recovery-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.recovery-main {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}

.recovery-score-ring {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}

.recovery-score-ring svg {
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.ring-fill.green  { stroke: var(--green); }
.ring-fill.yellow { stroke: var(--yellow); }
.ring-fill.red    { stroke: var(--red); }

.score-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-number {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}

.score-number.green  { color: var(--green); }
.score-number.yellow { color: var(--yellow); }
.score-number.red    { color: var(--red); }

.score-pct {
  font-size: 12px;
  color: var(--text-muted);
}

.recovery-info {
  flex: 1;
}

.recovery-status {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.recovery-status.green  { color: var(--green); }
.recovery-status.yellow { color: var(--yellow); }
.recovery-status.red    { color: var(--red); }

.recovery-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.recovery-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.metric-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.metric-unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 2px;
}

/* =========================================================
   SLEEP CARD
   ========================================================= */

.sleep-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.sleep-stat {
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}

.sleep-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.sleep-stat-value {
  font-size: 17px;
  font-weight: 700;
}

.sleep-main-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: var(--space-xs);
}

.sleep-hours {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -2px;
  color: #6366F1;
}

.sleep-hours-label {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
}

.sleep-quality-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  margin: var(--space-sm) 0;
  overflow: hidden;
}

.sleep-quality-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #6366F1, #8B5CF6);
}

/* =========================================================
   RECOMMENDATION CARD
   ========================================================= */

.recommendation-card {
  background: linear-gradient(135deg, #0F1F3D, #1A1F35);
  border-color: var(--accent);
}

.rec-content {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.rec-icon {
  width: 60px;
  height: 60px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.rec-text {
  flex: 1;
}

.rec-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.rec-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.rec-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--green-dim);
  color: var(--green);
}

/* =========================================================
   WORKOUT / TODAY CARD
   ========================================================= */

.workout-card {
  position: relative;
  overflow: hidden;
}

.workout-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.workout-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-md);
}

.exercise-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.exercise-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.exercise-name {
  font-size: 14px;
  font-weight: 500;
}

.exercise-sets {
  font-size: 12px;
  color: var(--text-muted);
}

/* =========================================================
   CALENDAR CARD
   ========================================================= */

.calendar-events {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.calendar-event {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: background 0.2s ease;
}

.event-time-col {
  text-align: center;
  min-width: 44px;
}

.event-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  display: block;
}

.event-duration {
  font-size: 10px;
  color: var(--text-muted);
}

.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-dot.blue   { background: var(--accent); }
.event-dot.green  { background: var(--green); }
.event-dot.purple { background: #8B5CF6; }

.event-info {
  flex: 1;
}

.event-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.event-location {
  font-size: 12px;
  color: var(--text-muted);
}

/* =========================================================
   BOTTOM NAVIGATION
   ========================================================= */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
}

@media (min-width: 768px) {
  .bottom-nav {
    max-width: 600px;
  }
}
@media (min-width: 1024px) {
  .bottom-nav {
    max-width: 480px;
  }
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: color 0.2s ease;
  color: var(--text-muted);
  position: relative;
}

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

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* =========================================================
   CHAT SCREEN
   ========================================================= */

.chat-page .page-content {
  padding: 0;
  gap: 0;
}

.chat-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.chat-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), #6366F1);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.chat-header-info h2 {
  font-size: 16px;
  font-weight: 600;
}

.chat-header-info p {
  font-size: 12px;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-info p::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: calc(100vh - var(--header-height) - 80px - var(--nav-height));
  padding-bottom: 100px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.5;
}

.message.user .message-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

.message-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.message-context-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.context-chip {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.3);
}

.chat-input-bar {
  position: fixed;
  bottom: var(--nav-height);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  z-index: 150;
}

@media (min-width: 768px) {
  .chat-input-bar { max-width: 600px; }
}
@media (min-width: 1024px) {
  .chat-input-bar { max-width: 480px; }
}

.chat-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input:focus {
  border-color: var(--accent);
}

.send-btn {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
  box-shadow: var(--shadow-glow);
}

.send-btn:active {
  transform: scale(0.9);
}

.send-btn svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* =========================================================
   NEWS SCREEN
   ========================================================= */

.news-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: var(--space-xs) 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.news-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.news-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.news-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.news-player-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--bg-surface), var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.news-player-info {
  flex: 1;
}

.news-player-name {
  font-size: 15px;
  font-weight: 600;
}

.news-player-league {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.news-league-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--accent-dim);
  color: var(--accent);
}

.news-headline {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  font-weight: 400;
}

.news-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.news-source {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.news-time {
  font-size: 11px;
  color: var(--text-muted);
}

.news-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-xs) 0;
}

/* =========================================================
   HISTORY SCREEN
   ========================================================= */

.weekly-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.summary-stat {
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  text-align: center;
}

.summary-stat-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--accent);
}

.summary-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Bar Chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  height: 120px;
  padding: 0 var(--space-xs);
  margin-bottom: var(--space-md);
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.bar-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex: 1;
}

.bar {
  width: 28px;
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
  position: relative;
}

.bar.green  { background: linear-gradient(to top, #059669, var(--green)); }
.bar.yellow { background: linear-gradient(to top, #D97706, var(--yellow)); }
.bar.red    { background: linear-gradient(to top, #DC2626, var(--red)); }

.bar-day {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.bar-value {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.history-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255,255,255,0.02);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.history-date {
  min-width: 72px;
}

.history-date-main {
  font-size: 14px;
  font-weight: 600;
}

.history-date-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.history-score-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.history-score-badge.green  { background: var(--green-dim);  color: var(--green); }
.history-score-badge.yellow { background: var(--yellow-dim); color: var(--yellow); }
.history-score-badge.red    { background: var(--red-dim);    color: var(--red); }

.history-details {
  flex: 1;
}

.history-workout {
  font-size: 13px;
  font-weight: 500;
}

.history-workout-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-status {
  font-size: 18px;
  flex-shrink: 0;
}

/* =========================================================
   DATE CHIP (page labels)
   ========================================================= */

.page-label {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: var(--space-xs);
}

.page-sublabel {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

/* =========================================================
   UTILITY
   ========================================================= */

.text-green  { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red    { color: var(--red); }
.text-accent { color: var(--accent); }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }

.flex { display: flex; }
.items-center { align-items: center; }
.gap-sm { gap: var(--space-sm); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }

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

/* =========================================================
   SECTION DIVIDER
   ========================================================= */

.section-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: var(--space-xs) 0;
}
