/* General styles */
body {
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 0;
    background-color: #f4f7fc;
}

.container {
    max-width: 90%;
    margin: 20px auto;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
}

/* Headings */
h2 {
    color: #0056b3;
}

/* Inputs & Select */
input, select, button {
    width: 33%;
    padding: 10px;
    margin: 8px auto;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    display: block;
}

.input-group, .location-date-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.input-group input, .location-date-group select, .location-date-group input {
    flex: 1;
    min-width: 48%;
    max-width: 48%;
}

/* Buttons */
button {
    background-color: #0056b3;
    color: white;
    font-weight: bold;
    cursor: pointer;
    padding: 10px 12px;
    border: none;
    border-radius: 5px;
    width: auto;
}

button:hover {
    background-color: #003f80;
}

button:active {
    background-color: #002d66;
}

.remove-btn {
    background-color: red;
    color: white;
    font-weight: bold;
}

.primary-btn {
    padding: 10px 20px;
    font-size: 14px;
}

/* Table styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: #fff;
}

th, td {
    border: 1px solid #ccc;
    padding: 10px;
    text-align: left;
    width: 25%;
    box-sizing: border-box;
}

th {
    background-color: #0056b3;
    color: white;
}

.exercise-table {
    margin-top: 10px;
    border: 1px solid #ccc;
}

/* Exercise Selection */
#exercise-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.exercise-box {
    padding: 10px 20px;
    background-color: #e6e6e6;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    display: inline-block;
    text-align: center;
    width: 200px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

.exercise-box.selected {
    background-color: #0056b3;
    color: white;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
}

.modal.show {
    display: flex;
}

.trainee-option {
    padding: 10px;
    margin: 5px 0;
    background-color: #f1f1f1;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
}

.trainee-option:hover {
    background-color: #ddd;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
}

/* Training Plan Selection */
.plan-name {
    width: 80%;
    max-width: 400px;
    padding: 10px;
    margin: 10px auto;
    display: block;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
}

.plan-location {
    width: 80%;
    max-width: 400px;
    padding: 10px;
    margin: 10px auto;
    display: block;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
}

#exercises p {
    background: #e6f0ff;
    padding: 8px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

#results {
    display: none;
    background: #f1f1f1;
    padding: 8px;
    margin: 8px 0;
    border-radius: 5px;
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    cursor: pointer;
    font-size: 24px;
    background: none;
    border: none;
    padding: 10px;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
        position: absolute;
        top: 15px;
        right: 15px;
    }

    .navigation {
        display: none;
        flex-direction: column;
        width: 100%;
        background: #333;
        position: absolute;
        top: 50px;
        left: 0;
        z-index: 999;
    }

    .navigation.open {
        display: flex;
    }

    .navigation a {
        padding: 15px;
        color: white;
        text-align: center;
        border-bottom: 1px solid white;
    }
}

/* Saved Exercises Section */
.saved-entry {
    margin-top: 5px;
    padding: 8px;
    background: #d4edda;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.saved-entry button {
    background: red;
    color: white;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 5px;
}

/* Style for the main headline */
#training-headline {
    font-size: 24px; /* Match the select training plan font */
    font-weight: bold;
    text-align: center;
    margin-top: 30px; /* 30px under header */
}

/* Style for trainee name display */
#trainee-container {
    font-size: 24px; /* Match the select training plan font */
    font-weight: bold;
    text-align: center;
    margin-top: 50px; /* 50px under header */
}

#trainees-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* Ensures 10px space between trainee boxes */
    justify-content: center; /* Centers the boxes */
    align-items: center; /* Aligns them properly */
    padding-top: 50px !important; /* Increases space above "Select Trainees" */
}

#training-history {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 200px; /* Ensure it's visible initially */
    padding: 20px;
    overflow: visible; /* Allow content to expand */
    transition: max-height 0.3s ease-in-out;
    max-height: none; /* Remove height constraint */
}

#training-history.active, #training-history.expanded {
    max-height: none; /* Allow it to grow dynamically */
    overflow: visible;
}

#training-plan-select {
    color: black !important; /* Ensures text is visible */
    background-color: white !important; /* Ensures proper contrast */
    font-size: 16px;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #ccc;
}

#training-plan-select option {
    color: black !important; /* Ensures options have visible text */
    background-color: white !important;
}

.expanded {
    max-height: none !important; /* Allow full expansion when content loads */
    overflow: visible;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(200px, 1fr)); /* Ensure two charts per row on desktop */
    gap: 20px; /* Space between charts */
    justify-content: center;
    align-items: start;
    margin-top: 20px;
    width: 100%;
}

.charts-container canvas {
    width: 100%;
    max-width: 600px;
    height: 150px; /* 50% lower height on desktop */
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .charts-container canvas {
        width: 100%;
        height: 800px; /* Keeps 4x taller height on mobile */
    }
}

.plan-selection-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.plan-box {
    padding: 12px 16px;
    font-size: 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.plan-box:hover {
    background-color: #0056b3;
}

/* Ensure 2 charts per row on desktops */
@media (max-width: 768px) {
    .charts-container canvas {
        width: 100%; /* Full width for mobile */
    }
}

.select-style {
    width: 80%;
    max-width: 400px;
    padding: 10px;
    margin: 10px auto;
    display: block;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
    background-color: #fff;
    cursor: pointer;
    appearance: none; /* Removes default styling */
    
    /* Custom arrow */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="%23666"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 30px; /* Space for the arrow */
}

.date-picker-style {
    width: 80%;
    max-width: 400px;
    padding: 10px;
    margin: 10px auto;
    display: block;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
    background-color: #fff;
    cursor: pointer;
    appearance: none; /* Removes default styling on some browsers */
}

/* General container styles */
.plan-container, .trainee-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; /* Adds 20px spacing between boxes */
    align-items: center;
    margin-top: 15px;
    margin-bottom: 30px;
}

.training-box {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border: 2px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: inline-block; /* Ensures boxes stay inline */
}

#training-plan-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* Ensures 10px space between boxes */
    justify-content: center; /* Centers boxes in the container */
    margin-bottom: 30px; /* Ensures 30px space below the selected plan */
}

.trainee-box {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border: 2px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: inline-flex; /* Keeps them in a row */
    justify-content: center;
    align-items: center;
    min-width: 120px; /* Ensures consistent size */
    text-align: center;
    margin: 5px; /* Removes default margin */
}

/* Hover effect */
.training-box:hover, .trainee-box:hover {
    background-color: #002d66; /* Light Blue on hover */
    color: white;
}

/* Selected state */
.training-box.selected, .trainee-box.selected {
    background-color: #0056b3; /* Dark Blue when selected */
    color: white;
    border: 2px solid #000080;
}

/* Comparison Charts Container - Force two per row layout */
.comparison-charts-container {
    display: flex !important; /* Force flex display */
    flex-wrap: wrap !important; /* Force wrap */
    gap: 30px;
    margin-top: 30px;
    width: 100%;
    justify-content: space-between !important; /* Force space between */
}

/* Chart wrapper styling for comparison charts */
.comparison-chart-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 50px; /* Increased margin between rows */
    /* Maintain 1:1 ratio using padding-bottom trick */
    padding-bottom: 100%; /* 1:1 = 100% */
    height: 0;
    box-sizing: border-box; /* Include padding in width calculation */
}

.comparison-chart-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 4px;
    background-color: white;
}

/* Responsive settings for comparison charts */
@media (min-width: 768px) {
    .comparison-chart-wrapper {
        width: calc(50% - 15px) !important; /* Exactly 50% minus half the gap */
        padding-bottom: calc(50% - 15px) !important; /* Match width for 1:1 ratio */
        max-width: calc(50% - 15px) !important; /* Add max-width constraint */
        flex: 0 0 calc(50% - 15px) !important; /* Don't grow or shrink */
        float: left; /* Fallback if flex doesn't work */
    }
    
    /* Clear every 2nd item for fallback float layout */
    .comparison-chart-wrapper:nth-child(2n+1) {
        clear: left;
    }
}

/* 🔹 Enable horizontal scrolling for tables */
.table-container {
    width: 100%;
    overflow-x: auto; /* ✅ Enables sideways scrolling */
    -webkit-overflow-scrolling: touch; /* ✅ Smooth scrolling on mobile */
}

/* 🔹 Ensure tables have a minimum width */
.table-container table {
    width: 100%;
    min-width: 600px; /* ✅ Prevents excessive compression */
    border-collapse: collapse;
}

/* 🔹 Prevent table content from wrapping */
.table-container th,
.table-container td {
    white-space: nowrap; /* ✅ Ensures text stays on a single line */
    padding: 10px;
    text-align: left;
}

/* ✅ Remove the blue line and style the accordion */
.accordion-item {
    box-shadow: none;
    border-bottom: 1px solid #ccc;
    margin-bottom: 10px;
    background: white; /* Light grey background */
    border-radius: 5px;
}

/* ✅ Style the accordion button */
.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: white;
    color: black; /* ✅ Ensure text is black */
    font-size: 18px;
    font-weight: bold;
    padding: 15px;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    text-align: left;
    border-radius: 5px;
}

/* ✅ Remove any blue borders */
.accordion-header:hover {
    background: #f0f0f0;
}

/* ✅ Ensure the accordion icon is styled properly */
.accordion-icon {
    font-size: 20px;
    font-weight: bold;
    transition: transform 0.3s;
}

/* ✅ Style the accordion content */
.accordion-content {
    display: none;
    padding: 15px;
    background: white;
    color: black; /* ✅ Ensure text remains black */
}

/* ✅ Make content visible when active */
.accordion-content.active {
    display: block;
}

/* ✅ Style the delete button */
.delete-prediction-btn {
    background: #d9534f;
    color: white;
    padding: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.delete-prediction-btn:hover {
    background: #c9302c;
}

/* PWA-specific styles */
body.pwa-mode {
    /* Keep normal padding for the navigation bar but optimize for fullscreen */
    background-color: #f4f7fc; /* Ensure background color extends fully */
    min-height: 100vh; /* Ensure full viewport height coverage */
    position: fixed; /* Prevent bounce effects on iOS */
    width: 100%;
    overflow: auto;
}

/* Use 100% of viewport height in PWA mode */
body.pwa-mode .container {
    box-sizing: border-box; /* Include padding in size calculation */
}

/* Ensure content doesn't get hidden under notches or home indicators */
@supports (padding: max(0px)) {
    body.pwa-mode {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* When in PWA mode, adjust container spacing */
body.pwa-mode .container:first-of-type {
    margin-top: 20px !important; /* Gives some breathing room at the top */
}

/* For any page-specific headers that might look odd without nav */
body.pwa-mode h1:first-of-type {
    margin-top: 10px !important;
}
