/* public/style.css */
body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: #f4f7f6;
    color: #333;
}
.container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 30px;
}
label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}
input[type="text"],
input[type="number"],
input[type="file"], /* Added for file input */
textarea,
select { /* Added for select if any other dropdowns were reintroduced */
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box; /* Ensures padding doesn't increase width */
}
textarea {
    resize: vertical;
    min-height: 80px;
}
button {
    background-color: #007bff;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    transition: background-color 0.3s ease;
    width: 100%;
}
button:hover {
    background-color: #0056b3;
}
button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}
.image-output {
    margin-top: 30px;
    text-align: center;
    border-top: 1px solid #eee;
    padding-top: 30px;
}

/* Updated styles for displaying multiple images */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Adjust minmax as needed */
    gap: 20px;
    justify-items: center;
    align-items: start;
    margin-top: 20px;
}
.image-grid .generated-image-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 10px;
    background-color: #f9f9f9;
    text-align: center;
    width: 100%; /* Occupy full grid column width */
    box-sizing: border-box; /* Include padding/border in width */
}
.image-grid .generated-image-card img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 10px;
}
.image-grid .generated-image-card .model-name {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
    font-weight: bold;
}
.image-grid .generated-image-card .image-status {
    font-size: 0.8em;
    color: #888;
}
.image-grid .generated-image-card .image-status.error {
    color: red;
}
.placeholder-text {
    color: #888;
    font-style: italic;
    grid-column: 1 / -1; /* Make placeholder span all columns */
}


.status-message {
    margin-top: 15px;
    text-align: center;
    font-size: 1.1em;
    color: #666;
}
.error {
    color: red;
    font-weight: bold;
}
.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
    display: none; /* Hidden by default */
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.form-grid > div {
    display: flex;
    flex-direction: column;
}
.full-width {
    grid-column: span 2;
}

/* New: Model selection grid for checkboxes */
.model-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 20px;
}
.model-selection-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal; /* Override default label bold */
    margin-bottom: 0;
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background-color: #fcfcfc;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.model-selection-grid label:hover {
    background-color: #f0f8ff;
    border-color: #a0c0ff;
}
.model-selection-grid input[type="checkbox"] {
    margin-bottom: 0; /* Remove default margin for inputs in labels */
    width: auto; /* Allow checkbox to take natural width */
}
.model-selection-grid input[type="checkbox"]:checked + span { /* If using a span next to checkbox */
    font-weight: bold;
    color: #007bff;
}

/* Optional sections (image upload, strength) */
.optional-section {
    display: none; /* Hidden by default, shown by JS */
}

/* Image preview styles */
.image-preview-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center items horizontally */
    gap: 10px;
}
.image-preview-container img {
    max-width: 256px; /* Max size for preview */
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: block; /* Ensures img takes full width for centering */
}
.image-preview-container .clear-button {
    background-color: #dc3545; /* Red color for clear button */
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    width: auto; /* Allow button to size naturally */
    display: none; /* Hidden by default */
}
.image-preview-container .clear-button:hover {
    background-color: #c82333;
}

.hint-text {
    font-size: 0.85em;
    color: #777;
    text-align: center;
    margin-top: -10px; /* Pull it up closer to the input */
    margin-bottom: 15px;
}


@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .model-selection-grid {
        grid-template-columns: 1fr;
    }
    .image-grid {
        grid-template-columns: 1fr;
    }
}

#maskDrawingSection button {
    background-color: #007bff;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 5px;
}

#maskDrawingSection button.active {
    background-color: #0056b3;
}

#maskCanvasContainer {
    position: relative;
    width: 100%;
    height: 512px; /* Fixed height for consistent drawing area */
    max-width: 512px;
    margin: 0 auto;
    border: 1px solid #ddd;
    background-color: #f0f0f0; /* Fallback background */
    overflow: hidden;
}

/* Add this new style */
#maskCanvasContainer canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%; /* Ensure canvas fills container */
    height: 100%;
    object-fit: contain; /* Maintain aspect ratio */
}