/* Flex Layouts */

/* --- App Container --- */
#app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

#app-container.loaded {
    opacity: 1;
}

/* --- App View --- */
.app-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    height: 100%;
    flex-direction: column;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
    opacity: 0;
    transform: translateX(0);
}

.app-view.active { 
    display: flex;
    opacity: 1;
    transform: translateX(0);
}

/* Slide out to left (when going to a higher index) */
.app-view.slide-out-left {
    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

/* Slide out to right (when going to a lower index) */
.app-view.slide-out-right {
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

/* Slide in from right (when coming from a lower index) */
.app-view.slide-in-right {
    animation: slideInFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Slide in from left (when coming from a higher index) */
.app-view.slide-in-left {
    animation: slideInFromLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --- Workout Content Wrapper (for tab switching animations) --- */
#workout-content-wrapper {
    position: relative;
    width: 100%;
    transform: translateX(0);
    opacity: 1;
}

/* Slide out to left (when going to a higher index tab) */
#workout-content-wrapper.slide-out-left {
    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

/* Slide out to right (when going to a lower index tab) */
#workout-content-wrapper.slide-out-right {
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

/* Slide in from right (when coming from a lower index tab) */
#workout-content-wrapper.slide-in-right {
    animation: slideInFromRight 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Slide in from left (when coming from a higher index tab) */
#workout-content-wrapper.slide-in-left {
    animation: slideInFromLeft 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- Content Scroll Area --- */
.content-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-top: var(--header-height);
    padding-bottom: 100px;
}

/* Additional top margin for profile and settings pages */
#view-profile .content-scroll-area,
#view-settings .content-scroll-area {
    padding-top: calc(var(--header-height) + 30px);
}

/* --- Glass Panel Header --- */
.glass-panel-header {
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border-bottom: 1px solid var(--border-glass);
    padding: 15px;
    position: sticky;
    top: var(--safe-area-top);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0; /* Ensure no gap that causes overlap */
}

/* --- Module Header --- */
.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

/* --- Header Actions --- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- Action Area --- */
.action-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- Input Group Row --- */
.input-group-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

/* --- Input Row --- */
.input-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* --- Set Row (Flex) --- */
.set-row:has(.actual-input) {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px;
    background: transparent;
    border: none;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.set-row:has(.actual-input):hover {
    background: var(--bg-glass-subtle);
}

/* --- Action Area Layout --- */
.action-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

