/* Modern Design System */
:root {
  /* Colors */
  --bg: #0a0f1c;
  --bg-secondary: #0f1629;
  --card: #1a2332;
  --card-hover: #1f2937;
  --surface: #111827;
  --border: #374151;
  --border-light: #4b5563;
  
  /* Text */
  --text: #f9fafb;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  
  /* Brand */
  --primary: #06b6d4;
  --primary-light: #67e8f9;
  --secondary: #3b82f6;
  --accent: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Border radius */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: 
    linear-gradient(135deg, rgba(10, 15, 28, 0.45) 0%, rgba(15, 22, 41, 0.55) 100%),
    url('fundo.jpg') center center / cover no-repeat;
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mobile background fix - better performance */
@media (max-width: 768px) {
  body {
    background-attachment: scroll; /* Better performance on mobile */
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
  }
  
  /* Simplified background for mobile performance */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
      linear-gradient(135deg, rgba(10, 15, 28, 0.6) 0%, rgba(15, 22, 41, 0.7) 100%),
      url('fundo.jpg') center center / cover no-repeat;
    z-index: -1;
    will-change: transform;
  }
}

/* Layout */
.site-header {
  padding: var(--space-xl) var(--space-md) var(--space-lg);
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.site-header h1 {
  margin: 0 0 var(--space-sm);
  font-weight: 800;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md) var(--space-2xl);
}

/* Stats Dashboard */
.stats-dashboard {
  margin-bottom: var(--space-xl);
}

.swimmer-level {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.6) 0%, rgba(59, 130, 246, 0.6) 100%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  color: white;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.swimmer-level::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1));
  transform: skewX(-15deg);
}

.level-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
}

.level-badge {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.level-progress {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: 1;
  max-width: 300px;
}

.level-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.level-fill {
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.level-text {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 60px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
}

.stat-card {
  background: rgba(26, 35, 50, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  border: 1px solid rgba(55, 65, 81, 0.5);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-light);
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Badges Section */
.badges-section {
  background: rgba(26, 35, 50, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  border: 1px solid rgba(55, 65, 81, 0.5);
}

.badges-section h3 {
  margin: 0 0 var(--space-lg);
  color: var(--text);
  font-size: 1.1rem;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-md);
}

.badge-item {
  background: rgba(17, 24, 39, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border-radius: var(--radius);
  padding: var(--space-md);
  text-align: center;
  border: 1px solid rgba(75, 85, 99, 0.4);
  transition: all 0.3s ease;
  animation: badgeUnlock 0.5s ease-out;
}

.badge-item:hover {
  transform: scale(1.05);
}

.badge-icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
}

.badge-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.badge-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Skeleton Loading */
.skeleton-grid {
  display: grid;
}

.skeleton-card {
  background: linear-gradient(90deg, rgba(26, 35, 50, 0.4) 25%, rgba(55, 65, 81, 0.2) 50%, rgba(26, 35, 50, 0.4) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-lg);
  min-height: 100px;
  border: 1px solid rgba(55, 65, 81, 0.2);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes badgeUnlock {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
  }
  50% {
    transform: scale(1.1) rotate(5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  gap: var(--space-md);
}

.comparison-badge {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.comparison-badge.negative {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Touch and Swipe Optimizations */
.weeks-grid {
  touch-action: pan-y;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.week-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(6, 182, 212, 0.2);
  -webkit-touch-callout: none;
  cursor: pointer;
}

/* Smooth scrolling for mobile */
* {
  -webkit-overflow-scrolling: touch;
}

/* Prevent text selection on interactive elements */
.week-card,
.ctrl-btn,
.btn-save-registo,
.btn-close,
.stat-card {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Hardware acceleration for animations */
.week-card,
.stat-card,
.workout,
.badge-item {
  will-change: transform;
  transform: translateZ(0);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Intro Card */
.intro-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  background: rgba(26, 35, 50, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  border: 1px solid rgba(55, 65, 81, 0.5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  margin-bottom: var(--space-xl);
}

.intro-card h2 {
  margin: 0 0 var(--space-md);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-light);
}

.intro-card ul {
  margin: 0;
  padding-left: var(--space-lg);
  color: var(--text-secondary);
}

.intro-card li {
  margin-bottom: var(--space-sm);
}

.intro-tips {
  background: rgba(17, 24, 39, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid rgba(75, 85, 99, 0.4);
}

.intro-tips h3 {
  margin: 0 0 var(--space-md);
  font-size: 1.1rem;
  color: var(--accent);
}

/* Weeks Section */
.weeks-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin: var(--space-xl) 0 var(--space-lg);
  gap: var(--space-md);
  flex-wrap: wrap;
}

.weeks-header div:first-child h2 {
  margin: 0 0 var(--space-xs);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.weeks-header div:first-child p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.pill {
  padding: var(--space-xs) var(--space-sm);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pill-easy {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pill-base {
  background: rgba(59, 130, 246, 0.1);
  color: var(--secondary);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.pill-challenge {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Week Cards Grid */
.weeks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-lg);
  margin: var(--space-lg) 0;
}

.week-card {
  background: rgba(26, 35, 50, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(55, 65, 81, 0.5);
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.week-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.week-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
  border-color: rgba(75, 85, 99, 0.7);
  background: rgba(31, 41, 55, 0.5);
}

.week-card:hover::before {
  opacity: 1;
}

.week-card.current-week {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-lg);
  background: linear-gradient(135deg, var(--card) 0%, rgba(6, 182, 212, 0.05) 100%);
}

.week-card.current-week::before {
  opacity: 1;
}

/* Progress Indicator */
.progress-indicator {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--success);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9999px;
  min-width: 24px;
  text-align: center;
}

.week-title {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* Week Content */
.week-title h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 700;
}

.week-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: var(--space-sm);
  font-weight: 500;
}

/* Dialog */
.week-dialog {
  width: 95vw;
  max-width: 900px;
  border-radius: var(--radius-xl);
  background: rgba(15, 22, 41, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0;
  border: 1px solid rgba(55, 65, 81, 0.7);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.week-dialog::backdrop {
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid rgba(55, 65, 81, 0.6);
  background: rgba(26, 35, 50, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.dialog-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.btn-close {
  appearance: none;
  border: 0;
  background: rgba(17, 24, 39, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  background: var(--danger);
  color: white;
}

.dialog-content {
  padding: var(--space-xl);
  max-height: 70vh;
  overflow: auto;
}

/* Workout Cards - Redesigned */
.workout {
  background: rgba(26, 35, 50, 0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border-radius: var(--radius-xl);
  padding: 0;
  border: 1px solid rgba(55, 65, 81, 0.7);
  margin-bottom: var(--space-xl);
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.08);
}

.workout:hover {
  transform: translateY(-2px);
  border-color: rgba(75, 85, 99, 0.6);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.workout-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  padding: var(--space-lg) var(--space-xl);
  color: white;
  position: relative;
  overflow: hidden;
}

.workout-header::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1));
  transform: skewX(-15deg);
}

.workout-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.workout h4 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.workout-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.workout-meta {
  font-size: 0.9rem;
  opacity: 0.9;
  font-weight: 500;
  display: flex;
  gap: var(--space-lg);
  align-items: center;
}

.workout-content {
  padding: var(--space-xl);
}

.blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.block {
  background: rgba(17, 24, 39, 0.2);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(75, 85, 99, 0.5);
  transition: all 0.2s ease;
  position: relative;
}

.block:hover {
  background: rgba(17, 24, 39, 0.6);
  border-color: rgba(75, 85, 99, 0.4);
}

.block-title {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.block-title::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
}

.block pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.workout-footer {
  background: rgba(17, 24, 39, 0.1);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  padding: var(--space-xl);
  border-top: 1px solid rgba(75, 85, 99, 0.5);
}

.registo-section {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-lg);
  align-items: start;
}

.registo-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.registo-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.registo-inputs {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.workout-note {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius);
  padding: var(--space-md);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.workout-note::before {
  content: '💡';
  font-size: 1rem;
}

/* Registration Area - Redesigned */
input[type="number"],
input[type="date"] {
  font-size: 14px;
  padding: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid rgba(55, 65, 81, 0.5);
  background: rgba(17, 24, 39, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: var(--text);
  width: 130px;
  transition: all 0.2s ease;
  font-weight: 500;
}

input[type="number"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
  background: rgba(17, 24, 39, 0.6);
}

.btn-save-registo {
  appearance: none;
  border: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
  min-width: 120px;
}

.btn-save-registo:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

.btn-save-registo:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.registo-status {
  font-size: 0.85rem;
  font-weight: 600;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  transition: all 0.3s ease;
}

/* Evolution Cards */
.evolucao-section {
  margin-top: var(--space-2xl);
  background: rgba(26, 35, 50, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(55, 65, 81, 0.5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.evolucao-section h2 {
  margin: 0 0 var(--space-lg);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.chart-controls,
.data-controls {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

#evolucaoResumo .resumo-card {
  background: rgba(17, 24, 39, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 1px solid rgba(75, 85, 99, 0.4);
  border-radius: var(--radius);
  padding: var(--space-md);
  min-width: 100px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: all 0.2s ease;
}

@media (max-width: 768px) {
  #evolucaoResumo .resumo-card {
    min-width: auto;
    padding: var(--space-sm);
  }
}

#evolucaoResumo .resumo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

#evolucaoResumo .resumo-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

#evolucaoResumo .resumo-value {
  font-weight: 800;
  color: var(--primary-light);
  font-size: 1.25rem;
  margin-top: var(--space-xs);
}

/* Calendar */
.calendar-section {
  margin-top: var(--space-xl);
  background: rgba(26, 35, 50, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(55, 65, 81, 0.5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

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

.cal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

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

.cal-month-label {
  font-weight: 700;
  color: var(--primary-light);
  font-size: 1rem;
  min-width: 150px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-xs);
}

.cal-weekday {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
  padding: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-day {
  min-height: 48px;
  padding: var(--space-sm);
  border-radius: var(--radius);
  background: rgba(17, 24, 39, 0.25);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-weight: 600;
  border: 1px solid rgba(75, 85, 99, 0.3);
  transition: all 0.2s ease;
  cursor: default;
}

.cal-day:hover {
  background: rgba(31, 41, 55, 0.4);
}

.cal-day .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: var(--space-xs);
  opacity: 0;
  transition: all 0.2s ease;
}

.cal-day.trained {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.cal-day.trained .dot {
  background: rgba(255, 255, 255, 0.8);
  opacity: 1;
}

/* Controls */
.ctrl-btn {
  appearance: none;
  border: 1px solid rgba(55, 65, 81, 0.4);
  background: rgba(17, 24, 39, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.ctrl-btn:hover {
  background: rgba(31, 41, 55, 0.4);
  border-color: rgba(75, 85, 99, 0.6);
  color: var(--text);
}

.ctrl-btn.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.ctrl-btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.ctrl-btn.danger:hover {
  background: var(--danger);
  color: white;
}

.import-label {
  cursor: pointer;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Responsive Design */
@media (min-width: 640px) {
  body {
    font-size: 16px;
  }
  
  .intro-card {
    grid-template-columns: 1.2fr 0.8fr;
  }
  
  .weeks-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  
  .registo-row {
    flex-wrap: nowrap;
  }
  
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .level-info {
    flex-direction: row;
  }
}

@media (min-width: 769px) {
  body {
    background-attachment: fixed;
  }
  
  .layout {
    padding: 0 var(--space-xl) var(--space-2xl);
  }
  
  .weeks-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
  
  .blocks {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
  
  .registo-section {
    grid-template-columns: 1fr auto;
  }
  
  .registo-inputs {
    flex-wrap: nowrap;
  }
}

@media (min-width: 1024px) {
  .weeks-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  
  .controls-row {
    flex-wrap: nowrap;
  }
}

/* Mobile optimizations */
@media (max-width: 768px) {
  /* Improved viewport handling */
  html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
  }
  
  body {
    font-size: 16px; /* Prevent zoom on iOS */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  /* Allow text selection in content areas */
  .dialog-content,
  .intro-card,
  .workout-content {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
  }
  
  /* Layout improvements */
  .layout {
    padding: 0 var(--space-sm) var(--space-xl);
  }
  
  .site-header {
    padding: var(--space-lg) var(--space-sm);
  }
  
  /* Stats grid mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
  
  .stat-card {
    min-height: 90px;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  
  .stat-icon {
    font-size: 1.25rem;
    margin-bottom: var(--space-xs);
  }
  
  .stat-value {
    font-size: 1.25rem;
    line-height: 1;
  }
  
  .stat-label {
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.2;
  }
  
  /* Level progress mobile */
  .level-info {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }
  
  .level-progress {
    max-width: 100%;
  }
  
  /* Weeks grid mobile */
  .weeks-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-md);
  }
  
  .week-card {
    min-height: 100px;
    padding: var(--space-lg);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(6, 182, 212, 0.2);
  }
  
  /* Modal optimizations */
  .week-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    margin: 0;
    background: 
      linear-gradient(135deg, rgba(10, 15, 28, 0.65) 0%, rgba(15, 22, 41, 0.65) 100%),
      url('fundo.jpg') center center / cover no-repeat;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  
  .week-dialog::backdrop {
    background: rgba(0, 0, 0, 0.3);
  }
  
  .dialog-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(26, 35, 50, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 0;
    padding: var(--space-md);
    border-bottom: 1px solid rgba(55, 65, 81, 0.6);
  }
  
  .dialog-content {
    height: calc(100vh - 70px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: var(--space-md);
  }
  
  /* Prevent body scroll when modal is open */
  body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
  
  /* Touch targets - Apple HIG 44px minimum */
  .btn-save-registo {
    min-height: 48px;
    padding: var(--space-md) var(--space-lg);
    font-size: 16px;
    width: 100%;
    margin-top: var(--space-sm);
  }
  
  input[type="number"],
  input[type="date"] {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: var(--space-md);
    width: 100%;
  }
  
  .ctrl-btn {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    font-size: 14px;
    white-space: nowrap;
  }
  
  .btn-close {
    min-height: 44px;
    min-width: 44px;
    font-size: 18px;
  }
  
  /* Workout cards mobile */
  .workout {
    margin-bottom: var(--space-md);
  }
  
  .workout-header {
    padding: var(--space-md);
  }
  
  .workout-title {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }
  
  .workout-meta {
    flex-direction: column;
    gap: var(--space-xs);
    align-items: flex-start;
  }
  
  .workout-content {
    padding: var(--space-md);
  }
  
  .workout-footer {
    padding: var(--space-md);
  }
  
  .blocks {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }
  
  .block {
    padding: var(--space-md);
  }
  
  .registo-section {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }
  
  .registo-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    align-items: end;
  }
  
  .registo-inputs .btn-save-registo {
    grid-column: 1 / -1;
    margin-top: var(--space-sm);
  }
  
  /* Controls mobile */
  .controls-row {
    flex-direction: column;
    gap: var(--space-md);
    align-items: stretch;
  }
  
  .chart-controls,
  .data-controls {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  /* Calendar mobile */
  .cal-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
  }
  
  .cal-header h2 {
    font-size: 1rem;
    margin: 0;
  }
  
  .cal-controls {
    flex-shrink: 0;
  }
  
  .cal-month-label {
    min-width: 100px;
    font-size: 0.9rem;
  }
  
  .cal-day {
    min-height: 40px;
    font-size: 14px;
  }
  
  /* Intro card mobile */
  .intro-card {
    padding: var(--space-lg);
  }
  
  .intro-card h2 {
    font-size: 1.1rem;
  }
  
  .intro-tips h3 {
    font-size: 1rem;
  }
  
  /* Weeks header mobile */
  .weeks-header {
    flex-direction: column;
    gap: var(--space-sm);
    text-align: center;
  }
  
  .legend {
    justify-content: center;
  }
  
  /* Evolution section mobile */
  .evolucao-section,
  .calendar-section {
    padding: var(--space-lg);
    margin-top: var(--space-lg);
  }
  
  /* Badge grid mobile */
  .badges-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-sm);
  }
  
  .badge-item {
    padding: var(--space-sm);
  }
  
  .badge-icon {
    font-size: 1.5rem;
  }
  
  .badge-name {
    font-size: 0.75rem;
  }
  
  .badge-desc {
    font-size: 0.65rem;
  }
}

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

.week-card {
  animation: fadeIn 0.3s ease-out;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
  border-radius: var(--radius);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Mobile scrollbar - thinner */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
}

/* Safe area handling for notched devices */
@supports (padding: max(0px)) {
  .site-header {
    padding-top: max(var(--space-xl), env(safe-area-inset-top));
  }
  
  .layout {
    padding-left: max(var(--space-md), env(safe-area-inset-left));
    padding-right: max(var(--space-md), env(safe-area-inset-right));
  }
  
  .site-footer {
    padding-bottom: max(var(--space-xl), env(safe-area-inset-bottom));
  }
}

/* Focus styles for accessibility */
.week-card:focus,
.ctrl-btn:focus,
.btn-save-registo:focus,
.btn-close:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Loading states */
.loading {
  opacity: 0.7;
  pointer-events: none;
  cursor: not-allowed;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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