/* frontend/css/workouts.css */

/* CSS Variables */
:root {
    --font-primary: 'Inter', sans-serif;
    --text-primary: #EEFDF9;
    --text-secondary: #EEFDF930;
    --container-bg: #EEFDF920;
    --container-bg-hover: #EEFDF930;
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #2a2a2a;
    --bg-modal: #1a1a1a;
}

html {
    box-sizing: border-box;
}

/* --- Base Styles --- */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    margin: 0;
    padding: 0;
    /* Explicitly reset padding */
    overflow-y: auto;
    /* Allows vertical scrolling for the page */
    height: auto;
    /* Allows body to grow with content */
    min-height: 100vh;
    /* Ensures body fills at least the viewport height */
    display: block;
    /* Scrollbar styling to match home.css */
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-modal);
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

main {
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 0;
    /* Footer height removed */
    /* Safe area support for iPhone notch/Dynamic Island */
    padding-top: calc(24px + env(safe-area-inset-top, 0px));
    padding-left: calc(32px + env(safe-area-inset-left, 0px));
    padding-right: calc(32px + env(safe-area-inset-right, 0px));
    /* Scrollbar styling to match home.css */
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-modal);
}

/* Main page title */
.page-main-title {
    font-size: 36px;
    font-weight: 600;
    margin-bottom: 30px;
    padding-bottom: 10px;
    padding-left: 20px;
    padding-top: 70px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    /* Safe area support for iPhone notch/Dynamic Island */
    padding-top: calc(36px + env(safe-area-inset-top, 0px));
    padding-left: calc(0px + env(safe-area-inset-left, 0px));
}

h2.page-title {
    font-size: 1.875rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

p.text-muted {
    color: #757575;
}

p.text-error {
    color: #ef4444;
}

/* --- Event Delegation Optimization Styles --- */
/* Clickable workout cards with pseudo-element plus icons */
.clickable-workout-card,
.clickable-workout-item {
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.clickable-workout-card:hover,
.clickable-workout-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background-color: #2d2d2d;
}

/* Plus icon pseudo-element for cards */
.clickable-workout-card::after,
.clickable-workout-item::after {
    content: '+';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #a2a9b0;
    transition: all 0.2s ease;
    pointer-events: none;
    /* Prevent interference with click detection */
}

/* Hide plus icon for workout items in main library section (outside modal) */
#my-workouts-section .clickable-workout-item::after,
#workout-list .clickable-workout-item::after {
    display: none;
}

.clickable-workout-card:hover::after,
.clickable-workout-item:hover::after {
    background-color: #1a1a1a;
    color: white;
    transform: scale(1.1);
}

/* Group header styling - non-clickable container */
.workout-group-header {
    position: relative;
    padding: 8px 12px;
    border-radius: 8px;
}

/* Plus icon button for group headers */
.group-add-button {
    content: '+';
    position: absolute;
    top: 30px;
    right: 16px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background-color: #252525;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #a2a9b0;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    padding: 0;
}

.group-add-button:hover {
    transform: translateY(-50%) scale(1.15);
    background-color: #2d2d2d;
}

/* Adjust title spacing to account for plus icon */
.workout-group-header .plan-week-group-title {
    padding-right: 48px;
    /* Space for plus icon */
}

/* Visual feedback for click areas */
.clickable-workout-card:active,
.clickable-workout-item:active {
    transform: scale(0.98);
}

.group-add-button:active {
    transform: translateY(-50%) scale(0.95);
}

.skill-node {
    /* will-change set dynamically during animations */
    backface-visibility: hidden;
}

/* --- Section Headers --- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    font-family: var(--font-primary);
}

.section-header div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-subtitle {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-secondary);
    margin: 0;
    font-family: var(--font-primary);
}

/* Schedule Button Container - override section-header div column layout */
.schedule-button-container {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
}

/* Restart Schedule Button - styled like notes-help-icon.edit-mode-delete */
.restart-schedule-btn {
    /* Base styling */
    width: auto;
    padding: 4px 12px;
    border-radius: 20px;
    background-color: #ef4444;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    border: none;
    cursor: pointer;
    white-space: nowrap;

    /* Ensure it doesn't interfere with display:none */
    font-family: var(--font-primary);
}

.restart-schedule-btn:hover {
    background-color: #dc2626;
    transform: scale(1.05);
}

/* Navigation buttons */
.nav-text-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    padding: 8px;
    transition: opacity 0.3s ease;
}

.nav-text-btn:hover {
    opacity: 0.3;
}

.nav-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.nav-icon-btn:hover {
    opacity: 0.7;
}

.nav-icon-btn img {
    width: 24px;
    height: 24px;
}

/* --- My Plan Section --- */
#my-plan-section {
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 24px;
    background-color: transparent;
}

.horizontal-scroll-container {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 0px;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-modal);
    box-sizing: border-box;
}

.horizontal-scroll-container::-webkit-scrollbar {
    height: 10px;
}

.horizontal-scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 5px;
}

.horizontal-scroll-container::-webkit-scrollbar-thumb {
    background-color: var(--bg-tertiary);
    border-radius: 5px;
    border: 2px solid var(--bg-modal);
}

.horizontal-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: #6b7a8c;
}

.workout-day-card {
    flex: 0 0 auto;
    width: 180px;
    height: 180px;
    border: none;
    border-radius: 28px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--text-primary);
    background-color: var(--container-bg);
    transition: all 0.25s ease-out;
    cursor: pointer;
    position: relative;
    /* For the card-specific "+" button */
}

/* Ensure skill icons are at the bottom in Schedule cards */
.workout-day-card .skill-icons-title-container {
    margin-top: auto;
}

/* Content wrapper removed - using simplified structure */


.workout-day-card:hover {
    background-color: var(--container-bg-hover);
}

.workout-day-card h4,
.workout-day-card-title {
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    align-self: flex-start;
}

/* Goals and status styles removed as they are no longer used */

.workout-day-card.plan-archived-week {
    background-color: #28313e;
    border-color: #3a4553;
    opacity: 0.75;
}

.workout-day-card.plan-archived-week h4 {
    color: #b0bcc9;
}

.workout-day-card.plan-archived-week:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
    opacity: 0.9;
}

.workout-day-card.plan-day-logged-in-active {
    /* For logged days in the active plan */
    background-color: #1a1a1a;
}

.workout-day-card .btn {
    margin-top: auto;
    width: 100%;
    font-size: 0.85rem;
    padding: 8px 10px;
}

.workout-day-card .btn-secondary {
    background-color: #5a6878;
}

.workout-day-card .btn-secondary:hover {
    background-color: #6b7a8c;
}

/* +++  Delete button for cards in "My Active Plan" */
.btn-delete-day-from-plan {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: transparent;
    color: #ef4444;
    /* Red icon/text */
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    z-index: 15;
    /* Above other card content but below modal */
}

.btn-delete-day-from-plan:hover {
    background-color: #ef4444;
    /* Solid red on hover */
    color: white;
    transform: scale(1.1);
}

/* +++ DELETE BUTTON STYLE +++ */


/* .start-log-btn-from-history styles removed as the button is no longer used */
.add-week-scroll-card {
    flex: 0 0 auto;
    width: 180px;
    height: 180px;
    min-height: 180px;
    background-color: #2d2d2d;
    border-radius: 28px;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.25s ease-out;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 15px;
}

.add-week-scroll-card .add-week-plus-icon {
    font-size: 3rem;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 10px;
    color: #ffffff;
}

.add-week-scroll-card .add-week-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: #e0e0e0;
}

.add-week-scroll-card:hover {
    background-color: #3a455a;
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 7px 14px rgba(0, 0, 0, 0.3);
}

/* --- "My Workouts" Section --- */
#my-workouts-section {
    margin-bottom: 30px;
    padding: 4px;
    border-radius: 12px;
    background-color: transparent;
}

.my-workouts-plan-week-group {
    margin-bottom: 20px;
    padding: 15px;
    background-color: transparent;
    border-radius: 8px;
}

.plan-week-group-title {
    font-size: 1.1rem;
    /* Adjusted for potentially longer text + button */
    font-weight: 500;
    color: #ccc;
    margin-bottom: 10px;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Button to add the entire group/set to the active plan */
.btn-add-group-to-plan {
    /* This class is added along with btn-add-to-active-plan.
       We need to override the position: absolute from btn-add-to-active-plan */
    position: static !important;
    /* Use !important if necessary, or ensure higher specificity */
    top: auto !important;
    right: auto !important;
    /* General styling for this button */
    font-size: 0.8rem;
    margin-left: 15px;
    /* Space from the title text */
    background-color: #7a7a7a;
    /* Green, like success */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    line-height: normal;
    /* Reset line-height if inherited oddly */
    width: auto;
    /* Not full width */
    height: auto;
    /* Not fixed height */
    flex-shrink: 0;
    /* Prevent shrinking */
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-add-group-to-plan:hover {
    background-color: #7a7a7a;
    /* Darker green */
    transform: scale(1.05);
}


.my-workouts-horizontal-scroll {
    padding: 10px 0;
    display: flex;
    overflow-x: auto;
    gap: 18px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-modal);
}

.my-workouts-horizontal-scroll::-webkit-scrollbar {
    height: 10px;
}

.my-workouts-horizontal-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 5px;
}

.my-workouts-horizontal-scroll::-webkit-scrollbar-thumb {
    background-color: var(--bg-tertiary);
    border-radius: 5px;
    border: 2px solid var(--bg-modal);
}

.my-workouts-horizontal-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #6b7a8c;
}

.my-workouts-group-separator {
    border: none;
    height: 1px;
    margin: 25px 0;
}

.workout-item {
    background-color: var(--container-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 180px;
    height: 180px;
    border-radius: 28px;
    padding: 16px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    border: none;
    position: relative;
    /* For the absolute positioned button */
}

/* Ensure skill icons are at the bottom in workout-item */
.workout-item .skill-icons-title-container {
    margin-top: auto;
}

.workout-item:hover {
    background-color: var(--container-bg-hover);
}

.workout-item-title {
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    align-self: flex-start;
}

.workout-item-text-title {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-primary);
    font-family: var(--font-primary);
}

/* Date and summary styles removed as they are no longer used */

/* General "+" Button for adding to active plan (used on cards and vertical items) */
.btn-add-to-active-plan {
    position: absolute;
    /* This is key for its placement on cards/items */
    top: 10px;
    right: 10px;
    background-color: #383838;
    /* Darker, less prominent than group add */
    color: white;
    border: 1px solid #383838;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    /* font-size, font-weight, and line-height removed as we are using an SVG now */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    /* Ensure no extra padding affects centering */
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    z-index: 10;
}

.btn-add-to-active-plan:hover {
    background-color: #03a3b1;
    /* Green on hover */
    border-color: #03a3b1;
    transform: scale(1.1);
}

.btn-add-to-active-plan:active {
    transform: scale(0.95);
}

/* Clickable workout items styling */
.clickable-workout-item {
    cursor: pointer;
}

.clickable-workout-card {
    cursor: pointer;
}

/* Styling for the SVG plus icon */
.btn-add-to-active-plan .plus-icon-svg {
    width: 10x;
    /* Adjust size as needed */
    height: 10px;
    /* Adjust size as needed */
    display: block;
    /* Prevents extra space below inline images */
}

/* Styling for the SVG cross icon */
.btn-delete-day-from-plan .cross-icon-svg {
    width: 8px;
    /* Adjust size as needed */
    height: 8px;
    /* Adjust size as needed */
    display: block;
    /* Prevents extra space below inline images */
}

/* --- Empty State Placeholders --- */
.placeholder-container {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 5px;
    gap: 18px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-modal);
    box-sizing: border-box;
}

.placeholder-card {
    flex: 0 0 auto;
    width: 180px;
    height: 180px;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--container-bg);
    opacity: 0.7;
    position: relative;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.placeholder-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.placeholder-text {
    font-size: 0.95rem;
    color: #757575;
    text-align: center;
    line-height: 1.4;
}

.placeholder-text-main {
    font-size: 1.05rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.placeholder-text-sub {
    font-size: 0.85rem;
}

/* Workouts section placeholder specific */
.workouts-placeholder {
    padding: 40px 20px;
    text-align: center;
}

.placeholder-workout-item {
    background-color: #252525;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 20px;
    margin-bottom: 16px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0.7;
    position: relative;
    overflow: hidden;
}

.placeholder-workout-item::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.02) 50%,
            transparent 100%);
    animation: shimmer 2s infinite;
}

/* --- Modals --- */

.library-workouts-list {
    padding: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    box-sizing: border-box;
}

/* Remove backgrounds from workout groups in modal */
.library-workouts-list .my-workouts-plan-week-group {
    background-color: transparent;
    width: 100%;
    padding: 15px 0;
}

/* Horizontal scroll container for Library main view */
#workout-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 0px;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-modal);
    min-height: 190px;
    /* Ensure height for placeholder */
}

#workout-list .workout-item {
    flex: 0 0 180px;
    /* Prevent shrinking, fixed width */
    min-width: 180px;
    /* Ensure minimum width */
}

/* Individual workout items in the library modal - match card sizing */
.library-workouts-list .workout-item {
    width: 180px;
    height: 180px;
    flex: 0 0 180px;
    min-width: 180px;
}

#workout-list::-webkit-scrollbar {
    height: 10px;
}

#workout-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 5px;
}

#workout-list::-webkit-scrollbar-thumb {
    background-color: var(--bg-tertiary);
    border-radius: 5px;
    border: 2px solid var(--bg-modal);
}

#workout-list::-webkit-scrollbar-thumb:hover {
    background-color: #6b7a8c;
}

.modal-content {
    background-color: #282a2c;
    padding: 25px 30px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    color: #F6EAE7;
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-content.large-modal {
    max-width: 700px;
}

.modal-content.small-modal {
    max-width: 400px;
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: white;
    text-align: center;
}

.modal-body-text {
    margin-bottom: 24px;
    color: white;
    text-align: center;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

.modal-question {
    margin-bottom: 18px;
}

.modal-question label {
    display: block;
    margin-bottom: 7px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #b3b2b1;
}

.modal-question input[type="text"],
.modal-question input[type="number"],
.modal-question select,
.modal-question textarea {
    width: 100%;
    padding: 10px 12px;
    margin-top: 4px;
    border: 1px solid #d6c7c3;
    border-radius: 6px;
    background-color: white;
    color: #0A090C;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.modal-question input[type="text"]:focus,
.modal-question input[type="number"]:focus,
.modal-question select:focus,
.modal-question textarea:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(186, 63, 29, 0.15);
    outline: none;
}

.modal-question .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}

.modal-question .checkbox-group label {
    display: inline-flex;
    background-color: #b3b2b1;
    padding: 7px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    margin: 2px;
    color: #333;
    transition: all 0.2s ease;
    cursor: pointer;
}

.modal-question .checkbox-group label:has(input:checked) {
    background-color: #3498db;
    color: white;
}

.modal-question .checkbox-group input[type="checkbox"] {
    margin-right: 6px;
}

.error-message {
    color: #3498db;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 10px;
    text-align: center;
    font-size: 0.85em;
}

/* Plan History Modal Specifics */
#plan-history-list-container {
    max-height: 65vh;
    overflow-y: auto;
    padding: 10px;
}

/* Style for cards inside plan history modal */
.plan-history-card-style {
    background-color: #2d2d2d;
    /* Lighter background for modal items */
    margin-bottom: 12px;
}


.plan-history-card-style:hover {
    background-color: #252525;
}


/* Progress Section */
#progress-section {
    padding: 4px;
    border-radius: 12px;
    background-color: transparent;
}

#progress-container {}

/* General Separator */
hr.section-separator {
    border: none;
    height: 1px;
    margin: 32px 0;
    background-color: rgba(238, 253, 249, 0.1);
}

/* Utility */
.hidden {
    display: none !important;
}

.page-error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    text-align: center;
    font-size: 0.9em;
}





/* Container for multiple icons that replaces the text title */
.skill-icons-title-container {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 3px;
    margin-top: auto;
    max-width: 100%;
    /* 2 rows max, 3 items per row */
    justify-content: flex-start;
    /* Ensure proper sizing for 2 rows of 3 icons each */
    width: fit-content;
    max-width: 69px;
    /* 3 icons * 20px + 2 gaps * 3px = 66px + small buffer */
    margin-top: 16px;
}

/* Individual circle for each skill icon */
.skill-icon-circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    flex-shrink: 0;
}

/* The SVG icon itself inside the circle */
.skill-icon-svg {
    width: 100%;
    /* Example: Icon smaller than circle for a border effect */
    height: 100%;
    /* Example: Icon smaller than circle for a border effect */
    object-fit: contain;
    /* Scales SVG nicely */
}

/* Smaller icons for history view */
.history-icons .skill-icon-circle {
    width: 28px;
    height: 28px;
    margin-right: 4px;
}




/* Larger 32x32px icons for workout cards */
.workout-item .skill-icon-circle,
.workout-day-card .skill-icon-circle {
    width: 32px;
    height: 32px;
}

/* Update container width for larger icons in workout cards */
.workout-item .skill-icons-title-container,
.workout-day-card .skill-icons-title-container {
    max-width: 105px;
    /* 3 icons * 32px + 2 gaps * 3px = 102px + small buffer */
}


.plan-history-icon {
    cursor: pointer;
    width: 35px;
    /* Adjust size as needed */
    height: 35px;
    /* Adjust size as needed */
    padding: 8px;
    border-radius: 50%;
    /* Make it a circle */
    transition: background-color 0.3s ease;
    /* Smooth transition for hover */
}

.plan-history-icon.hidden {
    display: none;
}

.plan-history-icon:hover {
    background-color: #1a1a1a;
}

/* --- History Modal Specific Styles --- */

.history-nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.history-month-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    flex: 1;
}

.history-content {
    height: 100%;
    overflow-y: auto;
    padding: 0 8px;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.history-section {
    margin-bottom: 32px;
    min-width: 350px;
}

.history-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 16px;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}




.history-week-group {
    border-radius: 12px;
    padding: 20px;
}

.history-week-title {
    font-size: 1rem;
    font-weight: 500;
    color: #e5e7eb;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

}


.loading-message {
    text-align: center;
    color: #9ca3af;
    font-size: 1rem;
    padding: 40px 20px;
}

.no-data-message {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px;
}

.no-data-message p {
    margin: 8px 0;
}

.no-data-message .text-muted {
    font-size: 0.9rem;
    color: #6b7280;
}

/* History navigation arrow buttons */
.history-nav-arrow-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, background-color 0.3s ease;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.history-nav-arrow-btn:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
}

.history-nav-arrow-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.history-nav-arrow-btn img {
    width: 24px;
    height: 24px;
}


/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    #history-modal .modal-content {
        max-width: 100%;
    }

    .history-nav-container {
        /* Keep flex-direction as row to maintain horizontal layout */
        gap: 12px;
        text-align: center;
    }

}

/* === Recent Achievements Styles === */

#recent-achievements-section {
    margin-bottom: 32px;
}

/* Base styles - mobile first (2x2 grid) */
.achievements-container {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 378px;
    /* 180px + 180px + 18px gap */
    margin: 0px 0px;
    box-sizing: border-box;
}

/* Ensure direct children are grid items */
.achievements-container>* {
    margin: 0;
}

.achievement-card {
    background: linear-gradient(135deg, #2a2a2a 0%, #333333 100%);
    border-radius: 28px;
    padding: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
    /* Adaptive sizing like skills grid */
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    max-width: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

.achievement-card.clickable {
    cursor: pointer;
}

.achievement-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: #555555;
}

.achievement-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
    flex: 1;
}

.achievement-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
}

.achievement-details {
    flex: 1;
    min-width: 0;
}

.exercise-name {
    font-weight: 400;
    color: #f9fafb;
    font-size: 16px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.achievement-value {
    font-weight: 700;
    color: #03a3b1;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.improvement-text {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
}

.achievement-date {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 0.7rem;
    color: #9ca3af;
    background: rgba(42, 42, 42, 0.9);
    padding: 2px 6px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
}

.no-achievements-message {
    text-align: center;
    padding: 32px 16px;
    background: #2a2a2a;
    border: 1px solid #404040;
    border-radius: 12px;
    border-style: dashed;
    grid-column: 1 / -1;
    /* Span across all columns */
}

.no-achievements-message p {
    margin: 0;
    color: #9ca3af;
    font-size: 0.95rem;
}

/* Desktop styles - straight line of 4 containers */
@media (min-width: 769px) {
    .achievements-container {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 18px;
        max-width: 738px;
        /* 180px * 4 + 18px * 3 gaps */
    }
}

/* Responsive adjustments for achievements */
/* Tablets and medium screens */
@media (max-width: 768px) {
    .achievements-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
        justify-content: center;
        max-width: 372px;
        /* 180px + 180px + 12px gap */
        margin: 0px 0px;
    }

    .achievement-card {
        padding: 12px;
        /* Responsive sizing - cards scale with grid */
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        max-width: 180px;
    }

    .achievement-content {
        gap: 8px;
    }

    .achievement-icon {
        font-size: 1.2rem;
    }


    .achievement-value {
        font-size: 0.9rem;
    }

    .achievement-date {
        font-size: 0.7rem;
        padding: 1px 4px;
    }
}

/* Small screens: Adjust max-width to prevent overflow */
@media (max-width: 390px) {
    .achievement-card {
        max-width: 165px;
    }
}

/* Very small screens (single column) */
@media (max-width: 360px) {
    .achievements-container {
        grid-template-columns: 1fr;
        gap: 12px;
        justify-items: center;
        max-width: none;
    }
}

/* Exercise History Modal styles moved to dedicated file: exercise-history-modal.css */




/* === Loading Skeleton for Achievements === */

.achievements-loading {
    width: 100%;
}

.loading-skeleton {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    justify-content: center;
    width: 100%;
    max-width: 338px;
    margin: 0 auto;
}

.skeleton-card {
    background: linear-gradient(90deg, #2a2a2a 25%, #333333 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 12px;
    /* Adaptive sizing like achievement cards */
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    max-width: 180px;
    position: relative;
    overflow: hidden;
}

.skeleton-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #404040 0%, #555555 50%, #404040 100%);
    opacity: 0.5;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* === Workout Generation Placeholder Styles === */

.generation-placeholder,
.generation-success,
.generation-error {
    background: #1f1f1f;
    border-radius: 10px;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    /* Match workout-item dimensions */
    width: 180px;
    height: 180px;
    flex: 0 0 180px;
    min-width: 180px;
}

.generation-placeholder {
    background: linear-gradient(135deg, #1f1f1f 0%, #252525 100%);
    position: relative;
    overflow: hidden;
}

.generation-placeholder::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(3, 163, 177, 0.1) 50%,
            transparent 100%);
    animation: shimmer 2s infinite;
    pointer-events: none;
}

.generation-success {
    border-color: #4ade80;
    background: #1a2e1a;
}

.generation-error {
    border-color: #ef4444;
    background: #2e1a1a;
}

.workout-generation-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    gap: 12px;
    height: 100%;
    text-align: center;
}

.generation-loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.generation-progress-bar {
    width: 80%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.generation-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a90e2, #03a3b1);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.generation-success-icon {
    width: 32px;
    height: 32px;
    background: #4ade80;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a2e1a;
    font-weight: bold;
    font-size: 1rem;
    animation: success-bounce 0.6s ease-in-out;
}

.generation-error-icon {
    width: 32px;
    height: 32px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2e1a1a;
    font-weight: bold;
    font-size: 1rem;
}

.generation-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.generation-text h4 {
    color: #e0e0e0;
    margin: 0 0 4px 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.generation-text p {
    color: #b0b0b0;
    margin: 0 0 4px 0;
    font-size: 0.75rem;
    line-height: 1.3;
}

.generation-progress-text {
    font-size: 0.7rem;
    color: #03a3b1;
    font-weight: 500;
    margin-top: 4px;
}

.generation-text .btn {
    margin-top: 8px;
    padding: 4px 12px;
    font-size: 0.75rem;
}

@keyframes success-bounce {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Responsive skeleton */
@media (max-width: 768px) {
    .loading-skeleton {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        justify-content: center;
        max-width: 338px;
        margin: 0 auto;
    }

    .skeleton-card {
        /* Responsive sizing */
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        max-width: 180px;
    }
}

/* Small screens: Adjust skeleton max-width */
@media (max-width: 390px) {
    .skeleton-card {
        max-width: 165px;
    }
}

@media (max-width: 360px) {
    .loading-skeleton {
        grid-template-columns: 1fr;
        gap: 12px;
        justify-items: center;
        max-width: none;
    }

    main {
        padding-top: 60px;
        /* Added top padding for mobile menu button */
    }
}

@media (max-width: 480px) {
    main {
        padding-top: 60px;
        /* Added top padding for mobile menu button */
    }

    .achievements-container {
        grid-template-columns: 1fr;
    }
}

/* Success Modal Styles - Matching Settings Page */
#workout-activation-success-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    opacity: 0;
    visibility: visible !important;
    transition: opacity 0.3s ease;
}

#workout-activation-success-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible !important;
}

.success-modal .modal-content-small {
    max-width: 420px;
    text-align: center;
    padding: 3rem 2rem;
    background-color: #2d2d2d;
    border-radius: 12px;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.success-modal.show .modal-content-small {
    transform: scale(1);
}


.success-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #f9fafb;
    margin-bottom: 0.75rem;
}

.success-message {
    font-size: 1rem;
    color: #a0aec0;
    line-height: 1.5;
    margin-bottom: 2rem;
}

.success-modal .btn-large {
    min-width: 120px;
    padding: 0.75rem 2rem;
}

/* Start Workout Confirmation Modal Styles */
#confirmation-modal .workout-name-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: #f9fafb;
    margin: 0 0 0.75rem 0;
    line-height: 1.3;
}

#confirmation-modal .workout-subtitle {
    font-size: 1rem;
    color: #a0aec0;
    margin: 0;
    line-height: 1.5;
}

#confirmation-modal .modal-actions {
    gap: 1rem;
}

#confirmation-modal .btn {
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
}

/* Legacy delete-day-confirmation-modal styles removed - now uses standard modal system */

/* ======================================
   INFINITE SCROLL STYLES
   ====================================== */

/* Library Loading Spinner */
.library-loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
}

.library-loading-spinner .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.library-loading-spinner p {
    color: #9ca3af;
    font-size: 0.9rem;
    margin: 0;
    font-weight: 500;
}

/* Spinner animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* End of data message */
.library-end-message {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 16px;
}

.library-end-message p {
    color: #6b7280;
    font-size: 0.9rem;
    margin: 0;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.library-end-message p::before {
    content: '🏁';
    font-size: 1.2em;
}

/* Error message */
.library-error-message {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 16px;
    margin: 16px;
    text-align: center;
    color: #ef4444;
    font-size: 0.9rem;
    font-weight: 500;
}


/* Ensure library workouts container has proper spacing - Mobile First */
.library-all-workouts {
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
}

/* Make workout groups in library modal use horizontal scrolling */
.library-all-workouts .my-workouts-horizontal-scroll {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 0px;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-modal);
    box-sizing: border-box;
    /* Prevent the container from expanding beyond viewport */
    max-width: 100%;
}

.library-all-workouts .my-workouts-horizontal-scroll::-webkit-scrollbar {
    height: 10px;
}

.library-all-workouts .my-workouts-horizontal-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 5px;
}

.library-all-workouts .my-workouts-horizontal-scroll::-webkit-scrollbar-thumb {
    background-color: var(--bg-tertiary);
    border-radius: 5px;
    border: 2px solid var(--bg-modal);
}

.library-all-workouts .my-workouts-horizontal-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #6b7a8c;
}

/* Ensure workout cards in library modal maintain consistent sizing */
.library-all-workouts .workout-day-card {
    flex: 0 0 auto;
    width: 180px;
    height: 180px;
    min-width: 180px;
}

/* Keep individual workout items as cards in horizontal layout */
.library-all-workouts .workout-item {
    flex: 0 0 auto;
    width: 180px;
    height: 180px;
    min-width: 180px;
}

/* Ensure group titles and containers fit within viewport */
.library-all-workouts .my-workouts-plan-week-group {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    /* Prevent group container from creating horizontal scroll */
}

/* Ensure group titles in library modal have proper spacing and don't overflow */
.library-all-workouts .plan-week-group-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: #ccc;
    margin-bottom: 10px;
    padding-bottom: 8px;
    padding-right: 16px;
    /* Space for any buttons */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Desktop: Center content with max-width */
@media (min-width: 769px) {
    .library-all-workouts {
        max-width: 840px;
        margin: 0 auto;
        padding: 24px;
    }

    .library-workouts-list {
        padding: 24px;
    }
}