/* =============================================================================
   THE UNPERFECT BODY - Design System
   Dark Mode Native | Scientific Bodybuilding
   ============================================================================= */

/* =============================================================================
   ROOT VARIABLES
   ============================================================================= */
:root {
  /* Primary Colors */
  --primary: #E31C25;
  --primary-hover: #FF2A35;
  --primary-rgb: 227, 28, 37;  /* same as --primary, for rgba() */
  --on-primary: #FFFFFF;       /* text on primary backgrounds, switched to black for light brand colors */
  --pure-black: #000000;
  --carbon: #121212;

  /* Surface & UI */
  --surface-grey: #1E1E1E;
  --surface-elevated: #2C2C2E;
  --border-grey: #333333;
  --success-green: #4CAF50;
  --warning-orange: #FF9800;
  --error-red: #F44336;

  /* Typography */
  --text-high: #FFFFFF;
  --text-medium: #B0B0B0;
  --text-disabled: #666666;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Shadows */
  --shadow-card: 0px 4px 10px rgba(0, 0, 0, 0.5);
}

/* =============================================================================
   RESET & BASE
   ============================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--pure-black);
  color: var(--text-high);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* =============================================================================
   TYPOGRAPHY
   ============================================================================= */
.font-heading {
  font-family: 'Montserrat', 'Inter', sans-serif;
}

h1,
.h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

h2,
.h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

h3,
.h3 {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

.text-data {
  font-family: 'Inter', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.text-body {
  font-size: 0.875rem;
  color: var(--text-medium);
}

.text-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-medium);
}

.text-muted {
  color: var(--text-medium);
}

.text-disabled {
  color: var(--text-disabled);
}

/* =============================================================================
   LAYOUT
   ============================================================================= */
.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.screen {
  min-height: 100vh;
  padding-top: var(--space-lg);
  padding-bottom: 100px;
  /* Space for bottom nav */
}

.section {
  margin-bottom: var(--space-xl);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-1 {
  flex: 1 1 0;
  min-width: 0;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-xs {
  gap: var(--space-xs);
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

/* =============================================================================
   HEADER
   ============================================================================= */
.header {
  background-color: var(--carbon);
  padding: var(--space-md);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-grey);
}

.header-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-title span {
  color: var(--primary);
}

/* =============================================================================
   BUTTONS
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  min-height: 48px;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background-color: rgba(var(--primary-rgb), 0.1);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-high);
}

.btn-ghost:hover {
  background-color: var(--surface-grey);
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-lg {
  min-height: 56px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* =============================================================================
   CARDS
   ============================================================================= */
.card {
  background-color: var(--surface-grey);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: transform var(--transition-base);
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-md);
}

.card-title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1rem;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-medium);
  margin-top: var(--space-xs);
}

/* Exercise Card */
.exercise-card {
  border-left: 3px solid var(--primary);
}

.exercise-card.tier-fondamentale {
  border-left-color: var(--primary);
}

.exercise-card.tier-complementare {
  border-left-color: #FFC107;
}

.exercise-card.tier-isolamento {
  border-left-color: var(--success-green);
}

.exercise-meta {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-sm);
}

.exercise-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* =============================================================================
   INPUT FIELDS
   ============================================================================= */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.input-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-medium);
}

.input {
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-grey);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: 'Inter', sans-serif;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-high);
  width: 100%;
  transition: border-color var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
}

.input::placeholder {
  color: var(--text-disabled);
}

.input-number {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Number Input with +/- buttons */
.number-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.number-input-wrapper .input {
  flex: 1;
}

.number-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-grey);
  border-radius: var(--radius-md);
  color: var(--text-high);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.number-btn:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* =============================================================================
   TIMER
   ============================================================================= */
.timer-display {
  font-family: 'Inter', sans-serif;
  font-size: 4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: 2px;
}

.timer-display.active {
  color: var(--primary);
}

.timer-display.complete {
  color: var(--success-green);
}

.timer-label {
  text-align: center;
  color: var(--text-medium);
  margin-top: var(--space-sm);
}

.timer-controls {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

/* =============================================================================
   PROGRESS INDICATORS
   ============================================================================= */
.progress-ring {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--surface-grey);
  stroke-width: 8;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-base);
}

.progress-bar {
  height: 4px;
  background-color: var(--surface-grey);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

/* =============================================================================
   PHASE SELECTOR
   ============================================================================= */
.phase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

.phase-card {
  background-color: var(--surface-grey);
  border: 2px solid var(--border-grey);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
}

.phase-card:hover {
  border-color: var(--primary);
}

.phase-card.active {
  border-color: var(--primary);
  background-color: rgba(var(--primary-rgb), 0.1);
}

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

.phase-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
}

/* =============================================================================
   BOTTOM NAVIGATION
   ============================================================================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--carbon);
  border-top: 1px solid var(--border-grey);
  display: flex;
  justify-content: space-around;
  padding: var(--space-sm) 0;
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-medium);
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: color var(--transition-fast);
  padding: var(--space-xs) var(--space-md);
}

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

.nav-icon {
  font-size: 1.5rem;
}

/* =============================================================================
   BADGES & TAGS
   ============================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-sm);
  background-color: var(--surface-elevated);
  color: var(--text-medium);
}

.badge-red {
  background-color: var(--primary);
  color: var(--on-primary);
}

.badge-green {
  background-color: var(--success-green);
  color: var(--text-high);
}

.badge-yellow {
  background-color: #FFC107;
  color: var(--pure-black);
}

/* Tier Badges */
.tier-badge {
  font-size: 0.625rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.tier-badge.fondamentale {
  background-color: var(--primary);
  color: var(--on-primary);
}

.tier-badge.complementare {
  background-color: #FFC107;
  color: var(--pure-black);
}

.tier-badge.isolamento {
  background-color: var(--success-green);
}

/* =============================================================================
   LISTS
   ============================================================================= */
.list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background-color: var(--surface-grey);
  border-radius: var(--radius-md);
}

.list-item-content {
  flex: 1;
}

.list-item-title {
  font-weight: 600;
}

.list-item-subtitle {
  font-size: 0.875rem;
  color: var(--text-medium);
}

/* =============================================================================
   LOGBOOK / SET ROWS
   ============================================================================= */
.set-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 1fr;
  gap: var(--space-xs);
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-grey);
}

.set-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface-elevated);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.875rem;
}

.set-number.complete {
  background-color: var(--success-green);
}

.set-input {
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-grey);
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-high);
  width: 100%;
}

.set-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

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

.animate-shake {
  animation: shake 0.3s ease-in-out;
}

/* =============================================================================
   UTILITIES
   ============================================================================= */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mt-xs {
  margin-top: var(--space-xs);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.mb-xs {
  margin-bottom: var(--space-xs);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.mb-xl {
  margin-bottom: var(--space-xl);
}

.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (min-width: 768px) {
  .container {
    max-width: 600px;
  }

  h1,
  .h1 {
    font-size: 2rem;
  }

  .timer-display {
    font-size: 5rem;
  }
}

/* Mobile Small (< 400px) */
@media (max-width: 400px) {
  .input-number {
    font-size: 1.125rem;
    padding: var(--space-sm);
  }

  .flex.gap-md {
    gap: var(--space-sm);
  }

  .input-group.flex-1 {
    min-width: 0;
  }

  #stats-section .text-data {
    font-size: 1.375rem;
  }

  #stats-section .card {
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  .input-label {
    font-size: 0.625rem;
  }
}

/* =============================================================================
   LOGIN / AUTH SCREENS
   ============================================================================= */
.auth-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-xl);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.auth-logo h1 {
  font-size: 1.5rem;
}

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

.auth-footer {
  text-align: center;
  margin-top: var(--space-xl);
}

/* =============================================================================
   PROGRESS / STATS SCREEN
   ============================================================================= */
.stat-card {
  background-color: var(--surface-grey);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-medium);
  text-transform: uppercase;
  margin-top: var(--space-xs);
}

.progress-history {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--surface-grey);
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.history-date {
  font-size: 0.875rem;
  color: var(--text-medium);
}

.history-stats {
  display: flex;
  gap: var(--space-md);
  font-size: 0.875rem;
}

/* =============================================================================
   LOGBOOK / RECOVERY TRACKING
   ============================================================================= */
.recovery-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background-color: var(--surface-grey);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}

.recovery-icon {
  font-size: 1.5rem;
  width: 48px;
  text-align: center;
}

.recovery-content {
  flex: 1;
}

.recovery-label {
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

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

.recovery-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 8px;
  background: var(--surface-elevated);
  border-radius: var(--radius-full);
  outline: none;
}

.recovery-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
}

.recovery-value {
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}

/* Rating dots */
.rating-dots {
  display: flex;
  gap: var(--space-xs);
}

.rating-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--surface-elevated);
  border: 2px solid var(--border-grey);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.rating-dot:hover,
.rating-dot.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* =============================================================================
   SCREEN VISIBILITY
   ============================================================================= */
.screen-section {
  display: none;
}

.screen-section.active {
  display: block;
}

/* Utility classes */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.w-full {
  width: 100%;
}
/* =============================================================================
   WHITE-LABEL (TENANT) BRANDING
   ============================================================================= */
.brand-lockup {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.brand-logo {
  height: 32px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
}

.brand-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 1rem;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-logo .brand-lockup {
  flex-direction: column;
}

.auth-logo .brand-logo {
  height: 72px;
  max-width: 200px;
}

.auth-logo .brand-name {
  font-size: 1.5rem;
  white-space: normal;
  text-align: center;
}

.tenant-welcome {
  border-left: 3px solid var(--primary);
}

.powered-by {
  font-size: 0.7rem;
  color: var(--text-disabled);
}

/* Exercise preview: keep "4x6-10" on one line */
.exercise-card .text-right .text-data {
  font-size: 1.25rem;
  white-space: nowrap;
}

/* =============================================================================
   WORKOUT: BREATHING CUE + FIXED NOTES BAR
   ============================================================================= */
.exercise-breathing {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Notes stay visible at the bottom while scrolling the exercise */
.exercise-notes {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  padding: var(--space-sm) 16px;
  background: var(--surface-elevated);
  border-top: 1px solid var(--border-grey);
  display: none;
}

#workout-screen:not(.hidden) ~ .exercise-notes {
  display: block;
}

#workout-screen:not(.hidden) {
  padding-bottom: 150px;
}

.exercise-notes textarea {
  resize: none;
  font-size: 0.875rem;
}
