/* Progress panel positioning for larger screens */
@media (min-width: 768px) {
    .progress-sidebar {
        position: fixed;
        top: 210px;
        right: 20px;
        width: 300px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
    
    .main-content {
        margin-right: 320px;
    }
}

/* Main content centering */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Video container styles */
.video-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    aspect-ratio: 16/9; /* Default landscape aspect ratio */
    background: #000;
    max-height: calc(100vh - 200px);
    margin-bottom: 60px; /* Add space for footer */
    z-index: 1;
}

/* Mobile portrait mode */
@media (max-width: 640px) and (orientation: portrait) {
    .video-container {
        aspect-ratio: 9/16; /* Portrait aspect ratio for mobile */
        max-height: calc(100vh - 160px); /* Reduced to account for footer */
        margin-bottom: 80px; /* More space for footer on mobile */
    }
}

.video-container video,
.video-container canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Position guidance overlay */
.position-guidance {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 1rem;
    z-index: 15;
    backdrop-filter: blur(4px);
    text-align: center;
    display: none;
    max-width: 80%;
}

.position-guidance.visible {
    display: block;
}

/* Loading and CTA overlays */
#loadingOverlay,
#ctaOverlay {
    transition: opacity 0.3s ease-in-out;
    z-index: 20;
}

#loadingOverlay.hidden,
#ctaOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Fullscreen styles */
.video-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    border-radius: 0;
    max-height: none;
    aspect-ratio: 16/9; /* Default landscape aspect ratio */
}

/* Mobile portrait fullscreen */
@media (max-width: 640px) and (orientation: portrait) {
    .video-container.fullscreen {
        aspect-ratio: 9/16; /* Portrait aspect ratio for mobile */
    }
    
    /* Ensure controls are visible in fullscreen */
    .video-container.fullscreen .controls {
        bottom: 80px;
    }
    
    /* Adjust progress bar in fullscreen */
    .video-container.fullscreen .progress-overlay {
        padding-bottom: 70px;
    }
}

.video-container.fullscreen video,
.video-container.fullscreen canvas {
    width: 100%;
    height: 100%;
}

/* Rep counters positioning */
.counter-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 5px;
    z-index: 10;
    gap: 5px;
}

.counter-left,
.counter-right {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    border-radius: 4px;
    min-width: 70px;
    text-align: center;
    backdrop-filter: blur(4px);
}

.counter-label {
    font-size: 0.65rem;
    font-weight: bold;
    line-height: 1;
}

.counter-value {
    font-size: 1.25rem;
    font-weight: bold;
    line-height: 1;
}

.counter-angle {
    font-size: 0.6rem;
    opacity: 0.8;
    line-height: 1;
}

/* Pulse animation for active tracking */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 255, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 0, 0);
    }
}

.tracking-active {
    animation: pulse 2s infinite;
    border-radius: 8px;
}

/* State indicators */
.state-up {
    background-color: rgba(0, 255, 0, 0.7);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.state-down {
    background-color: rgba(255, 165, 0, 0.7);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

/* Progress overlay */
.progress-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    z-index: 10;
}

/* Settings panel transition */
#settingsPanel {
    max-width: 800px;
    margin: 1.5rem auto;
    transition: all 0.3s ease-in-out;
}

#settingsPanel.hidden {
    display: none;
}

/* Custom range input styling */
input[type=range] {
    height: 25px;
    -webkit-appearance: none;
    margin: 10px 0;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 5px;
    cursor: pointer;
    animate: 0.2s;
    box-shadow: 0px 0px 0px #000000;
    background: #4F46E5;
    border-radius: 5px;
    border: 0px solid #000000;
}

input[type=range]::-webkit-slider-thumb {
    box-shadow: 0px 0px 1px #000000;
    border: 1px solid #4F46E5;
    height: 18px;
    width: 18px;
    border-radius: 9px;
    background: #FFFFFF;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px;
}

/* Footer */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 10;
    backdrop-filter: blur(4px);
    font-size: small;
}

footer a {
    text-decoration: none;
    transition: color 0.2s ease-in-out;
    white-space: nowrap;
}

footer button {
    transition: all 0.2s ease-in-out;
}

.space-around { justify-content: space-around }
.space-evenly { justify-content: space-evenly }

/* Responsive adjustments */
@media (max-width: 640px) {
    .counter-left,
    .counter-right {
        min-width: 60px;
        padding: 3px;
    }

    .counter-value {
        font-size: 1.1rem;
    }

    .progress-overlay {
        padding: 8px;
    }

    footer {
        padding: 8px 12px;
    }
    
    footer .flex {
        width: 100%;
        justify-content: center;
    }

    footer .flex-1 {
        flex-direction: column;
        gap: 3px;
    }

    footer .space-x-4 {
        margin: 0;
    }
}

/* Controls centering */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* Mobile overlay controls */
@media (max-width: 640px) {
    .controls {
        position: absolute;
        bottom: 60px;
        left: 0;
        right: 0;
        z-index: 15;
        margin-top: 0;
        padding: 0 15px;
    }
    
    .controls button {
        flex: 1;
        background-color: rgba(0, 0, 0, 0.7);
        color: white;
        border: none;
        padding: 10px 16px;
        border-radius: 4px;
        backdrop-filter: blur(4px);
        font-weight: bold;
        transition: background-color 0.2s;
        text-transform: uppercase;
        font-size: 0.8rem;
        letter-spacing: 0.5px;
    }
    
    .controls button:hover, 
    .controls button:active {
        background-color: rgba(0, 0, 0, 0.9);
    }
    
    /* Adjust progress bar to make room for buttons */
    .progress-overlay {
        padding-bottom: 50px;
    }
}

/* Mobile menu */
#mobileMenu {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: white;
    z-index: 99999;
    display: none;
    overflow: visible;
}

#mobileMenu:not(.hidden) {
    display: block;
}

#mobileMenu .flex-col {
    width: 100%;
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
    padding: 0;
    position: static;
}

#mobileMenu a,
#mobileMenu button {
    display: block;
    width: 100%;
    padding: 12px;
    text-align: center;
    font-size: 16px;
    color: #374151;
    background: white;
    border: none;
    border-top: 1px solid #e5e7eb;
}

#mobileMenu a i,
#mobileMenu button i {
    margin-right: 8px;
}

#closeMenuBtn {
    color: #374151;
    border-top: 1px solid #e5e7eb !important;
    position: relative;
}

/* Desktop menu */
@media (min-width: 769px) {
    .md\:hidden {
        display: none !important;
    }
}

/* GIF container animation */
.gif-container {
    overflow: hidden;
    transition: all 0.3s ease-in-out;
    max-height: 500px;
    margin-top: 12px;
}

.gif-container.collapsed {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
}

/* Exercise instructions container positioning */
#exerciseInstructions {
    position: relative;
}

/* Example link styling */
#showKettlebellExample {
    font-size: 0.85rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    background-color: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
    font-weight: 500;
}

#showKettlebellExample:hover {
    background-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#showKettlebellExample svg {
    transition: transform 0.3s ease;
}

/* GIF positioning and styling */
.gif-container {
    position: absolute;
    top: 100%;
    right: 0;
    max-width: none;
    border: 2px solid #e5e7eb;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.gif-container img {
    width: auto;
    height: auto;
    display: block;
    max-height: 300px;
}

/* Mobile adjustments for the GIF */
@media (max-width: 640px) {
    .gif-container {
        right: 0;
        left: 0;
        margin: 0 auto;
        max-width: 90%;
    }
    
    .gif-container img {
        max-height: 250px;
        margin: 0 auto;
    }
}