/* CSS including fixed buttons AND conditional fixed timer/bottom bar styles */

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    padding: 20px;
    background-color: #f4f4f4;
    color: #333;
    transition: padding-top 0.3s ease-out, padding-bottom 0.3s ease-out;
}

.container {
    max-width: 800px;
    margin: auto;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 0;
}

h1, h2, h3 {
    color: #0056b3;
    margin-bottom: 15px;
}

h1 {
    text-align: center;
    margin-top: 0;
}

hr {
    border: 0;
    height: 1px;
    background: #ddd;
    margin: 25px 0;
}

.section {
    margin-bottom: 25px;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 5px;
    background-color: #fdfdfd;
}

.hidden {
    display: none;
}

/* Form Elements */
.input-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: normal;
}

#setup-section label,
#settings-section label {
    font-weight: bold;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-bottom: 5px;
}

input[type="number"] {
    width: 30%;
    min-width: 80px;
}

input.custom-exercise-input {
    width: calc(100% - 20px);
    margin-left: 20px;
    margin-top: 5px;
}

/* Buttons */
button,
.button-label {
    display: inline-block;
    padding: 12px 20px;
    background-color: #007bff;
    color: white !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    text-align: center;
    transition: background-color 0.2s ease;
    margin-top: 10px;
    margin-right: 10px;
    text-decoration: none;
    font-weight: normal;
}

button:hover,
.button-label:hover {
    background-color: #0056b3;
}

button.secondary,
.button-label.secondary {
    background-color: #6c757d;
}

button.secondary:hover,
.button-label.secondary:hover {
    background-color: #5a6268;
}

button.danger,
.button-label.danger {
    background-color: #dc3545;
}

button.danger:hover,
.button-label.danger:hover {
    background-color: #c82333;
}

button.inline-btn {
    padding: 8px 15px;
    font-size: 14px;
    margin-left: 10px;
}

button.finish-workout-btn {
    display: block;
    width: 100%;
    margin-top: 25px;
    background-color: #28a745;
    font-weight: bold;
}

button.finish-workout-btn:hover {
    background-color: #218838;
}

/* Workout Selector */
#workout-selector-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.workout-selector-item {
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 5px;
    cursor: pointer;
    background-color: #fff;
    transition: background-color 0.2s, box-shadow 0.2s;
    text-align: center;
    font-size: 0.95em;
}

.workout-selector-item:hover {
    background-color: #e9f5ff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.workout-selector-item.completed {
    border-left: 5px solid #28a745;
    background-color: #f0fff4;
}

.workout-selector-item.testing-week {
    border-left: 5px solid #ffc107;
    background-color: #fffbec;
}

.workout-selector-item .week-day {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.workout-selector-item .main-lift-preview {
    font-size: 0.85em;
    color: #555;
}

.workout-selector-item .status {
    font-size: 0.75em;
    color: #1a6a30;
    font-weight: normal;
    margin-top: 5px;
    display: block;
}

/* Lists */
ul {
    list-style: none;
    padding: 0;
}

li {
    background: #f9f9f9;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
}

/* Exercise Display */
.exercise-header {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 8px;
}

.exercise-header a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted #007bff;
}

.exercise-header a:hover {
    color: #0056b3;
    border-bottom-style: solid;
}

.set-info {
    margin-left: 15px;
    font-size: 0.95em;
    color: #555;
    line-height: 1.4;
}

.set-info strong {
    color: #333;
}

.set-info br {
    content: "";
    margin: 3px 0;
    display: block;
}

.last-logged-info {
    font-size: 0.85em;
    color: #666;
    margin-left: 0px;
    font-style: italic;
    margin-top: 8px;
    margin-bottom: 8px;
    display: block;
}

/* Set Logging */
.set-logging input[type="number"] {
    width: 80px;
    margin-right: 15px;
    margin-bottom: 8px;
    vertical-align: middle;
}

.set-logging label {
    display: inline-block;
    width: 50px;
    margin-right: 5px;
    text-align: right;
    vertical-align: middle;
}

.set-logging .set-item {
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px dotted #eee;
}

.set-logging .set-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.set-logging .input-line {
    display: block;
    margin-bottom: 5px;
}

.set-logging button {
    margin-top: 5px;
    vertical-align: middle;
}

/* Timer */
#timer-display {
    font-size: 2.8em;
    font-weight: bold;
    text-align: center;
    margin: 0 0 15px 0;
    color: #007bff;
}

/* Messages */
.success-message,
.error-message {
    padding: 12px;
    margin: 15px 0;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Program Content */
#full-program-content h2,
#settings-section h2 {
    font-size: 1.8em;
    color: #333;
}

#full-program-content h3,
#settings-section h3 {
    font-size: 1.4em;
    color: #0056b3;
}

#full-program-content h4,
#settings-section h4 {
    font-size: 1.2em;
    color: #555;
}

#full-program-content ul {
    margin-left: 20px;
}

#full-program-content li {
    background: none;
    border: none;
    padding: 5px 0;
}

#full-program-content hr {
    margin: 40px 0;
    background: #ccc;
}

/* Settings */
#settings-section .settings-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

#settings-section .settings-group:last-child {
    border-bottom: none;
}

#selected-workout-area h3 {
    text-align: center;
    margin-bottom: 20px;
}

#selected-workout-details {
    border-top: 2px solid #007bff;
    padding-top: 20px;
    margin-top: 20px;
}

/* Fixed Close Buttons */
.fixed-close-btn {
    position: fixed;
    top: 70px;
    right: 30px;
    z-index: 1000;
    margin-top: 0;
}

#full-program-view,
#settings-section {
    position: relative;
}

/* Fixed Timer Bar */
#timer-section {
    display: none;
}

#timer-section.timer-fixed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1001;
    background-color: rgba(0, 91, 187, 0.9);
    padding: 8px 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

#timer-section.timer-fixed h3 {
    display: none;
}

#timer-section.timer-fixed #timer-display {
    font-size: 1.8em;
    color: #fff;
    margin: 0 15px 0 0;
}

#timer-section.timer-fixed button {
    padding: 6px 10px;
    font-size: 13px;
    margin: 0 3px;
    color: #333 !important;
    background-color: #f8f9fa;
    border: 1px solid #ccc;
}

#timer-section.timer-fixed button:hover {
    background-color: #e2e6ea;
}

/* Fixed Bottom Bar */
.fixed-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(240, 240, 240, 0.95);
    padding: 10px 15px;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    box-sizing: border-box;
    text-align: center;
}

#full-program-view:not(.hidden) .fixed-bottom-bar,
#settings-section:not(.hidden) .fixed-bottom-bar,
#selected-workout-area:not(.hidden) .fixed-bottom-bar,
#historical-programs-view:not(.hidden) .fixed-bottom-bar {
    display: block;
}

/* Historical Programs Styles */
.historical-programs-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.historical-program-item {
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    transition: box-shadow 0.2s;
}

.historical-program-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.historical-program-item.current {
    border-color: #0056b3;
    background-color: #f0f8ff;
}

.historical-program-item h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #0056b3;
}

.program-meta {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    background-color: #0056b3;
    color: white;
    border-radius: 3px;
    font-size: 0.8em;
    margin-left: 10px;
}

.program-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.program-actions button {
    flex: 1;
}

.fixed-bottom-bar button {
    margin: 0 5px;
}

.fixed-bottom-bar #finish-workout-btn {
    width: auto;
    display: inline-block;
}

/* Body Padding for Fixed Bars */
body.timer-active-padding {
    padding-top: 60px;
}

body.bottom-bar-padding {
    padding-bottom: 80px;
}

body.timer-active-padding.bottom-bar-padding {
    padding-top: 60px;
    padding-bottom: 80px;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    .section {
        padding: 15px;
        margin-bottom: 15px;
    }

    li {
        padding: 10px;
        margin-bottom: 8px;
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }

    h2 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }

    h3 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }

    hr {
        margin: 15px 0;
    }

    .input-group {
        margin-bottom: 10px;
    }

    button,
    .button-label {
        padding: 10px 15px;
        font-size: 15px;
        margin-right: 5px;
    }

    button.inline-btn {
        padding: 6px 10px;
        font-size: 13px;
        margin-left: 5px;
    }

    .set-logging .set-item input[type="number"] {
        width: 70px;
    }

    .fixed-close-btn {
        top: 55px;
        right: 10px;
        padding: 8px 12px;
    }

    /* Timer specific mobile adjustments */
    #timer-section.timer-fixed {
        padding: 5px 10px;
    }

    #timer-section.timer-fixed #timer-display {
        font-size: 1.5em;
        margin-right: 10px;
    }

    #timer-section.timer-fixed button {
        padding: 5px 8px;
        font-size: 12px;
        margin: 0 2px;
    }

    body.timer-active-padding {
        padding-top: 45px;
    }

    /* Bottom bar mobile adjustments */
    .fixed-bottom-bar {
        padding: 8px 10px;
    }

    .fixed-bottom-bar button {
        padding: 8px 15px;
        font-size: 14px;
    }

    body.bottom-bar-padding {
        padding-bottom: 70px;
    }

    body.timer-active-padding.bottom-bar-padding {
        padding-top: 45px;
        padding-bottom: 70px;
    }

    /* Other mobile */
    #workout-selector-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .workout-selector-item {
        padding: 10px;
        font-size: 0.9em;
    }

    .set-logging .set-item label {
        width: 40px;
    }

    .set-logging .set-item input[type="number"] {
        margin-right: 10px;
    }
}

/* ============================================
   Exercise Swap Dropdown Styles
   ============================================ */

/* Container for swappable exercise header */
.exercise-header.exercise-swappable {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.exercise-swap-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Exercise swap dropdown */
.exercise-swap-dropdown {
    flex: 1;
    padding: 8px 12px;
    font-size: 1em;
    font-weight: bold;
    color: #333;
    background-color: #fff;
    border: 2px solid #007bff;
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23007bff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 35px;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
    max-width: 100%;
}

.exercise-swap-dropdown:hover {
    border-color: #0056b3;
}

.exercise-swap-dropdown:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

/* YouTube link button */
.yt-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: #ff0000;
    color: white !important;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.yt-link:hover {
    background-color: #cc0000;
}

/* Custom exercise input */
.exercise-custom-input {
    width: 100% !important;
    padding: 10px 12px !important;
    font-size: 1em;
    border: 2px dashed #28a745 !important;
    border-radius: 6px;
    background-color: #f8fff8;
    margin-left: 0 !important;
    margin-top: 8px !important;
    box-sizing: border-box;
}

.exercise-custom-input:focus {
    outline: none;
    border-style: solid !important;
    border-color: #28a745 !important;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.15);
}

.exercise-custom-input::placeholder {
    color: #6c757d;
    font-style: italic;
}

/* When custom option is selected, show visual indicator */
.exercise-swap-dropdown option[value="__CUSTOM__"] {
    font-style: italic;
    color: #28a745;
}

/* Mobile responsive for exercise swap */
@media (max-width: 600px) {
    .exercise-swap-dropdown {
        padding: 6px 10px;
        padding-right: 30px;
        font-size: 0.95em;
        background-size: 14px;
    }
    
    .yt-link {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .exercise-custom-input {
        padding: 8px 10px !important;
        font-size: 0.95em;
    }
}
