/* CaliForm - Treino Científico 3x30 */
/* ================================= */

:root {
  --push: #FF6B6B;
  --pull: #4ECDC4;
  --legs: #FFE66D;
  --hiit: #FF8C42;
  --rest-color: #9B59B6;
  --bg-dark: #1A1A2E;
  --bg-card: #16213E;
  --bg-card-hover: #1a2a4e;
  --bg-surface: #0F3460;
  --text-primary: #FFFFFF;
  --text-secondary: #A0AEC0;
  --text-muted: #718096;
  --success: #48BB78;
  --danger: #FC8181;
  --rest-bg: #0d1b36;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* ============ HEADER ============ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-card) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--push), var(--pull));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.header-logo h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--push), var(--pull), var(--legs));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-logo .slogan {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  background: rgba(255,255,255,0.05);
  border: none;
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-btn:hover, .header-btn.active {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
}

/* ============ HOME / DASHBOARD ============ */
.home-container {
  padding: 0 20px 100px;
}

.greeting {
  padding: 20px 0 8px;
}

.greeting h2 {
  font-size: 26px;
  font-weight: 700;
}

.greeting p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* Schedule Cards */
.schedule-section {
  margin-top: 20px;
}

.schedule-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.schedule-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  position: relative;
}

.schedule-card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}

.schedule-card.today {
  border-color: var(--push);
  box-shadow: 0 0 20px rgba(255,107,107,0.2);
}

.schedule-card.today::after {
  content: '';
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--push);
}

.schedule-card .day-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.schedule-card .day-type {
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.schedule-card .day-duration {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* CTA Button */
.cta-section {
  margin-top: 24px;
}

.cta-button {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.cta-button.primary {
  background: linear-gradient(135deg, var(--push), #ff8e8e);
  color: white;
  box-shadow: 0 6px 30px rgba(255,107,107,0.4);
}

.cta-button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 40px rgba(255,107,107,0.5);
}

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

.cta-button .cta-icon {
  font-size: 20px;
}

.cta-button .cta-sub {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.8;
  display: block;
  margin-top: 2px;
}

/* Workout Day Cards */
.workout-cards {
  margin-top: 24px;
}

.workout-cards h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.workout-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 4px solid transparent;
}

.workout-card:hover {
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.workout-card .card-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.workout-card .card-info {
  flex: 1;
}

.workout-card .card-info h4 {
  font-size: 16px;
  font-weight: 700;
}

.workout-card .card-info p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.workout-card .card-info .card-meta {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

.workout-card .card-meta span {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.workout-card .card-arrow {
  color: var(--text-muted);
  font-size: 14px;
}

/* Stats */
.stats-section {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

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

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============ EXECUTION SCREEN ============ */
.execution-screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background 0.5s ease;
  overflow: hidden;
}

.execution-screen.resting {
  background: var(--rest-bg) !important;
}

/* Top Bar */
.exec-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  flex-shrink: 0;
}

.exec-topbar .back-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exec-topbar .workout-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.exec-topbar .progress-text {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Global Progress Bar */
.global-progress {
  height: 3px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.global-progress .bar {
  height: 100%;
  transition: width 0.5s ease;
  border-radius: 2px;
}

/* Focus Center */
.focus-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.exercise-name {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.2;
}

.muscle-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 20px;
  background: rgba(255,255,255,0.1);
}

/* SVG Timer */
.timer-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 8;
}

.timer-progress {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.0s linear;
}

.timer-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.timer-digits {
  font-size: 56px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  line-height: 1;
}

.timer-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
}

/* Round Indicator */
.round-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.round-dots {
  display: flex;
  gap: 6px;
}

.round-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: var(--transition);
}

.round-dot.completed {
  background: var(--success);
}

.round-dot.current {
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* Rest Screen */
.rest-info {
  text-align: center;
  margin-top: 16px;
}

.rest-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.next-preview {
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  margin-top: 12px;
  display: inline-block;
}

.next-preview .next-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.next-preview .next-name {
  font-size: 16px;
  font-weight: 700;
  margin-top: 2px;
}

/* Video Window */
.video-window {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 140px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  z-index: 10;
  background: #000;
}

.video-window.expanded {
  width: 90%;
  height: 200px;
  bottom: 100px;
  right: 5%;
}

.video-window iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.video-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 11;
}

/* Bottom Controls */
.exec-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}

.ctrl-btn {
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  color: white;
}

.ctrl-btn.small {
  width: 48px;
  height: 48px;
  font-size: 16px;
  background: rgba(255,255,255,0.1);
}

.ctrl-btn.main {
  width: 68px;
  height: 68px;
  font-size: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.ctrl-btn:hover {
  transform: scale(1.08);
}

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

/* Extra Time Button */
.extra-time-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-secondary);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.extra-time-btn:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

/* Warmup Screen */
.warmup-overlay {
  text-align: center;
}

.warmup-exercises {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.warmup-exercise {
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

.warmup-exercise.active {
  background: rgba(255,255,255,0.1);
  border-left: 3px solid var(--success);
}

.warmup-exercise.done {
  opacity: 0.4;
  text-decoration: line-through;
}

/* ============ LIBRARY SCREEN ============ */
.library-container {
  padding: 0 20px 100px;
}

.library-header {
  padding: 20px 0;
}

.library-header h2 {
  font-size: 24px;
  font-weight: 700;
}

.library-filters {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.filter-btn {
  background: var(--bg-card);
  border: none;
  color: var(--text-secondary);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.filter-btn.active {
  color: white;
}

.exercise-list {
  margin-top: 16px;
}

.exercise-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
  transition: var(--transition);
}

.exercise-item-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  cursor: pointer;
}

.exercise-item-header .ex-color {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}

.exercise-item-header .ex-info {
  flex: 1;
}

.exercise-item-header .ex-info h4 {
  font-size: 15px;
  font-weight: 600;
}

.exercise-item-header .ex-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.exercise-item-header .ex-toggle {
  color: var(--text-muted);
  font-size: 12px;
  transition: var(--transition);
}

.exercise-item.expanded .ex-toggle {
  transform: rotate(180deg);
}

.exercise-detail {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.exercise-item.expanded .exercise-detail {
  display: block;
}

.exercise-detail .detail-video {
  width: 100%;
  height: 180px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
  background: #000;
}

.exercise-detail .detail-video iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.exercise-detail .detail-instructions {
  list-style: none;
}

.exercise-detail .detail-instructions li {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.exercise-detail .detail-instructions li::before {
  content: '→';
  color: var(--success);
  font-weight: 700;
  flex-shrink: 0;
}

/* ============ COMPLETION SCREEN ============ */
.completion-screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  background: var(--bg-dark);
}

.completion-icon {
  font-size: 80px;
  margin-bottom: 24px;
  animation: bounce 1s ease infinite;
}

.completion-screen h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.completion-screen p {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.5;
  max-width: 300px;
}

.completion-stats {
  display: flex;
  gap: 24px;
  margin-top: 32px;
}

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

.completion-stat .val {
  font-size: 32px;
  font-weight: 800;
}

.completion-stat .lbl {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.completion-screen .cta-button {
  margin-top: 40px;
  max-width: 300px;
}

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(22, 33, 62, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 200;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.5px;
}

.nav-item i {
  font-size: 20px;
  transition: var(--transition);
}

.nav-item.active {
  color: var(--push);
}

.nav-item.active i {
  transform: scale(1.1);
}

/* ============ ANIMATIONS ============ */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-slide-up {
  animation: slideUp 0.4s ease;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease;
}

.timer-pulse {
  animation: pulse 0.5s ease;
}

/* ============ RESPONSIVE ============ */
@media (min-width: 768px) {
  #app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid rgba(255,255,255,0.05);
    border-right: 1px solid rgba(255,255,255,0.05);
  }
  
  .bottom-nav {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Scrollbar */
#app::-webkit-scrollbar {
  width: 0;
}

/* Safe areas */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: max(16px, env(safe-area-inset-top));
  }
}
