/* CSS Variables */
:root {
    /* Dark Theme Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #16161f;
    --bg-card-hover: #1e1e2a;
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-tertiary: #606070;
    
    /* Accent Colors */
    --accent-primary: #6c5ce7;
    --accent-secondary: #a29bfe;
    --accent-gradient: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    
    /* Muscle Colors */
    --muscle-inactive: #2a2a3a;
    --muscle-light: #4ade80;
    --muscle-medium: #facc15;
    --muscle-heavy: #f97316;
    --muscle-intense: #ef4444;
    
    /* Status Colors */
    --success: #4ade80;
    --warning: #facc15;
    --error: #ef4444;
    --info: #60a5fa;
    
    /* Stat Card Colors */
    --blue: #3b82f6;
    --green: #22c55e;
    --orange: #f97316;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --cyan: #06b6d4;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.3);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Layout */
    --header-height: 60px;
    --nav-height: 70px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* App Container */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--header-height);
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
    z-index: 100;
    border-bottom: 1px solid var(--bg-tertiary);
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.logo i {
    color: var(--accent-primary);
    font-size: 1.3rem;
}

.header-right {
    display: flex;
    gap: var(--space-sm);
}

.header-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ========================================
   SEARCH OVERLAY
   ======================================== */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 200;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-container {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    padding: var(--space-md);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    gap: var(--space-md);
    border: 2px solid var(--bg-tertiary);
}

.search-input-wrapper:focus-within {
    border-color: var(--accent-primary);
}

.search-input-wrapper i {
    color: var(--text-tertiary);
}

.search-input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text-primary);
}

.search-input-wrapper input::placeholder {
    color: var(--text-tertiary);
}

.close-search {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
}

.search-results {
    margin-top: var(--space-md);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    flex: 1;
    margin-top: var(--header-height);
    margin-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
    overflow: hidden;
}

.screen {
    display: none;
    height: 100%;
    overflow-y: auto;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen-content {
    padding: var(--space-md);
    padding-bottom: var(--space-xxl);
}

/* ========================================
   WELCOME CARD
   ======================================== */
.welcome-card {
    background: var(--accent-gradient);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-glow);
}

.welcome-text .greeting {
    font-size: 0.9rem;
    opacity: 0.9;
}

.welcome-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: var(--space-xs);
}

.welcome-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-icon i {
    font-size: 1.8rem;
    color: white;
}

/* ========================================
   STATS GRID
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: var(--transition-fast);
}

.stat-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.2);
    color: var(--blue);
}

.stat-icon.green {
    background: rgba(34, 197, 94, 0.2);
    color: var(--green);
}

.stat-icon.orange {
    background: rgba(249, 115, 22, 0.2);
    color: var(--orange);
}

.stat-icon.purple {
    background: rgba(139, 92, 246, 0.2);
    color: var(--purple);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ========================================
   START WORKOUT BUTTON
   ======================================== */
.start-workout-btn {
    width: 100%;
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-lg);
    color: var(--accent-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: var(--transition-normal);
    margin-bottom: var(--space-lg);
}

.start-workout-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-style: solid;
}

.start-workout-btn i {
    font-size: 1.2rem;
}

/* ========================================
   SECTION HEADER
   ======================================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.section-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.see-all-btn, .add-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    transition: var(--transition-fast);
}

.see-all-btn:hover, .add-btn:hover {
    opacity: 0.8;
}

.add-btn {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: var(--space-xxl) var(--space-lg);
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.empty-state span {
    font-size: 0.9rem;
}

.empty-state.small {
    padding: var(--space-lg);
}

.empty-state.small i {
    font-size: 2rem;
}

/* ========================================
   RECENT WORKOUTS
   ======================================== */
.recent-workouts {
    margin-bottom: var(--space-lg);
}

.workout-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.workout-card:hover {
    background: var(--bg-card-hover);
}

.workout-card-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.workout-card-info {
    flex: 1;
}

.workout-card-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.workout-card-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.workout-card-meta {
    text-align: right;
}

.workout-card-meta .date {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.workout-card-meta .duration {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========================================
   MUSCLE PREVIEW CARD
   ======================================== */
.muscle-preview-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.muscle-preview-card:hover {
    background: var(--bg-card-hover);
}

.muscle-mini-stats {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.muscle-stat {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.muscle-stat .muscle-name {
    width: 60px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.muscle-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.muscle-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

/* ========================================
   BOTTOM NAVIGATION
   ======================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--nav-height);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: var(--safe-area-bottom);
    border-top: 1px solid var(--bg-tertiary);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-sm) 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.nav-item i {
    font-size: 1.3rem;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
}

.nav-item.active {
    color: var(--accent-primary);
}

.nav-item:hover:not(.active) {
    color: var(--text-secondary);
}

/* ========================================
   FLOATING WORKOUT INDICATOR
   ======================================== */
.floating-workout {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--space-md) + var(--safe-area-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 448px;
    background: var(--accent-gradient);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 90;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.floating-info {
    display: flex;
    flex-direction: column;
}

.floating-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.floating-timer {
    font-size: 1.2rem;
    font-weight: 700;
}

.floating-expand {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.floating-expand:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   MODALS
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow: hidden;
    transform: translateY(100%);
    transition: var(--transition-normal);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: flex-end;
    padding: var(--space-md);
}

.modal-close {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 0 var(--space-lg) var(--space-xl);
    overflow-y: auto;
    max-height: calc(90vh - 60px);
}

/* Timer Modal */
.timer-modal .timer-content {
    width: 100%;
    max-width: 480px;
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-primary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%);
    transition: var(--transition-normal);
}

.timer-modal.active .timer-content {
    transform: translateY(0);
}

.timer-circle {
    position: relative;
    width: 200px;
    height: 200px;
    margin-bottom: var(--space-xl);
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
}

.timer-controls {
    display: flex;
    gap: var(--space-md);
}

.timer-btn {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.timer-btn:hover {
    background: var(--bg-card-hover);
}

.timer-btn.skip {
    background: var(--accent-primary);
}

.timer-btn.skip:hover {
    opacity: 0.9;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
    .app-container {
        max-width: 100%;
    }
    
    .app-header,
    .bottom-nav,
    .floating-workout {
        max-width: 100%;
    }
    
    .modal-content,
    .timer-modal .timer-content {
        max-width: 100%;
    }
}

@media (min-width: 481px) {
    body {
        background: #050508;
    }
    
    .app-container {
        box-shadow: 0 0 60px rgba(108, 92, 231, 0.1);
    }
}

/* ==========================================
   CREATE TEMPLATE BUTTON
   ========================================== */
.create-template-btn {
    width: 100%;
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-lg);
    color: var(--accent-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    transition: var(--transition-normal);
}

.create-template-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-style: solid;
}

.create-template-btn i {
    font-size: 1.2rem;
}

#pose-tracker-root canvas {
  max-width: 100% !important;
  height: auto !important;
}
/* ========================================
   AI POSE TRAINER SCREEN
   ======================================== */

.pose-screen-header {
    text-align: center;
    margin-bottom: var(--space-lg);
    padding-top: var(--space-sm);
}

.pose-screen-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pose-screen-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#pose-tracker-root {
    width: 100%;
}

#pose-tracker-root canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* Make bottom nav scrollable when 6 items on small screens */
.bottom-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.bottom-nav::-webkit-scrollbar {
    display: none;
}

.bottom-nav .nav-item {
    min-width: 60px;
    flex-shrink: 0;
}

/* AI Trainer Card on Dashboard */
.ai-trainer-card {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: linear-gradient(135deg, #1a1535 0%, #12122a 100%);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    margin-bottom: var(--space-lg);
    transition: var(--transition-fast);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.15);
    text-align: left;
}

.ai-trainer-card:hover, .ai-trainer-card:active {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(108, 92, 231, 0.3);
}

.ai-trainer-card-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.ai-trainer-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
    flex-shrink: 0;
}

.ai-trainer-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ai-trainer-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ai-trainer-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ai-trainer-badge {
    background: var(--accent-gradient);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    letter-spacing: 1px;
    flex-shrink: 0;
}
