/* AI Workout Planner Frontend Styles */
/* 
 * For optimal mobile experience, ensure viewport meta tag is set:
 * <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
 */

/* Reset and Base Styles */
#workout-app-container * {
    box-sizing: border-box;
}

#workout-app-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    overflow: hidden;
    /* Safe area support for notched devices */
    padding-top: env(safe-area-inset-top, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

/* Loading Screen */
.workout-app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-spinner.large {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main App Layout */
.workout-app-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background: #f8f9fa;
}

.workout-app-header {
    background: white;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.app-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.user-info {
    font-size: 0.9rem;
    color: #666;
}

.workout-app-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 100px; /* Space for bottom nav: icon(24px) + padding(24px) + label(20px) + border(1px) + extra(31px) */
    position: relative;
}

/* View System */
.workout-view {
    display: none;
    padding: 20px;
    min-height: calc(100vh - 140px);
    /* Modern mobile viewport units for better mobile support */
    min-height: calc(100dvh - 140px);
}

.workout-view.active {
    display: block;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-large {
    padding: 18px 36px;
    font-size: 1.2rem;
    min-width: 250px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
    min-height: 36px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-back {
    background: transparent;
    border: none;
    color: #667eea;
    font-size: 1rem;
    cursor: pointer;
    padding: 8px;
    margin-bottom: 10px;
}

/* Main View */
.main-view-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 60vh;
}

.workout-status h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #333;
}

.status-text {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 40px;
    max-width: 400px;
}

/* Creation View */
.creation-header {
    margin-bottom: 30px;
}

.creation-header h2 {
    margin: 10px 0 0 0;
    color: #333;
}

.creation-form {
    max-width: 500px;
    margin: 0 auto;
}

.question-section {
    margin-bottom: 40px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.question-section.active {
    opacity: 1;
}

.question-section h3 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.option-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.btn-option {
    background: white;
    color: #333;
    border: 2px solid #e9ecef;
    padding: 15px 20px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-option:hover {
    border-color: #667eea;
    color: #667eea;
}

.btn-option.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.generate-section {
    margin-top: 40px;
    text-align: center;
}

/* Generating View */
.generating-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 60vh;
    color: #333;
}

.generating-content h2 {
    margin: 20px 0 10px 0;
}

.generating-content p {
    color: #666;
    max-width: 400px;
}

/* Review View */
.review-header {
    margin-bottom: 30px;
}

.review-header h2 {
    margin: 10px 0 0 0;
    color: #333;
}

.workout-summary {
    margin-bottom: 40px;
}

.summary-card {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.summary-card h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.5rem;
}

.workout-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.detail-item .label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.detail-item span:not(.label) {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.workout-notes {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

.workout-notes p {
    margin: 0;
    color: #666;
    line-height: 1.5;
}

.review-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

/* Exercise Details Section */
.exercise-details {
    margin-bottom: 30px;
}

.exercise-details-toggle {
    width: 100%;
    background: white;
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 15px;
    color: #667eea;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.exercise-details-toggle:hover {
    background: #f8f9ff;
    transform: translateY(-2px);
}

.exercise-details-toggle span {
    display: flex;
    align-items: center;
    justify-content: center;
}

.exercise-list {
    display: none;
}

.exercise-item {
    background: white;
    border-radius: 12px;
    margin-bottom: 15px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #667eea;
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.exercise-header h4 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
}

.set-count {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.exercise-sets {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.set-detail {
    background: #f8f9ff;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #555;
    border-left: 3px solid #667eea;
}

/* Active Workout View */
.workout-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.workout-progress {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.exercise-card {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    text-align: center;
}

.exercise-card h2 {
    margin: 0 0 30px 0;
    color: #333;
    font-size: 1.8rem;
}

.set-tracker {
    max-width: 400px;
    margin: 0 auto;
}

.set-info {
    margin-bottom: 30px;
}

.set-info h3 {
    margin: 0 0 10px 0;
    font-size: 1.3rem;
    color: #333;
}

.set-target {
    font-size: 1.1rem;
    color: #666;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
}

.set-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.input-group label {
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
}

.input-group input {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1.1rem;
    text-align: center;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.set-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Rest Timer */
.rest-timer {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    border-radius: 16px;
    margin: 30px 0;
    color: #333;
}

.rest-timer h3 {
    margin: 0 0 20px 0;
    color: #333;
}

.timer-display {
    font-size: 3rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    margin-bottom: 20px;
    color: #333;
}

/* Workout Navigation */
.workout-navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

/* Complete View */
.complete-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 60vh;
    justify-content: center;
}

/* Settings View */
.settings-header {
    margin-bottom: 30px;
    text-align: center;
}

.settings-header h2 {
    margin: 0 0 10px 0;
    color: #333;
}

.settings-header p {
    color: #666;
    margin: 0;
}

.settings-content {
    max-width: 600px;
    margin: 0 auto;
}

.settings-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.settings-loading p {
    color: #666;
    margin-top: 15px;
}

.settings-form {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.form-header {
    margin-bottom: 30px;
    text-align: center;
}

.form-header h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.form-description {
    color: #666;
    font-size: 0.95rem;
    margin: 0;
}

.exercise-inputs {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

.exercise-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exercise-input-group label {
    font-weight: 500;
    color: #333;
    font-size: 0.95rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.exercise-input {
    flex: 1;
    padding: 12px 50px 12px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: white;
}

.exercise-input:focus {
    outline: none;
    border-color: #667eea;
}

.exercise-input:invalid {
    border-color: #dc3545;
}

.input-unit {
    position: absolute;
    right: 15px;
    color: #666;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.settings-messages {
    margin: 20px 0;
}

.settings-messages .notice {
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
}

.notice-success {
    background: #d1f2eb;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.notice-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.settings-help {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
    border-left: 4px solid #667eea;
}

.settings-help h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.2rem;
}

.settings-help h4 {
    margin: 20px 0 10px 0;
    color: #333;
    font-size: 1rem;
}

.settings-help p {
    color: #666;
    line-height: 1.5;
    margin: 0 0 15px 0;
}

.settings-help ul {
    color: #666;
    line-height: 1.5;
    margin: 0;
    padding-left: 20px;
}

.settings-help li {
    margin-bottom: 8px;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.complete-content h2 {
    margin: 0 0 15px 0;
    color: #333;
}

.complete-content p {
    color: #666;
    max-width: 400px;
    margin-bottom: 40px;
}

.workout-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
    width: 100%;
    max-width: 400px;
}

.stat-item {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
}

/* Bottom Navigation */
.workout-app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    border-top: 1px solid #e9ecef;
    z-index: 100;
    /* Better support for mobile browsers */
    bottom: env(safe-area-inset-bottom, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    transition: color 0.3s ease;
    text-decoration: none;
}

.nav-item:hover {
    color: #667eea;
}

.nav-item.active {
    color: #667eea;
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Login Required */
.workout-app-login-required {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    margin: 50px auto;
}

.workout-app-login-required h3 {
    margin: 0 0 15px 0;
    color: #333;
}

.workout-app-login-required p {
    color: #666;
    margin-bottom: 25px;
}

.workout-app-login-required .button {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .workout-app-content {
        padding: 15px;
        padding-bottom: 100px;
        /* Firefox mobile specific fixes */
        padding-bottom: max(100px, env(safe-area-inset-bottom, 100px));
    }
    
    .btn-large {
        min-width: 200px;
        padding: 16px 28px;
    }
    
    .workout-details {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .set-inputs {
        grid-template-columns: 1fr;
    }
    
    .workout-stats {
        grid-template-columns: 1fr;
    }
    
    .review-actions {
        gap: 12px;
    }
    
    .set-actions {
        flex-direction: column;
    }
    
    .workout-navigation {
        flex-direction: column;
    }
    
    /* Settings responsive */
    .settings-form {
        padding: 20px;
    }
    
    .settings-help {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .workout-app-content {
        padding-bottom: 120px; /* Extra space for smaller screens */
    }
    
    .workout-app-header {
        padding: 12px 15px;
    }
    
    .app-title {
        font-size: 1.3rem;
    }
    
    .option-buttons {
        grid-template-columns: 1fr;
    }
    
    .timer-display {
        font-size: 2.5rem;
    }
    
    .exercise-card {
        padding: 20px;
    }
    
    .summary-card {
        padding: 20px;
    }
    
    .exercise-details-toggle {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
    
    .exercise-item {
        padding: 15px;
        margin-bottom: 12px;
    }
    
    .exercise-header h4 {
        font-size: 1rem;
    }
    
    .set-count {
        font-size: 0.8rem;
        padding: 3px 10px;
    }
    
    .set-detail {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

/* Statistics View Styles */
:root {
    --muscle-default-color: #9ca3af;
    --muscle-highlight-color: #ef4444;
    --muscle-hover-color: #f87171;
}

#view-statistics {
    padding: 20px;
    max-width: 100%;
    overflow-y: auto;
}

.statistics-header {
    text-align: center;
    margin-bottom: 30px;
}

.statistics-header h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.statistics-header p {
    color: #666;
    font-size: 1rem;
    margin: 0;
}

/* Muscle Maps Container */
.muscle-maps-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.muscle-map-wrapper {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
    text-align: center;
}

.muscle-map-wrapper h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3rem;
    font-weight: 600;
}

.muscle-map-svg {
    width: 100%;
    height: auto;
    max-height: 70vh;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background: white;
    padding: 10px;
    transition: transform 0.3s ease;
}

.muscle-map-svg:hover {
    transform: scale(1.02);
}

/* Muscle Group Styles */
.muscle-group {
    fill: var(--muscle-default-color);
    transition: fill 0.3s ease, opacity 0.3s ease;
    cursor: pointer;
}

.muscle-group:hover {
    fill: var(--muscle-hover-color) !important;
    opacity: 0.8;
}

.muscle-group.muscle-highlighted {
    fill: var(--muscle-highlight-color) !important;
    opacity: 0.9;
    filter: drop-shadow(0 0 8px var(--muscle-highlight-color));
}

/* Muscle Info Panel */
.muscle-info-panel {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin: 30px auto 0;
    max-width: 600px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--muscle-highlight-color);
    animation: fade-in 0.3s ease;
}

.muscle-info-panel h4 {
    color: #333;
    margin: 0 0 10px 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.muscle-info-panel p {
    color: #666;
    margin: 0;
    line-height: 1.6;
    font-size: 1rem;
}

/* Fade-in Animation */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design for Statistics */
@media (max-width: 768px) {
    .muscle-maps-container {
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }
    
    .muscle-map-wrapper {
        max-width: 400px;
    }
    
    .muscle-map-svg {
        max-height: 50vh;
    }
    
    #view-statistics {
        padding: 15px;
    }
    
    .statistics-header h2 {
        font-size: 1.5rem;
    }
    
    .muscle-info-panel {
        margin: 20px auto 0;
        padding: 15px;
    }
    
    .muscle-info-panel h4 {
        font-size: 1.2rem;
    }
}

/* Firefox Mobile Specific Fixes */
@-moz-document url-prefix() {
    .workout-app-content {
        padding-bottom: 110px !important; /* Extra padding for Firefox mobile */
    }
    
    .workout-app-nav {
        height: auto;
        min-height: 70px; /* Ensure minimum height for navigation */
    }
}

@media (max-width: 480px) {
    .muscle-maps-container {
        gap: 15px;
    }
    
    .muscle-map-wrapper {
        min-width: 250px;
        max-width: 350px;
    }
    
    .muscle-map-svg {
        max-height: 40vh;
        padding: 5px;
    }
    
    .statistics-header {
        margin-bottom: 20px;
    }
    
    .statistics-header h2 {
        font-size: 1.3rem;
    }
    
    .statistics-header p {
        font-size: 0.9rem;
    }
}