/* CSS Custom Variables for Theme Styling */
:root {
  /* Dark Mode Variables (Default) */
  --bg-primary: #0b0e14;
  --bg-secondary: #121620;
  --bg-tertiary: #1b202e;
  --border-color: #1e2533;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-physical: #06b6d4;
  --accent-physical-grad: linear-gradient(135deg, #00f2fe, #4facfe);
  
  --accent-diet: #10b981;
  --accent-diet-grad: linear-gradient(135deg, #43e97b, #38f9d7);
  
  --accent-streak: #f97316;
  --accent-streak-grad: linear-gradient(135deg, #f97316, #ef4444);
  --accent-streak-bg: rgba(249, 115, 22, 0.1);

  --accent-record: #eab308;
  --accent-record-grad: linear-gradient(135deg, #fde047, #ca8a04);
  --accent-record-bg: rgba(234, 179, 8, 0.1);

  --active-tab-bg: #1c2333;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-speed: 0.25s;
}

[data-theme="light"] {
  /* Light Mode Variables */
  --bg-primary: #f4f6f9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-physical: #0284c7;
  --accent-physical-grad: linear-gradient(135deg, #0284c7, #2563eb);
  
  --accent-diet: #059669;
  --accent-diet-grad: linear-gradient(135deg, #059669, #15803d);
  
  --accent-streak: #ea580c;
  --accent-streak-grad: linear-gradient(135deg, #ea580c, #dc2626);
  --accent-streak-bg: rgba(234, 88, 12, 0.08);

  --accent-record: #d97706;
  --accent-record-grad: linear-gradient(135deg, #d97706, #b45309);
  --accent-record-bg: rgba(217, 119, 6, 0.08);

  --active-tab-bg: #f8fafc;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color var(--transition-speed), color var(--transition-speed);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: 75px; /* Space for bottom nav on mobile */
}

/* Layout Container */
.container {
  width: 100%;
  max-width: 600px; /* Centered layout perfect for phone view */
  margin: 0 auto;
  padding: 16px;
}

/* Header Component */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 8px 0;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-streak-grad);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.4);
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Round Action Button (Icon Buttons) */
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-speed);
}

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

/* Global Stats Panel */
.global-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-speed);
}

.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text-primary);
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .icon {
  font-size: 18px;
  margin-bottom: 4px;
  display: inline-block;
}

/* Tab Content Visibility */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

/* Filters & Action Bar */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 10px;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-speed);
}

.filter-btn.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

/* Standard Buttons */
.btn-primary {
  background: var(--text-primary);
  color: var(--bg-primary);
  border: none;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-speed);
}

.btn-primary:active {
  transform: scale(0.95);
}

/* Challenge Cards */
.challenges-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.challenge-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-speed);
}

.challenge-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.challenge-card.category-physical::before {
  background: var(--accent-physical-grad);
}

.challenge-card.category-diet::before {
  background: var(--accent-diet-grad);
}

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

.challenge-info {
  flex: 1;
  padding-right: 8px;
}

.challenge-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.category-physical .challenge-badge {
  background-color: rgba(6, 182, 212, 0.1);
  color: var(--accent-physical);
}

.category-diet .challenge-badge {
  background-color: rgba(16, 183, 129, 0.1);
  color: var(--accent-diet);
}

.challenge-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
}

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

/* Quick Check Toggle Area */
.quick-check-area {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}

.check-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed var(--border-color);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: all var(--transition-speed);
}

.check-pill .day-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-weight: 500;
}

.check-pill .status-label {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Custom completion check styling */
.check-pill.completed {
  border-style: solid;
  color: white;
}

.category-physical .check-pill.completed {
  background: var(--accent-physical-grad);
  border-color: var(--accent-physical);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.category-diet .check-pill.completed {
  background: var(--accent-diet-grad);
  border-color: var(--accent-diet);
  box-shadow: 0 0 10px rgba(16, 182, 129, 0.2);
}

/* Card Streaks Display */
.card-streaks {
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  font-size: 13px;
}

.streak-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
}

.streak-indicator.current {
  color: var(--accent-streak);
  background-color: var(--accent-streak-bg);
}

.streak-indicator.current.pulsing-streak {
  animation: streakPulse 1.5s infinite alternate;
}

.streak-indicator.record {
  color: var(--accent-record);
  background-color: var(--accent-record-bg);
}

.streak-indicator .material-symbols-outlined {
  font-size: 18px;
}

/* Calendar Toggle Button */
.calendar-toggle {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}

.calendar-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Card Calendar Expandable Panel */
.calendar-expand {
  display: none;
  border-top: 1px solid var(--border-color);
  margin-top: 14px;
  padding-top: 14px;
  animation: slideDown 0.3s ease;
}

.calendar-expand.active {
  display: block;
}

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

.calendar-month-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.calendar-weekday {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  padding-bottom: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  transition: all 0.2s;
}

.calendar-day.empty {
  background: transparent;
  cursor: default;
  pointer-events: none;
}

.calendar-day:not(.empty):active {
  transform: scale(0.85);
}

.calendar-day.completed {
  color: white;
  font-weight: 700;
}

.category-physical .calendar-day.completed {
  background: var(--accent-physical-grad);
}

.category-diet .calendar-day.completed {
  background: var(--accent-diet-grad);
}

.calendar-day.today {
  border: 1.5px solid var(--text-primary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* Modals & Forms styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 100%;
  max-width: 450px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-box h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 18px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--text-primary);
}

textarea.form-control {
  resize: none;
  height: 80px;
}

/* Segmented Category Picker in Form */
.category-picker {
  display: flex;
  gap: 10px;
}

.picker-option {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all var(--transition-speed);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.picker-option.selected[data-value="physical"] {
  border-color: var(--accent-physical);
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-physical);
}

.picker-option.selected[data-value="diet"] {
  border-color: var(--accent-diet);
  background: rgba(16, 183, 129, 0.1);
  color: var(--accent-diet);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

/* Manage Tab List Items */
.manage-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
}

.manage-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.manage-item-title {
  font-weight: 600;
  font-size: 15px;
}

.manage-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.manage-actions {
  display: flex;
  gap: 6px;
}

.btn-danger-icon {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger-icon:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Statistics Screen styling */
.stats-overview {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chart-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-md);
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* SVG Chart Elements */
.svg-chart-wrapper {
  position: relative;
  width: 100%;
  height: 180px;
}

.svg-chart {
  width: 100%;
  height: 100%;
}

.chart-grid-line {
  stroke: var(--border-color);
  stroke-width: 1;
  stroke-dasharray: 4,4;
}

.chart-line-phys {
  stroke: var(--accent-physical);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-diet {
  stroke: var(--accent-diet);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-bar-phys {
  fill: var(--accent-physical);
  rx: 4;
}

.chart-bar-diet {
  fill: var(--accent-diet);
  rx: 4;
}

.chart-axis-text {
  font-size: 10px;
  fill: var(--text-muted);
  font-weight: 500;
}

/* Custom Heatmap/Activity Grid (similar to GitHub contributions) */
.heatmap-container {
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  gap: 3px;
  width: max-content;
}

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background-color: var(--bg-tertiary);
  transition: background-color 0.2s;
}

.heatmap-cell.level-1 {
  background-color: rgba(6, 182, 212, 0.4);
}

.heatmap-cell.level-2 {
  background-color: rgba(16, 183, 129, 0.55);
}

.heatmap-cell.level-3 {
  background-color: var(--accent-diet);
}

.heatmap-cell.level-4 {
  background-color: var(--accent-physical);
}

.heatmap-legend {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 10px;
}

.heatmap-legend-box {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* Bottom Navigation (Fixed at screen bottom) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background-color: rgba(18, 22, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 90;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  transition: background-color var(--transition-speed);
}

[data-theme="light"] .bottom-nav {
  background-color: rgba(255, 255, 255, 0.85);
}

.nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  gap: 3px;
  transition: color 0.2s;
}

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

.nav-item svg {
  stroke-width: 2px;
  transition: transform 0.2s, stroke-width 0.2s;
  color: var(--text-secondary);
}

.nav-item.active svg {
  stroke-width: 2.5px;
  color: var(--text-primary);
  transform: translateY(-2px);
}

/* Inline SVG Helper Styles */
svg {
  flex-shrink: 0;
}
.btn-icon svg, .btn-primary svg, .btn-secondary svg, .streak-indicator svg, .calendar-toggle svg, .manage-actions svg {
  stroke: currentColor;
}

/* Toast Notification */
.toast-msg {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  z-index: 200;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-msg.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Keyframes & Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes streakPulse {
  from { transform: scale(1); box-shadow: 0 0 5px rgba(249, 115, 22, 0.2); }
  to { transform: scale(1.03); box-shadow: 0 0 12px rgba(249, 115, 22, 0.4); }
}

/* Media Queries for Desktop layout compatibility */
@media (min-width: 601px) {
  body {
    padding-bottom: 0;
    align-items: center;
    justify-content: center;
  }
  
  .container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    margin: 40px auto;
    box-shadow: var(--shadow-lg);
    min-height: 80vh;
    padding: 24px;
    position: relative;
    padding-bottom: 80px;
  }
  
  .bottom-nav {
    position: absolute;
    width: calc(100% - 2px);
    bottom: 1px;
    left: 1px;
    border-radius: 0 0 23px 23px;
    border-bottom: none;
    border-left: none;
    border-right: none;
  }
}

/* Spinner for Loading State */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-streak);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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