/* ======================================================================
   FinishWorkoutModal CSS — Separated from business logic for easier redesign
   ====================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css');

.fwm-modal {
  /* Design tokens matching workout page */
  --fwm-font: "Figtree", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  
  --fwm-tfast: 0.2s;
  --fwm-tmed: 0.3s;
  
  --fwm-r-sm: 0.375rem;
  --fwm-r-md: 0.5rem;
  --fwm-r-lg: 1rem;
  --fwm-r-xl: 1.5rem;
  
  /* Colors matching workout page */
  --fwm-bg: #1a1a1a;
  --fwm-surface-1: rgba(255, 255, 255, 0.05);
  --fwm-surface-2: rgba(255, 255, 255, 0.08);
  --fwm-surface-inset: #252525;
  
  --fwm-text-h: #f5f5f5;
  --fwm-text: #e9edf1;
  --fwm-text-body: rgba(255, 255, 255, 0.9);
  --fwm-text-muted: #a1a1aa;
  
  --fwm-border-1: rgba(255, 255, 255, 0.2);
  --fwm-border-2: rgba(255, 255, 255, 0.1);
  
  --fwm-accent: #facc15; /* yellow */
  --fwm-accent-green: #4caf50;
}

/* Highlight animations for workout completion */
.highlight-new {
  animation: highlightPulse 1.5s ease-in-out;
}

.highlight-update {
  animation: highlightGlow 1.5s ease-in-out;
}

.zoom-reveal {
  animation: zoomReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes highlightPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
  50% { transform: scale(1.08); box-shadow: 0 0 20px 10px rgba(46, 204, 113, 0.3); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

@keyframes highlightGlow {
  0% { background-color: transparent; }
  50% { background-color: rgba(46, 204, 113, 0.15); }
  100% { background-color: transparent; }
}

@keyframes zoomReveal {
  0% { 
    transform: scale(0.5); 
    opacity: 0;
  }
  60% { 
    transform: scale(1.1); 
  }
  100% { 
    transform: scale(1); 
    opacity: 1;
  }
}

.fwm-no-scroll { overflow: hidden; }

.fwm-modal {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: none;
  font-family: var(--fwm-font);
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.fwm-modal.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Dialog */
.fwm-dialog {
  position: relative;
  width: 100%;
  max-width: 500px;
  background: var(--fwm-bg);
  color: var(--fwm-text-body);
  border-radius: var(--fwm-r-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--fwm-border-2);
  outline: none;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity var(--fwm-tfast), transform var(--fwm-tfast);
  overflow: hidden;
  z-index: 10020;
}

.fwm-modal.is-open .fwm-dialog { 
  opacity: 1; 
  transform: scale(1);
  animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Confetti Canvas */
.fwm-confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Pre-Rating Screen */
.fwm-pre-rating-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

.fwm-pre-rating-screen.is-visible {
  opacity: 1;
  visibility: visible;
}

.fwm-pre-rating-video-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  overflow: hidden;
  border-radius: var(--fwm-r-lg);
}

.fwm-pre-rating-video-container iframe,
.fwm-pre-rating-video-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
  border-radius: var(--fwm-r-lg);
}

.fwm-pre-rating-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.85) 25%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0) 75%);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  z-index: 2;
}

.fwm-pre-rating-subtitle {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fwm-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fwm-pre-rating-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  text-align: center;
  line-height: 1.3;
}

.fwm-pre-rating-stars {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.fwm-pre-rating-finish-btn {
  width: 100%;
  max-width: 400px;
  background-color: #ffffff;
  color: #000000;
  border: none;
  padding: 1rem 2rem;
  border-radius: var(--fwm-r-md);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--fwm-tmed) ease;
  margin-top: 0.5rem;
}

.fwm-pre-rating-finish-btn:hover {
  background-color: #e5e5e5;
  transform: translateY(-1px);
}

.fwm-pre-rating-finish-btn:active {
  transform: translateY(0);
}

/* Content */
.fwm-body {
  padding: 0.5rem 1.5rem 1.5rem;
  text-align: center;
  position: relative;
  z-index: 2;
  display: none; /* Hidden by default, shown only after pre-rating */
}

.fwm-title {
  margin: 0 0 1rem;
  font-size: 1.625rem;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--fwm-text-h);
}

/* Auto-Complete Disclaimer Banner */
.fwm-auto-complete-disclaimer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--fwm-r-md);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.fwm-disclaimer-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.fwm-disclaimer-text {
  font-size: 0.875rem;
  color: rgba(251, 191, 36, 0.9);
  font-weight: 500;
  text-align: center;
}

/* Icons Row */
.fwm-icons-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  margin-bottom: 1rem;
}

.fwm-milestone-badge {
  background-color: var(--fwm-accent);
  color: black;
  padding: 4px 12px;
  border-radius: 9999px;
  font-weight: 500;
  font-size: 11px;
  animation: pulse 2s infinite;
}

.fwm-action-button-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.fwm-action-button-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  text-transform: lowercase;
  font-family: 'Figtree', ui-sans-serif, system-ui, sans-serif;
  font-weight: 500;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  margin-top: 0.1rem;
}

.fwm-streak-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: transparent;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  transition: all 0.3s;
}

.fwm-streak-icon {
  color: var(--fwm-accent);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.fwm-streak-number {
  color: var(--fwm-text-h);
  font-weight: bold;
  font-size: 16px;
  transition: transform 0.3s ease, color 0.3s ease;
  line-height: 1;
}

/* Streak increase animation */
.fwm-streak-number.streak-increase {
  animation: streakPulse 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: #ff6b35; /* Orange/red color for streak increase */
}

@keyframes streakPulse {
  0% {
    transform: scale(1);
    color: var(--fwm-text-h);
  }
  30% {
    transform: scale(1.4);
    color: #ff6b35;
  }
  60% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
    color: #ff6b35;
  }
}

.fwm-icon-btn {
  background-color: transparent;
  backdrop-filter: none;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  transition: all 0.3s;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.fwm-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.fwm-icon-btn:active {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(0.95);
}

.fwm-heart-btn.liked {
  color: #ef4444;
  background-color: transparent;
}

.fwm-heart-btn.liked:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

.fwm-heart-btn.liked svg {
  color: #ef4444;
  fill: #ef4444;
}

/* Tab Container */
.fwm-tab-container {
  position: relative;
  background-color: var(--fwm-surface-inset);
  border: 1px solid var(--fwm-border-1);
  border-radius: var(--fwm-r-lg);
  padding: 4px;
  display: flex;
  margin-bottom: 1.5rem;
}

.fwm-tab-slider {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  width: calc(50% - 4px);
  background-color: var(--fwm-text-h);
  border-radius: var(--fwm-r-md);
  transition: transform var(--fwm-tmed) ease;
  z-index: 1;
}

.fwm-tab-slider.community {
  transform: translateX(calc(100% + 4px));
}

.fwm-tab-btn {
  position: relative;
  z-index: 2;
  flex: 1;
  background: transparent;
  border: none;
  color: var(--fwm-text-h);
  padding: 12px 16px;
  border-radius: var(--fwm-r-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--fwm-tmed) ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.fwm-tab-btn.active {
  color: var(--fwm-bg);
}

.fwm-tab-btn:hover:not(.active) {
  color: var(--fwm-text-muted);
}

/* Tab Content */
.fwm-tab-content {
  position: relative;
  z-index: 2;
}

.fwm-tab-panel {
  display: none;
}

.fwm-tab-panel.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Stats tab specific styling */
#fwmStatsTab.active {
  display: block;
  height: auto;
}

/* Stats Grid */
.fwm-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.fwm-stat-card {
  background-color: var(--fwm-surface-inset);
  border: 1px solid var(--fwm-border-1);
  border-radius: var(--fwm-r-lg);
  padding: 16px;
  text-align: center;
}

.fwm-stat-label {
  font-size: 14px;
  color: var(--fwm-text-muted);
  margin-bottom: 4px;
}

.fwm-stat-value {
  font-size: 24px;
  font-weight: 500;
  color: var(--fwm-text-h);
  text-transform: capitalize;
}

.fwm-difficulty-beginner { color: var(--fwm-accent-green); }
.fwm-difficulty-intermediate { color: var(--fwm-accent); }
.fwm-difficulty-advanced { color: #f97316; }
.fwm-difficulty-professional { color: #ef4444; }

/* Section Title */
.fwm-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fwm-text-h);
  text-align: center;
  margin-bottom: 4px;
  margin-top: 0;
  flex-shrink: 0;
}

/* Chart Container */
.fwm-chart-container {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.fwm-pie-chart {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  order: 1;
}

.fwm-pie-svg {
  width: 120px;
  height: 120px;
}

.fwm-pie-segment {
  transition: opacity var(--fwm-tmed) ease;
  cursor: pointer;
}

.fwm-pie-segment:hover {
  opacity: 0.8;
}

.fwm-exercise-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  order: 2;
}

.fwm-exercise-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  cursor: pointer;
  transition: opacity var(--fwm-tmed) ease;
  padding: 4px 0;
  gap: 8px;
}

.fwm-exercise-item:hover {
  opacity: 0.7;
}

.fwm-exercise-name {
  color: var(--fwm-text-muted);
}

.fwm-exercise-percentage {
  color: var(--fwm-text-h);
  font-weight: 500;
}

/* Rating Container */
.fwm-rating-container {
  background-color: var(--fwm-surface-inset);
  border: 1px solid var(--fwm-border-1);
  border-radius: var(--fwm-r-lg);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  margin-top: 0;
  flex-shrink: 0;
}

.fwm-rating-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fwm-text-h);
}

.fwm-star-rating {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

/* Shared star styles */
.fwm-star {
  background: none;
  border: none;
  padding: 0.35rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, filter 0.2s ease;
  color: inherit;
}

.fwm-star svg {
  width: 2rem;
  height: 2rem;
  fill: rgba(255, 255, 255, 0.32);
  transition: fill 0.2s ease, filter 0.2s ease;
}

/* Slightly smaller stars inside the community tab rating row */
.fwm-star-rating .fwm-star {
  padding: 0.25rem;
}

.fwm-star-rating .fwm-star svg {
  width: 1.6rem;
  height: 1.6rem;
}

.fwm-star:hover,
.fwm-star.hover {
  transform: scale(1.12);
}

.fwm-star:hover svg,
.fwm-star.hover svg {
  fill: var(--fwm-accent);
  filter: drop-shadow(0 0 6px rgba(250, 204, 21, 0.4));
}

.fwm-star.active svg {
  fill: var(--fwm-accent);
  filter: drop-shadow(0 0 4px rgba(250, 204, 21, 0.35));
}

/* Comments Container */
.fwm-comments-container {
  margin-bottom: 0;
  max-height: 300px;
  min-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.fwm-comments-container::-webkit-scrollbar {
  width: 4px;
}

.fwm-comments-container::-webkit-scrollbar-track {
  background: transparent;
}

.fwm-comments-container::-webkit-scrollbar-thumb {
  background: var(--fwm-border-2);
  border-radius: 2px;
}

.fwm-comments-container::-webkit-scrollbar-thumb:hover {
  background: var(--fwm-border-1);
}

.fwm-comment-card {
  background-color: var(--fwm-surface-inset);
  border: 1px solid var(--fwm-border-1);
  border-radius: var(--fwm-r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
  text-align: left;
}

.fwm-comment-card > div:first-child {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.fwm-comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.fwm-comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fwm-comment-content {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.fwm-comment-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  text-align: left;
}

.fwm-comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fwm-comment-user {
  font-weight: 500;
  color: var(--fwm-text-h);
  font-size: 14px;
}

.fwm-comment-location {
  color: var(--fwm-text-muted);
  font-weight: normal;
}

.fwm-comment-time {
  font-size: 12px;
  color: var(--fwm-text-muted);
  flex-shrink: 0;
}

.fwm-comment-text {
  font-size: 14px;
  color: var(--fwm-text-muted);
  line-height: 1.5;
  text-align: left;
}

/* Buttons */
.fwm-cta-button {
  width: 100%;
  background-color: #2a2a2a;
  color: var(--fwm-text-h);
  border: 1px solid var(--fwm-border-1);
  padding: 12px 24px;
  border-radius: var(--fwm-r-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--fwm-tmed) ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 0;
  margin-top: 16px;
  flex-shrink: 0;
}

.fwm-cta-button:hover {
  background-color: #333333;
}

.fwm-cta-button-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #1a1a1a !important;
  color: var(--fwm-text-muted) !important;
  border-color: var(--fwm-border-2) !important;
}

.fwm-cta-button-disabled:hover {
  background-color: #1a1a1a !important;
  transform: none !important;
}

.fwm-view-more-btn {
  width: 100%;
  background: transparent;
  color: var(--fwm-text-muted);
  border: none;
  padding: 8px 16px;
  border-radius: var(--fwm-r-md);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--fwm-tmed) ease;
  margin-bottom: 16px;
}

.fwm-view-more-btn:hover {
  color: var(--fwm-text-h);
  background-color: rgba(255, 255, 255, 0.1);
}

/* Return Home */
.fwm-return-home {
  text-align: center;
  padding-top: 6px;
}

.fwm-return-btn {
  background: transparent;
  border: none;
  color: var(--fwm-text-muted);
  font-size: 14px;
  font-weight: 300;
  cursor: pointer;
  transition: color var(--fwm-tmed) ease;
}

.fwm-return-btn:hover {
  color: var(--fwm-text-h);
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Mobile Styles */
@media (max-width: 768px) {
  .fwm-modal.is-open {
    padding: 0;
    align-items: stretch;
  }

  .fwm-dialog {
    margin: 0;
    border-radius: 0;
    padding: 16px 20px 20px;
    width: 100%;
    max-width: none;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* Pre-Rating Screen Mobile */
  .fwm-pre-rating-video-container {
    border-radius: 0;
  }

  .fwm-pre-rating-video-container iframe,
  .fwm-pre-rating-video-container img {
    border-radius: 0;
  }

  .fwm-pre-rating-content {
    height: 100%;
    padding: 2rem 1.5rem calc(6rem + env(safe-area-inset-bottom, 0px));
    gap: 0.75rem;
  }

  .fwm-pre-rating-title {
    font-size: 1.25rem;
  }

  .fwm-star svg {
    width: 1.75rem;
    height: 1.75rem;
  }

  /* Community tab stars stay tighter on mobile too */
  .fwm-star-rating .fwm-star svg {
    width: 1.45rem;
    height: 1.45rem;
  }

  .fwm-pre-rating-finish-btn {
    font-size: 0.75rem;
    padding: 0.875rem 1.5rem;
    margin-bottom: env(safe-area-inset-bottom, 0px);
  }

  .fwm-star svg {
    width: 1.75rem;
    height: 1.75rem;
  }
  
  .fwm-title {
    font-size: 14px;
    margin-bottom: 10px;
    margin-top: 0;
  }
  
  .fwm-rating-title {
    font-size: 14px;
    font-weight: 500;
  }
  
  .fwm-stat-value {
    font-size: 15px;
  }
  
  .fwm-stat-label {
    font-size: 12px;
  }
  
  .fwm-body {
    padding: 2rem 0 0;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: flex-start;
  }
  
  .fwm-chart-container {
    flex-direction: row;
    gap: 16px;
  }
  
  .fwm-pie-svg {
    width: 100px;
    height: 100px;
  }
  
  .fwm-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  
  .fwm-stat-card {
    padding: 12px;
  }
  
  .fwm-icon-btn {
    width: 36px;
    height: 36px;
  }
  
  .fwm-tab-btn {
    font-size: 12px;
    padding: 10px 12px;
  }
  
  .fwm-cta-button {
    height: 40px;
    font-size: 12px;
  }
  
  .fwm-comment-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .fwm-comment-meta {
    order: 1;
    align-self: flex-end;
  }
  
  .fwm-comment-user {
    order: 2;
  }
  
  .fwm-comments-container {
    max-height: 250px;
    min-height: 175px;
  }
}

@media (max-width: 480px) {
  .fwm-dialog {
    margin: 0;
    padding: 16px;
  }
  
  .fwm-title {
    font-size: 14px;
  }
  
  .fwm-icons-row {
    gap: 12px;
  }
  
  .fwm-tab-btn {
    font-size: 12px;
    padding: 10px 12px;
  }
}

