/* General body and font styling */
body {
    font-family: 'Montserrat', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    /* Slight background color to improve contrast */
}

/* Header styling */
h1 {
    background-color: rgba(54, 69, 79, 1);
    color: white;
    margin: 0;
    padding: 15px;
    font-size: 28px;
    font-weight: 700;
}

.header {
    background-color: rgba(54, 69, 79, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Logo styling */
#logo {
    width: 75px;
    margin-right: 10px;
}

/* Main container layout */
.container {
    display: flex;
    justify-content: space-between;
    padding: 20px;
}

/* Left-side content */
.left-side {
    flex: 1;
    padding: 20px;
}

/* Right-side content with charts */
.right-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 20px;
    background-color: #ffffff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Form styling */
.workout-form {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

label {
    font-size: 16px;
    margin-bottom: 5px;
    color: rgba(54, 69, 79, 1);
    /* Matching the header color */
}

input[type="number"] {
    padding: 8px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    width: 25%;
    box-sizing: border-box;
}

.form-group {
    margin-bottom: 15px;
}

select#exercise-select {
    padding: 8px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    width: 50%;
    box-sizing: border-box;
    background-color: white;
}

input#weight {
    padding: 8px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    width: 25%;
    box-sizing: border-box;
}

/* Button styling */
button,
input[type="submit"] {
    padding: 12px 20px;
    /* Ensuring both buttons have the same padding */
    background-color: #6c7b8b;
    /* Matching color */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    /* Slightly smaller font for consistency */
    transition: background-color 0.3s ease;
    width: auto;
    margin-top: 10px;
    height: 40px;
    /* Fixing height for consistency */
    display: inline-flex;
    /* Aligning the text and button content */
    justify-content: center;
    /* Centering content */
    align-items: center;
    /* Vertically aligning content */
}

button:hover,
input[type="submit"]:hover {
    background-color: #5a6b77;
    /* Darker shade on hover */
}

/* Ensure submit button stays the same height as other buttons */
input[type="submit"] {
    line-height: 1.2;
}

/* Table styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

td, th {
    padding: 10px;
    text-align: center;
    font-size: 16px;
    color: rgba(54, 69, 79, 1);
    /* Matching the header color */
}

td:nth-child(2) {
    font-weight: 600;
    color: #36454f;
}

th:last-child, td:last-child {
    width: 35%;
}

tr:nth-child(even) {
    background-color: #f2f2f2;
}

/* Chart container styling */
.chart-container {
    width: 95%;
    min-width: 300px;
    max-height: 500px;
    height: 420px;
    margin-bottom: 25px;
    padding: 20px 20px 40px 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.8);
    position: relative;
    overflow: visible;
}

/* Chart header with title and controls */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.chart-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    font-family: 'Montserrat', sans-serif;
}

/* Chart toggle buttons */
.chart-controls {
    display: flex;
    gap: 5px;
    background: rgba(243, 244, 246, 0.8);
    border-radius: 6px;
    padding: 3px;
}

.chart-toggle-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Montserrat', sans-serif;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.7);
    color: #374151;
}

.chart-toggle-btn.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-toggle-btn.active:hover {
    background: #2563eb;
    color: white;
}

/* Specific override for calendar container to allow full height display */
#calendar.chart-container {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    min-height: 200px;
}

.chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3B82F6, #10B981, #F59E0B);
    border-radius: 12px 12px 0 0;
}

/* Specific styling for the total reps and reps per minute charts */
#reps-chart, #reps-per-minute-chart {
    max-height: 450px;
    height: 450px;
}

/* Monthly chart styling */
#reps-per-month-chart {
    max-height: 400px;
    height: 400px;
}

/* Calendar chart - inherits styling from .chart-container but with height overrides */
#calendar {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    min-height: 200px;
    /* All other styling inherited from chart-container */
}

/* Double-specific override to ensure calendar height is not constrained */
div#calendar.chart-container {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

#calendar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #8B5CF6, #EC4899, #F43F5E);
    border-radius: 12px 12px 0 0;
}

#activity {
    margin: 10px auto;
    display: block;
    border-radius: 4px;
    cursor: crosshair;
}

/* Layout for the form container */
.first-col-container {
    display: flex;
    justify-content: space-between;
}

/* Layout for controls */
.exercise-controls {
    margin-bottom: 15px;
}

.csv-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.csv-controls button {
    margin-top: 0;
}

/* Miscellaneous improvements */
button, input[type="submit"] {
    width: auto;
}

input[type="file"] {
    display: none;
}

/* Series list styling */
.series-list {
    padding-left: 15px;
    margin: 0;
    list-style-type: none;
    font-size: 0.9em;
}

.series-list li {
    margin-bottom: 3px;
    padding: 2px 5px;
    background-color: #f5f5f5;
    border-radius: 3px;
}

/* Workout list styling */
.workout-list-header {
    display: flex;
    background-color: rgba(54, 69, 79, 1);
    color: white;
    font-weight: 600;
    padding: 10px 0;
    border-radius: 5px 5px 0 0;
    margin-top: 20px;
}

.workout-list-header .header-item {
    flex: 1;
    padding: 0 10px;
    text-align: center;
}

#workout-list-container {
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
}

.workout-item {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.workout-item:last-child {
    border-bottom: none;
}

.workout-item:hover {
    background-color: #f9f9f9;
}

.workout-item.expanded {
    background-color: #f5f5f5;
}

.workout-detail {
    flex: 1;
    padding: 0 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.workout-detail.exercise {
    font-weight: 600;
    color: #36454f;
}

.toggle-icon {
    margin-left: 5px;
    font-size: 16px;
    transition: transform 0.3s;
}

.expanded .toggle-icon {
    transform: rotate(90deg);
}

.series-container {
    display: none;
    padding: 10px 15px;
    background-color: #f9f9f9;
    border-top: 1px dashed #ddd;
}

.workout-item.expanded+.series-container {
    display: block;
}

/* Deleted exercise type styling */
.workout-item.deleted-exercise-type {
    opacity: 0.6;
    background-color: #fff8dc; /* Light yellow background */
    border-left: 4px solid #ff9800; /* Orange left border indicator */
}

.workout-item.deleted-exercise-type:hover {
    background-color: #fff3cd;
}

.deleted-indicator {
    font-size: 0.8em;
    color: #ff9800;
    font-style: italic;
    font-weight: normal;
}

.workout-item.deleted-exercise-type .workout-detail.exercise {
    color: #856404; /* Darker text for deleted exercise types */
}

.series-list {
    padding-left: 0;
    margin: 0;
    list-style-type: none;
}

.series-list li {
    margin-bottom: 6px;
    padding: 0;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Single row form layout */
.form-controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 15px;
}

.form-controls-row .form-group {
    margin-bottom: 10px;
    flex: 1;
    min-width: 150px;
}

.form-controls-row .submit-group {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
}

.form-controls-row label {
    display: block;
    margin-bottom: 6px;
}

.form-controls-row select,
.form-controls-row input[type="number"] {
    width: 100%;
}

/* Adjustments to input sizes */
select#exercise-select {
    width: 100%;
}

input#weight, input#reps {
    width: 100%;
}

.exercise-controls {
    margin-bottom: 15px;
}

.csv-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.csv-controls button {
    margin-top: 0;
}

/* Activity chart legend */
.activity-legend {
    margin-top: 20px;
    padding: 15px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.legend-title {
    font-weight: 500;
    color: #333;
    margin-bottom: 10px;
    font-size: 14px;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Delete button styling */
.series-item {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    padding: 8px 15px 8px 10px;
    min-height: 36px;
    position: relative;
}

.series-info {
    flex: 1;
    line-height: 1.4;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
}

.delete-series-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    max-width: 22px;
    max-height: 22px;
    font-size: 18px;
    font-weight: normal;
    font-family: 'Courier New', monospace;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    margin: 0 0 0 10px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    flex-grow: 0;
    opacity: 0.6;
    box-sizing: border-box;
    padding: 0;
    border: 0;
    outline: none;
    text-decoration: none;
    vertical-align: baseline;
    float: none;
}

.series-item:hover .delete-series-btn {
    opacity: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.delete-series-btn:hover {
    background-color: #c82333;
    transform: scale(1.15);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.delete-series-btn:active {
    transform: scale(0.9);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Responsive design for charts */
@media (max-width: 768px) {
    .chart-container {
        width: 100%;
        padding: 15px;
        margin-bottom: 20px;
    }

    #reps-chart, #reps-per-minute-chart {
        height: 300px;
        max-height: 300px;
    }

    #reps-per-month-chart, #weekly-summary-chart {
        height: 250px;
        max-height: 250px;
    }

    #calendar {
        padding: 15px;
        min-height: 150px;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .legend-items {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 8px;
    }

    .legend-item {
        font-size: 12px;
        padding: 4px 6px;
    }

    .legend-color {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 480px) {
    .chart-container {
        padding: 10px;
    }

    #reps-chart, #reps-per-minute-chart {
        height: 250px;
        max-height: 250px;
    }

    #reps-per-month-chart, #weekly-summary-chart {
        height: 200px;
        max-height: 200px;
    }

    .legend-items {
        grid-template-columns: 1fr 1fr;
    }
}

/* Exercise Management Styles */
.exercise-management {
    margin-bottom: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.exercise-management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    cursor: pointer;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.exercise-management-header:hover {
    background-color: #e9ecef;
}

.exercise-management-header h3 {
    margin: 0;
    color: #36454f;
    font-size: 18px;
    font-weight: 600;
}

.exercise-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #6c757d;
}

.exercise-count {
    font-weight: 500;
}

.toggle-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: #36454f;
}

.exercise-management.collapsed .toggle-arrow {
    transform: rotate(-90deg);
}

.exercise-management-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 15px;
}

.exercise-management.collapsed .exercise-management-content {
    max-height: 0;
    padding: 0 15px;
}

.exercise-management-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.add-exercise-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.add-exercise-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.add-exercise-form input[type="text"]:focus {
    outline: none;
    border-color: #36454f;
    box-shadow: 0 0 0 2px rgba(54, 69, 79, 0.1);
}

.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.exercise-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: #36454f;
}

.reset-btn {
    background-color: #ff6b6b !important;
    color: white !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
    margin: 0 !important;
}

.reset-btn:hover {
    background-color: #ff5252 !important;
}

.exercise-types-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #fafafa;
}

.exercise-type-item {
    display: flex;
    align-items: center;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.exercise-type-name {
    margin-right: 8px;
    color: #333;
}

.delete-exercise-btn {
    background-color: #ff4757 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 20px !important;
    height: 20px !important;
    font-size: 12px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    line-height: 1;
}

.delete-exercise-btn:hover {
    background-color: #ff3742 !important;
}

.delete-exercise-btn:before {
    content: "×";
    font-weight: bold;
}

/* Responsive adjustments for exercise management */
@media (max-width: 768px) {
    .exercise-management-header {
        padding: 12px;
    }
    
    .exercise-management-header h3 {
        font-size: 16px;
    }
    
    .exercise-summary {
        font-size: 13px;
    }
    
    .exercise-management-content {
        padding: 12px;
    }
    
    .exercise-management.collapsed .exercise-management-content {
        padding: 0 12px;
    }
    
    .exercise-management-controls {
        gap: 10px;
    }
    
    .add-exercise-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .add-exercise-form input[type="text"] {
        min-width: auto;
    }
    
    .exercise-list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .exercise-types-container {
        max-height: 150px;
    }
}