/**
 * FitKPCS Widget Styles
 * Modern, responsive design with excellent readability
 */

/* Widget Container */
.fitkpcs-widget {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  container-type: inline-size;
  container-name: fitkpcs-widget;
}

/* Light Theme */
.fitkpcs-theme-light {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  color: #0f172a;
  border: 1px solid #e2e8f0;
}

.fitkpcs-theme-light .fitkpcs-stat {
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
}

.fitkpcs-theme-light .fitkpcs-progress-bar {
  background: #e2e8f0;
}

.fitkpcs-theme-light .fitkpcs-progress-fill {
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
}

.fitkpcs-theme-light .fitkpcs-charity {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24;
}

.fitkpcs-theme-light .fitkpcs-leaderboard-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.fitkpcs-theme-light .fitkpcs-leaderboard-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Dark Theme */
.fitkpcs-theme-dark {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #f1f5f9;
  border: 1px solid #475569;
}

.fitkpcs-theme-dark .fitkpcs-stat {
  background: linear-gradient(135deg, #334155 0%, #475569 100%);
  border: 1px solid #475569;
}

.fitkpcs-theme-dark .fitkpcs-progress-bar {
  background: #475569;
}

.fitkpcs-theme-dark .fitkpcs-progress-fill {
  background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 100%);
}

.fitkpcs-theme-dark .fitkpcs-charity {
  background: linear-gradient(135deg, #422006 0%, #713f12 100%);
  border: 1px solid #92400e;
}

.fitkpcs-theme-dark .fitkpcs-leaderboard-item {
  background: #334155;
  border: 1px solid #475569;
}

.fitkpcs-theme-dark .fitkpcs-leaderboard-item:hover {
  background: #475569;
  border-color: #64748b;
}

.fitkpcs-theme-dark .fitkpcs-link {
  color: #60a5fa;
}

/* Header */
.fitkpcs-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid currentColor;
  border-bottom-opacity: 0.15;
}

.fitkpcs-title {
  margin: 0 0 12px 0;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.3;
  color: inherit;
}

.fitkpcs-subtitle {
  font-size: 15px;
  opacity: 0.75;
  margin-bottom: 8px;
  line-height: 1.5;
}

.fitkpcs-date-range {
  font-size: 14px;
  opacity: 0.65;
  font-weight: 500;
}

.fitkpcs-days-remaining {
  font-weight: 700;
  opacity: 1;
  color: #f59e0b;
  font-size: 15px;
  margin-top: 4px;
}

/* Stats Grid - 2x2 responsive layout */
.fitkpcs-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.fitkpcs-stat {
  padding: 20px 16px;
  border-radius: 12px;
  text-align: center;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.fitkpcs-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.fitkpcs-stat-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 6px;
  color: #3b82f6;
  display: block;
}

.fitkpcs-theme-dark .fitkpcs-stat-value {
  color: #60a5fa;
}

.fitkpcs-stat-label {
  font-size: 13px;
  opacity: 0.75;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Charity Section */
.fitkpcs-charity {
  margin-bottom: 24px;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.fitkpcs-section-title {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fitkpcs-section-title::before {
  content: '🎗️';
  font-size: 20px;
}

.fitkpcs-charity-progress {
  margin-bottom: 12px;
}

.fitkpcs-progress-bar {
  height: 32px;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fitkpcs-progress-fill {
  height: 100%;
  border-radius: 16px;
  transition: width 0.6s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.fitkpcs-progress-label {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.fitkpcs-charity-donors {
  font-size: 14px;
  opacity: 0.8;
  text-align: center;
  margin-top: 8px;
  font-weight: 500;
}

/* Leaderboard */
.fitkpcs-leaderboard {
  margin-bottom: 24px;
}

.fitkpcs-team-list,
.fitkpcs-user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fitkpcs-leaderboard-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-radius: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.fitkpcs-rank {
  font-weight: 800;
  font-size: 18px;
  width: 36px;
  text-align: center;
  color: #3b82f6;
}

.fitkpcs-theme-dark .fitkpcs-rank {
  color: #60a5fa;
}

.fitkpcs-rank.top-1 {
  color: #f59e0b;
}

.fitkpcs-rank.top-2 {
  color: #94a3b8;
}

.fitkpcs-rank.top-3 {
  color: #cd7f32;
}

.fitkpcs-name {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  margin: 0 12px;
}

.fitkpcs-points {
  font-weight: 700;
  font-size: 16px;
  color: #3b82f6;
  white-space: nowrap;
}

.fitkpcs-theme-dark .fitkpcs-points {
  color: #60a5fa;
}

/* CTA Button */
.fitkpcs-cta {
  text-align: center;
  margin: 24px 0;
}

.fitkpcs-cta-button {
  display: inline-block;
  padding: 16px 32px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  /* Responsive text handling */
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
  line-height: 1.4;
}

.fitkpcs-cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.fitkpcs-cta-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.fitkpcs-theme-dark .fitkpcs-cta-button {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
}

.fitkpcs-theme-dark .fitkpcs-cta-button:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 6px 20px rgba(96, 165, 250, 0.4);
}

/* Footer */
.fitkpcs-footer {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid currentColor;
  border-top-opacity: 0.15;
  font-size: 13px;
  opacity: 0.75;
}

.fitkpcs-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s ease;
}

.fitkpcs-link:hover {
  opacity: 0.7;
  text-decoration: underline;
}

.fitkpcs-updated {
  margin-top: 8px;
  opacity: 0.65;
  font-size: 12px;
}

/* Error State */
.fitkpcs-error {
  text-align: center;
  padding: 48px 24px;
}

.fitkpcs-error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.fitkpcs-error-message {
  color: #ef4444;
  font-weight: 600;
  font-size: 16px;
}

/* Responsive Design */
@media (max-width: 640px) {
  .fitkpcs-widget {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .fitkpcs-title {
    font-size: 22px;
  }

  .fitkpcs-subtitle {
    font-size: 14px;
  }

  .fitkpcs-stats-grid {
    gap: 12px;
  }

  .fitkpcs-stat {
    padding: 16px 12px;
  }

  .fitkpcs-stat-value {
    font-size: 26px;
  }

  .fitkpcs-stat-label {
    font-size: 11px;
  }

  .fitkpcs-progress-bar {
    height: 28px;
  }

  .fitkpcs-progress-fill {
    font-size: 12px;
  }

  .fitkpcs-leaderboard-item {
    padding: 12px 14px;
  }

  .fitkpcs-rank {
    font-size: 16px;
    width: 32px;
  }

  .fitkpcs-name {
    font-size: 14px;
    margin: 0 10px;
  }

  .fitkpcs-points {
    font-size: 14px;
  }

  .fitkpcs-cta-button {
    padding: 14px 24px;
    font-size: 16px;
  }
}

/* Extra small screens */
@media (max-width: 400px) {
  .fitkpcs-stat-value {
    font-size: 22px;
  }

  .fitkpcs-stat-label {
    font-size: 10px;
  }

  .fitkpcs-name {
    font-size: 13px;
  }

  .fitkpcs-points {
    font-size: 13px;
  }

  /* Ultra-responsive button for very narrow screens (iPhone SE, etc.) */
  .fitkpcs-cta-button {
    padding: 12px 16px;
    font-size: 14px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
    min-width: 0;
  }
}

/* Animation for loading */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.fitkpcs-loading {
  animation: pulse 2s ease-in-out infinite;
}

/* Smooth entrance animation */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fitkpcs-widget > * {
  animation: fadeInUp 0.4s ease-out backwards;
}

.fitkpcs-widget > *:nth-child(2) {
  animation-delay: 0.1s;
}

.fitkpcs-widget > *:nth-child(3) {
  animation-delay: 0.2s;
}

.fitkpcs-widget > *:nth-child(4) {
  animation-delay: 0.3s;
}

/* ============================================
   CONTAINER QUERIES - Narrow Layout (< 500px)
   ============================================ */

@container fitkpcs-widget (max-width: 500px) {
  /* Compact padding */
  .fitkpcs-widget {
    padding: 16px;
    border-radius: 12px;
  }

  /* Header - compact */
  .fitkpcs-title {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .fitkpcs-subtitle {
    font-size: 13px;
  }

  .fitkpcs-date-range {
    font-size: 12px;
  }

  /* Stats Grid - SINGLE COLUMN for narrow spaces */
  .fitkpcs-stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }

  .fitkpcs-stat {
    padding: 14px 12px;
  }

  .fitkpcs-stat-value {
    font-size: 24px;
  }

  .fitkpcs-stat-label {
    font-size: 11px;
  }

  /* Charity section - compact */
  .fitkpcs-charity {
    padding: 14px;
    margin-bottom: 16px;
  }

  .fitkpcs-section-title {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .fitkpcs-progress-bar {
    height: 24px;
    margin-bottom: 10px;
  }

  .fitkpcs-progress-fill {
    font-size: 11px;
  }

  .fitkpcs-progress-label {
    font-size: 14px;
  }

  .fitkpcs-charity-donors {
    font-size: 12px;
  }

  /* Leaderboard - compact */
  .fitkpcs-leaderboard {
    margin-bottom: 16px;
  }

  .fitkpcs-leaderboard-item {
    padding: 10px 12px;
  }

  .fitkpcs-rank {
    font-size: 15px;
    width: 28px;
  }

  .fitkpcs-name {
    font-size: 13px;
    margin: 0 8px;
  }

  .fitkpcs-points {
    font-size: 13px;
  }

  /* CTA button - full width */
  .fitkpcs-cta {
    margin: 16px 0;
  }

  .fitkpcs-cta-button {
    width: 100%;
    padding: 12px 20px;
    font-size: 15px;
  }

  /* Footer - compact */
  .fitkpcs-footer {
    padding-top: 14px;
    font-size: 12px;
  }

  .fitkpcs-updated {
    font-size: 11px;
  }
}

/* Extra narrow containers (< 350px) - Ultra compact */
@container fitkpcs-widget (max-width: 350px) {
  .fitkpcs-widget {
    padding: 12px;
  }

  .fitkpcs-title {
    font-size: 18px;
  }

  .fitkpcs-stat-value {
    font-size: 20px;
  }

  .fitkpcs-stat-label {
    font-size: 10px;
  }

  .fitkpcs-section-title {
    font-size: 14px;
  }

  /* Hide leaderboards in ultra-narrow mode to save space */
  .fitkpcs-leaderboard {
    display: none;
  }

  .fitkpcs-cta-button {
    font-size: 14px;
    padding: 10px 16px;
  }
}
