/* =======================
   1. CSS Reset
   ======================= */
/* Remove default browser styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =======================
   2. Base Styles
   ======================= */
/* Set base font and background */
body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Hide specific message span */
span#ltme-message {
    display: none;
}

/* =======================
   3. Header Styling
   ======================= */
.main-header {
    background-color: #343a40;
    color: #fff;
    padding: 20px 10%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.main-header h1 {
    font-size: 24px;
}

/* Read-me Link Styling */
.read-me {
    color: #ffffff; /* White text */
    text-decoration: underline;
    text-decoration-color: orange; /* Underline color set to orange */
    font-size: 16px;
    transition: color 0.3s ease; /* Smooth transition for color change */
}

.read-me:hover {
    color: #FFA07A; /* Light orange color on hover */
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.header-controls label {
    font-size: 14px;
    margin-right: 5px;
}

.header-controls select,
.header-controls input[type='checkbox'] {
    padding: 5px;
    font-size: 14px;
}

/* =======================
   4. Checkboxes Row Styling
   ======================= */
.checkboxes-row {
    display: flex;
    justify-content: space-between;
    padding: 20px 20px;
    gap: 20px; /* Adjust spacing between cell and marker checkboxes */
    flex-direction: column;
}

.checkbox-container {
    flex: 1; /* Each checkbox container takes equal width */
}

/* Marker and Cell Checkboxes Containers */
#marker-checkboxes-container,
#cell-checkboxes-container {
    display: grid;
    grid-template-columns: auto 1fr; /* Two columns: buttons and checkboxes */
    grid-gap: 0px; /* Spacing between grid items */
    align-items: start; /* Align items to the top */
}

/* Select Controls Styling */
.select-controls {
    grid-column: 1 / 2; /* Place in the first column */
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 3px;
}

.select-controls button {
    padding: 4px 8px; /* Smaller padding for small buttons */
    font-size: 12px; /* Smaller font size */
    border: none;
    border-radius: 3px;
    background-color: #007BFF; /* Blue background */
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.select-controls button:hover {
    background-color: #0056b3; /* Darker blue on hover */
}

.select-controls button:focus {
    outline: 2px solid #0056b3; /* Blue outline on focus */
}

/* Marker Checkboxes Styling */
#marker-checkboxes,
#cell-checkboxes {
    grid-column: 2 / 3; /* Place in the second column */
    display: flex;
    flex-wrap: wrap;
    gap: 2px; /* Spacing between checkboxes */
    margin-left: 5px;
}

#marker-checkboxes label,
#cell-checkboxes label {
    display: flex;
    align-items: center;
    font-size: 11px; /* Smaller font size */
    cursor: pointer;
}

#marker-checkboxes input[type='checkbox'],
#cell-checkboxes input[type='checkbox'] {
    margin-right: 5px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* =======================
   5. Image and Legend Container Styling
   ======================= */
.image-legend-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 20px;
    gap: 20px; /* Spacing between image and legend */
}

.image-container {
    position: relative;
    flex: 1; /* Takes up remaining horizontal space */
    background-color: #f5f5f5;
    border-radius: 4px;
    overflow: hidden;
    min-height: 500px;
}

.image-container canvas {
    width: 100%;
    height: auto;
    display: block;
}

.overlay-canvas,
.cell-overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%; /* Ensure the canvas covers the entire image */
    height: 100%; /* Ensure the canvas covers the entire image */
    cursor: pointer;
}

.overlay-canvas {
    z-index: 10; /* Higher z-index to sit above cell overlays */
}

.cell-overlay-canvas {
    z-index: 9; /* Below overlay-canvas but above base-canvas */
}

.loading-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-bar {
    width: 50%;
    height: 8px;
    background-color: #007BFF;
    border-radius: 4px;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        width: 0%;
        opacity: 0.7;
    }
    50% {
        width: 50%;
        opacity: 1;
    }
    100% {
        width: 100%;
        opacity: 0.7;
    }
}

/* Legend Container */
.ltme-legend-container {
    width: 100px; /* Fixed width for the legend */
    display: flex;
    align-items: center;
    justify-content: center;
}

.ltme-legend {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Spacing between legend items */
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #333;
}

.legend-color-box {
    width: 20px;
    height: 20px;
    border: 1px solid #000;
    border-radius: 3px;
}

.legend-item:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease-in-out;
}

/* =======================
   6. Plots Row Styling
   ======================= */
.plots-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.plot-container {
    flex: 1; /* Each plot takes equal space */
    border-radius: 4px;
    min-height: 400px;
}

/* =======================
   7. Notification Styling
   ======================= */
.notification-container {
    z-index: 1000; /* Ensure it appears above other elements */
    font-family: Arial, sans-serif;
    font-size: 14px;
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #28a745;
    color: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    display: none; /* Hidden by default */
    font-weight: bold;
}

.notification-container[style*="display: block"] {
    /* Additional styles when visible */
    transition: opacity 0.5s ease-in-out;
}

/* =======================
   8. Patient Information Section
   ======================= */
.patient-info-row {
    padding: 10px 20px 0 20px;
}

.patient-info table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.patient-info th,
.patient-info td {
    border: 1px solid #ddd;
    padding: 4px 8px;
    text-align: left;
    font-size: 12px;
}

.patient-info th {
    background-color: #f2f2f2; /* Distinct background for headers */
    font-weight: bold;
}

/* Responsive Design: Patient Info Table */
@media screen and (max-width: 768px) {
    .patient-info table, 
    .patient-info thead, 
    .patient-info tbody, 
    .patient-info th, 
    .patient-info td, 
    .patient-info tr {
        display: block;
    }

    /* Hide the header row */
    .patient-info thead {
        display: none;
    }

    /* Each data row becomes a separate block */
    .patient-info tbody tr {
        margin-bottom: 15px;
    }

    /* Style each cell */
    .patient-info tbody td {
        position: relative;
        padding-left: 50%;
        padding-right: 10px;
        text-align: right;
        border: none;
        border-bottom: 1px solid #ddd;
        font-size: 14px; /* Optional: Adjust font size */
    }

    /* Add labels before each data cell */
    .patient-info tbody td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-left: 15px;
        font-weight: bold;
        text-align: left;
    }
}

/* =======================
   9. Responsive Design
   ======================= */
/* Tablet and Small Screens */
@media (max-width: 1024px) {
    .plots-row {
        flex-direction: column;
    }

    .plots-row .plot-container {
        width: 100%;
    }

    .checkboxes-row {
        flex-direction: column;
        gap: 20px;
    }

    .checkbox-container {
        width: 100%;
    }
}

/* Mobile View */
@media (max-width: 768px) {
    .header-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    #ltme-legend {
        flex-direction: row;
    }

    #checkboxes-row {
        padding: 10px 10px;
    }

    .image-legend-row {
        flex-direction: column;
        align-items: center;
    }

    .image-container {
        width: 100%;
        min-height: 300px;
    }

    .ltme-legend-container {
        width: 100%;
        margin-top: 10px;
    }

    .plots-row {
        flex-direction: column;
    }

    .plots-row .plot-container {
        width: 100%;
    }

    .checkboxes-row {
        flex-direction: column;
        gap: 20px;
    }

    .checkbox-container {
        width: 100%;
    }
}

/* =======================
   10. Accessibility Enhancements
   ======================= */
/* Focus Styles for Select Controls */
.select-controls button:focus {
    outline: 2px solid #0056b3; /* Blue outline on focus */
}

/* Focus Styles for Checkbox Labels */
.ltme-toggle-label input[type='checkbox']:focus + span {
    outline: 2px solid #0056b3;
}

/* Highlighted Legend Items */
.legend-item span.highlighted {
    font-weight: 900; /* Bold text */
    color: #FFD700;    /* Dark Yellow (Gold) */
} 

/* =======================
   11. Legend Container Styling
   ======================= */
/* B-Cell Legend */
.b-cell-legend {
    display: flex;
    gap: 20px; /* Space between legend items */
    align-items: center;
    font-size: 11px;
    justify-content: center;
    display: none;
}

.b-cell-legend-item {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between color box and label */
}

/* Solid B Cells Box */
.solid-bcells {
    width: 20px;
    height: 6px;
    background-color: #ffbb78;
    border: 1px solid #ffbb78;
    box-sizing: border-box;
}

/* Striped B-Cells for Cluster 0 */
.striped-blue {
    width: 20px;
    height: 6px;
    background-color: #ffbb78; /* Base color */
    background: repeating-linear-gradient(
        45deg,
        blue,
        blue 2px,
        #ffbb78 2px,
        #ffbb78 4px
    );
    border: 1px solid blue;
    box-sizing: border-box;
}

/* Striped B-Cells for Cluster 1 */
.striped-red {
    width: 20px;
    height: 6px;
    background-color: #ffbb78; /* Base color */
    background: repeating-linear-gradient(
        45deg,
        red,
        red 2px,
        #ffbb78 2px,
        #ffbb78 4px
    );
    border: 1px solid red;
    box-sizing: border-box;
}

/* =======================
   12. Modal Styles
   ======================= */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.5); /* Black with opacity */
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% from the top and centered */
    padding: 20px 40px;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    font-size: 14px;
}

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

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* Modal Content Specific Styles */
.modal-content h2,
.modal-content li {
    margin-bottom: 10px;
}
