/* Import premium modern fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* CSS Variables for design system */
:root {
  --bg-primary: #090d16;
  --bg-secondary: #121826;
  --bg-card: rgba(22, 30, 49, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(59, 130, 246, 0.5);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-blue: #3b82f6;
  --accent-blue-rgb: 59, 130, 246;
  --accent-green: #10b981;
  --accent-green-rgb: 16, 185, 129;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.4);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

/* Reset and basic setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  padding-bottom: 180px; /* Space for the floating timer */
  overflow-x: hidden;
}

/* Container */
.app-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 16px;
  margin: -16px -16px 16px -16px;
  border-bottom: 1px solid var(--border-color);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

h1 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 30%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.15);
}

/* Progress bar container */
.progress-container {
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 8px;
  border: 1px solid var(--border-color);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
}

.progress-track {
  background: rgba(255, 255, 255, 0.05);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, var(--accent-blue) 0%, var(--accent-green) 100%);
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Horizontal Day Selector Menu */
.day-selector-container {
  overflow-x: auto;
  scrollbar-width: none; /* Hide scrollbar for Firefox */
  margin: 0 -16px 12px -16px;
  padding: 4px 16px;
}

.day-selector-container::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari */
}

.day-selector {
  display: flex;
  gap: 8px;
  width: max-content;
}

.day-tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 16px;
  border-radius: 12px;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.day-tab:active {
  transform: scale(0.95);
}

.day-tab.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.15);
}

.day-tab.completed {
  border-color: var(--accent-green);
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.05);
}

/* Section Title */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 12px 0;
}

.section-header h2 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--accent-blue);
  border-radius: 2px;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.clear-btn:active {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.05);
}

/* Cards (Exercise & Stretch) */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  transition: background-color 0.3s ease;
}

.card.completed-card {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(12, 20, 35, 0.85);
}

.card.completed-card::before {
  background: var(--accent-green);
}

.card-title {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  padding-right: 24px;
  line-height: 1.3;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.meta-badge {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-badge.rest-badge {
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.2);
}

/* Technique block (Safety Note) */
.safety-note {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #fda4af;
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  line-height: 1.4;
}

.safety-note span {
  flex-shrink: 0;
  font-size: 0.9rem;
}

/* Sets/Series Tracker */
.sets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.set-check {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.checkbox-visual {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.set-check input {
  display: none; /* Hide standard input */
}

/* Checked styling */
.set-check input:checked + .checkbox-visual {
  background: linear-gradient(135deg, var(--accent-green) 0%, #064e3b 100%);
  border-color: var(--accent-green);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.set-check:active .checkbox-visual {
  transform: scale(0.9);
}

.set-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.set-check input:checked ~ .set-label {
  color: var(--accent-green);
}

/* Stretch card specifics */
.stretch-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.stretch-info {
  flex-grow: 1;
}

.stretch-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.stretch-duration {
  font-size: 0.75rem;
  color: var(--accent-blue);
  font-weight: 600;
}

.stretch-btn {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--accent-blue);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.stretch-btn:active {
  transform: scale(0.9);
  background: var(--accent-blue);
  color: white;
}

.stretch-card.completed-stretch {
  border-color: rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.02);
}

.stretch-card.completed-stretch .stretch-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.stretch-card.completed-stretch .stretch-btn {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
  color: var(--accent-green);
}

/* Descanso / Rest Day Card */
.rest-day-card {
  text-align: center;
  padding: 40px 24px;
  border-style: dashed;
  border-width: 2px;
}

.rest-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0px); }
}

.rest-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Floating Footer Rest Timer */
.timer-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: rgba(18, 24, 38, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: 12px 16px 20px 16px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.timer-footer.collapsed {
  transform: translateY(80px); /* Just show header/timer */
}

.timer-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timer-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-icon-wrapper {
  background: rgba(59, 130, 246, 0.1);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--accent-blue);
  cursor: pointer;
  transition: all 0.2s;
}

.timer-icon-wrapper.running {
  animation: pulse-timer 1.5s infinite;
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
}

@keyframes pulse-timer {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.timer-digits-container {
  display: flex;
  flex-direction: column;
}

.timer-current-exercise {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer-digits {
  font-family: var(--font-title);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
}

.timer-digits-ms {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-left: 2px;
}

/* Alert Flashing States */
.timer-finished-alert {
  animation: flash-bg 0.5s infinite alternate;
}

@keyframes flash-bg {
  0% { background-color: rgba(18, 24, 38, 0.95); }
  100% { background-color: rgba(239, 68, 68, 0.4); }
}

.timer-controls {
  display: flex;
  gap: 8px;
}

.timer-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}

.timer-btn:active {
  transform: scale(0.9);
}

.timer-btn.btn-play {
  background: var(--accent-blue);
  color: white;
  border: none;
}

.timer-btn.btn-pause {
  background: var(--accent-yellow);
  color: white;
  border: none;
}

.timer-btn.btn-reset {
  color: var(--text-secondary);
}

/* Quick Start Presets Slider */
.timer-presets {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.timer-presets::-webkit-scrollbar {
  display: none;
}

.preset-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 20px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-chip:active {
  transform: scale(0.95);
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent-blue);
}

.preset-chip.preset-suggested {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-blue);
}

/* Settings Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-control {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.modal-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
  margin-bottom: 10px;
}

.btn-primary:active {
  background: #2563eb;
  transform: scale(0.98);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

.btn-danger:active {
  background: var(--accent-red);
  color: white;
  transform: scale(0.98);
}

/* Sync status badge */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 20px;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.sync-dot.synced {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  animation: breathe 2s infinite alternate;
}

@keyframes breathe {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Sound Test Row */
.sound-test-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.sound-test-row span {
  font-size: 0.8rem;
  font-weight: 500;
}

.sound-test-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--accent-blue);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.sound-test-btn:active {
  background: var(--accent-blue);
  color: white;
}

/* Webhook Simulation Log */
.simulation-log {
  background: #000;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: monospace;
  font-size: 0.7rem;
  color: #10b981;
  max-height: 120px;
  overflow-y: auto;
  margin-top: 12px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
