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

:root {
  /* Colors */
  --coral-pink: #FF6B9D;
  --deep-rose: #C44569;
  --amber-gold: #FEC163;
  --sky-blue: #4A90E2;
  --soft-purple: #667EEA;
  --deep-navy: #1A1A2E;
  --midnight-blue: #16213E;
  --warm-white: #F8F8F2;

  /* Mood Colors */
  --energized: var(--coral-pink);
  --stressed: var(--deep-rose);
  --neutral: var(--amber-gold);
  --calm: var(--sky-blue);
  --contemplative: var(--soft-purple);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--deep-navy);
  color: var(--warm-white);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: 'Space Grotesk', sans-serif;
}

/* Layout */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--deep-navy);
}

.view {
  display: none;
  flex: 1;
  padding: 20px;
  padding-bottom: 100px;
  animation: slideIn 0.3s ease;
}

.view.active {
  display: flex;
  flex-direction: column;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
}

.header h1 {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--coral-pink), var(--soft-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 14px;
  color: rgba(248, 248, 242, 0.6);
  font-weight: 300;
}

/* Camera Container */
.camera-container {
  background: var(--midnight-blue);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  margin-bottom: 20px;
  aspect-ratio: 3/4;
}

#camera-video,
#preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#preview-container {
  width: 100%;
  height: 100%;
}

/* Mood Blob */
.mood-blob {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: float 3s ease-in-out infinite;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.mood-blob.analyzing {
  background: linear-gradient(135deg, var(--coral-pink), var(--soft-purple));
  animation: float 3s ease-in-out infinite, pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.mood-blob.energized {
  background: var(--energized);
}

.mood-blob.stressed {
  background: var(--stressed);
}

.mood-blob.neutral {
  background: var(--neutral);
}

.mood-blob.calm {
  background: var(--calm);
}

.mood-blob.contemplative {
  background: var(--contemplative);
}

/* Loading & Result States */
.loading-state,
.result-state {
  text-align: center;
  padding: 40px 20px;
}

.result-state h2 {
  font-size: 28px;
  margin-bottom: 12px;
  text-transform: capitalize;
}

.insight-text {
  font-size: 16px;
  line-height: 1.6;
  color: rgba(248, 248, 242, 0.8);
  margin-bottom: 24px;
}

/* Buttons */
.capture-btn {
  background: linear-gradient(135deg, var(--coral-pink), var(--soft-purple));
  border: none;
  border-radius: 50px;
  padding: 18px 40px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4);
  animation: pulseButton 2s ease-in-out infinite;
}

@keyframes pulseButton {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4);
  }
  50% {
    box-shadow: 0 4px 30px rgba(255, 107, 157, 0.6);
  }
}

.capture-btn:hover {
  transform: scale(1.05);
}

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

.btn-icon {
  font-size: 24px;
  line-height: 1;
}

.secondary-btn {
  background: var(--midnight-blue);
  border: 2px solid rgba(248, 248, 242, 0.2);
  border-radius: 50px;
  padding: 14px 32px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--warm-white);
  cursor: pointer;
  transition: all 0.2s;
  display: block;
  margin: 10px auto;
}

.secondary-btn:hover {
  border-color: rgba(248, 248, 242, 0.4);
  background: rgba(248, 248, 242, 0.05);
}

.camera-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Timeline */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.timeline-entry {
  background: var(--midnight-blue);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  animation: fadeIn 0.5s ease;
  animation-fill-mode: both;
}

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

.timeline-entry:nth-child(1) { animation-delay: 0.05s; }
.timeline-entry:nth-child(2) { animation-delay: 0.1s; }
.timeline-entry:nth-child(3) { animation-delay: 0.15s; }
.timeline-entry:nth-child(4) { animation-delay: 0.2s; }
.timeline-entry:nth-child(5) { animation-delay: 0.25s; }

.timeline-blob {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
}

.timeline-mood {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: capitalize;
}

.timeline-insight {
  font-size: 14px;
  color: rgba(248, 248, 242, 0.7);
  margin-bottom: 8px;
  line-height: 1.4;
}

.timeline-time {
  font-size: 12px;
  color: rgba(248, 248, 242, 0.4);
}

/* Patterns */
.patterns-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--midnight-blue);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 36px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--coral-pink), var(--soft-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  text-transform: capitalize;
}

.stat-label {
  font-size: 14px;
  color: rgba(248, 248, 242, 0.6);
}

.week-chart {
  background: var(--midnight-blue);
  border-radius: 16px;
  padding: 24px;
}

.week-chart h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

.week-moods {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mood-day {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mood-day-date {
  font-size: 12px;
  color: rgba(248, 248, 242, 0.6);
  min-width: 80px;
}

.mood-day-bar {
  flex: 1;
  height: 24px;
  border-radius: 12px;
  display: flex;
  overflow: hidden;
}

.mood-day-segment {
  height: 100%;
  transition: all 0.3s;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  opacity: 0.7;
}

.empty-state .mood-blob {
  margin-bottom: 20px;
}

.empty-state p {
  font-size: 18px;
  margin-bottom: 8px;
}

.empty-subtitle {
  font-size: 14px !important;
  color: rgba(248, 248, 242, 0.5) !important;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--midnight-blue);
  border-top: 1px solid rgba(248, 248, 242, 0.1);
  display: flex;
  justify-content: space-around;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
}

.nav-btn {
  background: none;
  border: none;
  color: rgba(248, 248, 242, 0.5);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  transition: color 0.2s;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
}

.nav-btn.active {
  color: var(--coral-pink);
}

.nav-btn svg {
  width: 24px;
  height: 24px;
}

/* Streak Badge */
.streak-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(22, 33, 62, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 18px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.streak-badge[data-streak-level="starting"] {
  opacity: 0.8;
}

.streak-badge[data-streak-level="building"] {
  animation: streakPulse 2s ease-in-out infinite;
  box-shadow: 0 4px 20px rgba(254, 193, 99, 0.4);
}

.streak-badge[data-streak-level="strong"] {
  animation: streakPulse 1.5s ease-in-out infinite;
  box-shadow: 0 4px 24px rgba(255, 107, 157, 0.5);
}

.streak-badge[data-streak-level="legendary"] {
  animation: streakShimmer 2s ease-in-out infinite;
  background: linear-gradient(135deg, var(--coral-pink), var(--soft-purple));
  box-shadow: 0 4px 28px rgba(255, 107, 157, 0.6);
}

.streak-badge[data-streak-level="legendary"] .streak-count {
  background: linear-gradient(135deg, #ffffff, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes streakPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.9;
  }
}

@keyframes streakShimmer {
  0% {
    filter: brightness(1) saturate(1);
  }
  50% {
    filter: brightness(1.2) saturate(1.3);
  }
  100% {
    filter: brightness(1) saturate(1);
  }
}

.streak-flame {
  font-size: 20px;
  line-height: 1;
}

.streak-count {
  line-height: 1;
}

/* Streak Toast */
.streak-toast {
  position: absolute;
  top: 70px;
  right: 16px;
  background: rgba(22, 33, 62, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.4s ease, fadeOut 0.4s ease 3.6s forwards;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(10px);
  }
}

/* Milestone Modal */
.milestone-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(20px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
  cursor: pointer;
}

.milestone-content {
  text-align: center;
  position: relative;
  padding: 40px;
  max-width: 480px;
  animation: zoomIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(-100px) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

.milestone-flame {
  font-size: 64px;
  margin-bottom: 20px;
  animation: float 2s ease-in-out infinite, pulse 1s ease-in-out infinite;
}

.milestone-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--coral-pink), var(--amber-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.milestone-text {
  font-size: 18px;
  color: rgba(248, 248, 242, 0.8);
  line-height: 1.6;
}

/* Enhanced Streak Stat Card */
.streak-stat-card {
  position: relative;
  overflow: hidden;
}

.streak-flame-large {
  font-size: 48px;
  margin-bottom: 8px;
  opacity: 0.3;
  filter: grayscale(100%);
  transition: all 0.3s ease;
}

.streak-stat-card[data-streak-level="building"] .streak-flame-large {
  opacity: 0.6;
  filter: grayscale(0%);
  animation: streakPulse 2s ease-in-out infinite;
}

.streak-stat-card[data-streak-level="strong"] .streak-flame-large {
  opacity: 0.8;
  filter: grayscale(0%);
  animation: streakPulse 1.5s ease-in-out infinite;
}

.streak-stat-card[data-streak-level="legendary"] .streak-flame-large {
  opacity: 1;
  filter: grayscale(0%) drop-shadow(0 0 10px rgba(254, 193, 99, 0.8));
  animation: streakShimmer 2s ease-in-out infinite;
}

.streak-status {
  font-size: 12px;
  color: rgba(248, 248, 242, 0.5);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Streak Calendar */
.streak-calendar {
  background: var(--midnight-blue);
  border-radius: 16px;
  padding: 24px;
  margin-top: 20px;
}

.streak-calendar h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

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

.streak-calendar-day {
  aspect-ratio: 1;
  border-radius: 8px;
  background: rgba(248, 248, 242, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: rgba(248, 248, 242, 0.3);
  transition: all 0.3s ease;
  position: relative;
}

.streak-calendar-day.checked {
  background: linear-gradient(135deg, var(--coral-pink), var(--soft-purple));
  color: white;
  box-shadow: 0 2px 8px rgba(255, 107, 157, 0.3);
}

.streak-calendar-day.checked::after {
  content: '✓';
  position: absolute;
  font-size: 16px;
  font-weight: bold;
}

.streak-calendar-day.today {
  border: 2px solid var(--amber-gold);
}

/* Insights Section */
.insights-section {
  margin-top: 30px;
}

.insights-section h3 {
  font-size: 18px;
  margin-bottom: 20px;
  padding-left: 4px;
}

.insights-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.insight-card {
  background: var(--midnight-blue);
  border-radius: 20px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeIn 0.6s ease;
  animation-fill-mode: both;
}

.insight-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.insight-card.featured {
  grid-column: 1 / -1;
  padding: 32px;
  background: linear-gradient(135deg,
    rgba(255, 107, 157, 0.15) 0%,
    rgba(102, 126, 234, 0.15) 100%),
    var(--midnight-blue);
  border: 1px solid rgba(255, 107, 157, 0.2);
  min-height: 180px;
}

.insight-card.featured::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 107, 157, 0.3) 0%, transparent 70%);
  filter: blur(40px);
  pointer-events: none;
  animation: ambientPulse 4s ease-in-out infinite;
}

@keyframes ambientPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.1); }
}

.insight-card:nth-child(1) { animation-delay: 0.1s; }
.insight-card:nth-child(2) { animation-delay: 0.2s; }
.insight-card:nth-child(3) { animation-delay: 0.3s; }

.insight-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(255, 107, 157, 0.4));
}

.insight-card.featured .insight-icon {
  font-size: 64px;
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
}

.insight-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(248, 248, 242, 0.5);
  font-weight: 600;
  margin-bottom: 8px;
}

.insight-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--coral-pink), var(--amber-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  line-height: 1.1;
}

.insight-card.featured .insight-value {
  font-size: 42px;
  max-width: 70%;
}

.insight-description {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(248, 248, 242, 0.7);
}

.insight-card.featured .insight-description {
  font-size: 16px;
  max-width: 70%;
}

.insight-card[data-mood="positive"] { border-left: 4px solid var(--amber-gold); }
.insight-card[data-mood="attention"] { border-left: 4px solid var(--deep-rose); }
.insight-card[data-mood="neutral"] { border-left: 4px solid var(--soft-purple); }

.insight-card.encouragement {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 24px;
  background: linear-gradient(135deg,
    rgba(102, 126, 234, 0.1) 0%,
    rgba(74, 144, 226, 0.1) 100%),
    var(--midnight-blue);
  border: 2px dashed rgba(248, 248, 242, 0.2);
}

.encouragement .insight-icon {
  font-size: 56px;
  margin: 0 auto 16px;
  filter: drop-shadow(0 4px 12px rgba(102, 126, 234, 0.4));
}

.encouragement .insight-value {
  font-size: 24px;
  background: linear-gradient(135deg, var(--soft-purple), var(--sky-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.encouragement .insight-description {
  font-size: 15px;
  color: rgba(248, 248, 242, 0.6);
}

.encouragement-progress {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(248, 248, 242, 0.2);
  transition: all 0.3s ease;
}

.progress-dot.filled {
  background: linear-gradient(135deg, var(--soft-purple), var(--sky-blue));
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.5);
}

/* Responsive */
@media (max-width: 480px) {
  .view {
    padding: 16px;
    padding-bottom: 100px;
  }

  .header h1 {
    font-size: 28px;
  }

  .capture-btn {
    padding: 16px 32px;
    font-size: 16px;
  }

  .streak-badge {
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    font-size: 16px;
  }

  .streak-toast {
    top: 60px;
    right: 12px;
    font-size: 13px;
  }

  .milestone-flame {
    font-size: 56px;
  }

  .milestone-title {
    font-size: 28px;
  }

  .milestone-text {
    font-size: 16px;
  }

  .insights-container {
    grid-template-columns: 1fr;
  }

  .insight-card.featured .insight-icon {
    position: relative;
    right: auto;
    top: auto;
    transform: none;
    margin-bottom: 16px;
  }

  .insight-card.featured .insight-value,
  .insight-card.featured .insight-description {
    max-width: 100%;
  }
}
