body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px;
    background-color: #f4f4f4;
}

h1, h2 {
    color: #333;
}

.controls-main {
    display: flex;
    flex-direction: row;
    gap: 20px;
    margin-bottom: 20px;
    width: 90%;
    max-width: 1200px;
    justify-content: space-between;
}

.plate-selector-container {
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#groups-management-container {
    flex-grow: 1;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-height: 250px; /* Ensure space for groups */
}

#groups-display-area {
    margin-top: 10px;
    max-height: 250px; /* Limit height for the row of groups */
    display: flex;
    flex-direction: row;
    overflow-x: auto; /* Allow horizontal scrolling for groups */
    overflow-y: hidden; /* Hide vertical scrollbar for the container itself */
    padding-bottom: 5px; /* Space for horizontal scrollbar if it appears */
}


#plate-and-info-container {
    display: flex;
    flex-direction: row;
    gap: 20px;
    width: 90%;
    max-width: 1200px;
    align-items: flex-start; /* Align items to the top */
}

#plate-container {
    display: grid;
    grid-template-columns: repeat(12, 35px); /* 12 columns */
    grid-template-rows: repeat(8, 35px);    /* 8 rows */
    gap: 1px;
    border: 1px solid #666;
    background-color: #ddd;
    padding: 2px; /* Small padding for visual separation */
    position: relative; /* For selection rectangle */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.well {
    width: 35px;
    height: 35px;
    background-color: white;
    border: 1px solid #bbb;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 9px;
    color: #555;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}

.well:hover {
    border-color: #007bff;
}

.well.selected-for-drag {
    outline: 2px dashed rgba(0, 100, 255, 0.7); /* Temporary highlight during drag */
    outline-offset: -2px;
}

#current-selection-info {
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 200px; /* Ensure it has some width */
}

#current-selection-info p {
    margin: 5px 0;
    font-size: 0.9em;
}

.group {
    border: 1px solid #ddd;
    padding: 10px;
    margin: 0 10px 0 0; /* Top, Right, Bottom, Left margins */
    border-radius: 5px;
    background-color: #f9f9f9;
    min-width: 220px; /* Minimum width for each group */
    max-height: 100%; /* Occupy available height within #groups-display-area */
    display: flex;
    flex-direction: column; /* Stack header, button, conditions list vertically */
    flex-shrink: 0; /* Prevent groups from shrinking when space is tight */
}

.group h3 {
    margin-top: 0;
    font-size: 1.1em;
    color: #555;
}

.conditions-list {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap; /* Allow conditions to wrap */
    gap: 5px; /* Spacing between condition buttons */
    overflow-y: auto; /* Allow vertical scrolling for conditions within a group */
    flex-grow: 1; /* Allow this list to take available vertical space */
}

.condition {
    padding: 6px 10px;
    margin: 3px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    display: flex; /* To align name and delete button */
    justify-content: space-between; /* Puts name and delete button on opposite ends */
    align-items: center; /* Vertically aligns them */
}

.condition .condition-name {
    flex-grow: 1; /* Allows name to take available space */
    margin-right: 5px; /* Space before delete button */
}

.delete-condition-btn {
    padding: 0 5px;
    margin-left: 5px;
    border-radius: 3px;
    font-weight: bold;
    color: #721c24; /* Dark red */
    background-color: transparent;
    border: 1px solid transparent; /* For consistent sizing */
    line-height: 1; /* Ensure it doesn't take too much vertical space */
}

.delete-condition-btn:hover {
    color: white;
    background-color: #dc3545; /* Red background on hover */
    border-color: #dc3545;
}


.condition:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.condition.selected {
    font-weight: bold;
    border-width: 2px;
    border-color: #0056b3; /* Darker blue for selected */
    box-shadow: 0 0 5px rgba(0, 86, 179, 0.5);
}

button {
    padding: 8px 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

.export-section {
    margin-top: 20px;
    padding: 15px;
    width: 90%;
    max-width: 1200px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#export-output { /* This ID is no longer used for the main output, but keeping styles in case it's reused elsewhere or for reference */
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    background-color: #e9ecef;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 250px;
    overflow-y: auto;
    border-radius: 4px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.85em;
}

#per-group-export-area {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.group-export-item {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.group-export-item h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1em;
    color: #333;
}

.group-export-content {
    padding: 8px;
    border: 1px solid #ddd;
    background-color: #e9ecef;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 150px;
    overflow-y: auto;
    border-radius: 4px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.85em;
    margin-bottom: 8px;
}

.copy-to-clipboard-btn {
    padding: 6px 10px;
    font-size: 0.8em;
    background-color: #28a745; /* Green */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.copy-to-clipboard-btn:hover {
    background-color: #218838; /* Darker green */
}

#selection-rectangle {
    position: absolute;
    border: 1px dashed #007bff;
    background-color: rgba(0, 123, 255, 0.15);
    pointer-events: none; 
    z-index: 10;
}
