body {
    font-family: sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.container {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    width: 80%;
    max-width: 900px;
}

h1 {
    text-align: center;
    color: #333;
}

.input-section {
    margin-bottom: 2rem;
}


.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

#prompt-counter {
    font-size: 0.9rem;
    color: #6c757d;
}

textarea {
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #ccc;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    box-sizing: border-box; /* Ensures padding doesn't affect width */
}

.controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.control-group label {
    margin-bottom: 0.25rem;
    color: #555;
}

.control-group input,
.control-group select {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

.main-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

#generate-btn, #save-all-btn {
    flex-grow: 1;
    padding: 0.75rem;
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

#generate-btn {
    background-color: #007bff;
}

#generate-btn:hover {
    background-color: #0056b3;
}

#save-all-btn {
    background-color: #6c757d;
}

#save-all-btn:hover {
    background-color: #5a6268;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(256px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.image-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

.image-gallery img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.edit-container {
    display: none; /* Hidden by default */
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}


.retry-btn {
    margin-top: 10px;
    padding: 8px 12px;
    border: none;
    background-color: #ffc107; /* A warning/retry color */
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.retry-btn:hover {
    background-color: #e0a800;
}

.error-actions {
    display: flex;
    gap: 10px; /* Spacing between buttons */
    margin-top: 10px;
}

.edit-error-btn, .update-error-btn {
    padding: 8px 12px;
    border: none;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.edit-error-btn {
    background-color: #17a2b8; /* Info color */
}

.edit-error-btn:hover {
    background-color: #138496;
}

.update-error-btn {
    background-color: #28a745; /* Success color */
}

.update-error-btn:hover {
    background-color: #218838;
}

.placeholder.error .edit-container {
    margin-top: 10px;
    width: 100%;
}

.edit-container input {
    flex-grow: 1;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.edit-container button {
    padding: 0.5rem 0.75rem;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}



.button-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.regenerate-btn {
    flex-grow: 1;
    padding: 0.5rem;
    border: none;
    background-color: #ffc107;
    color: #212529;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.regenerate-btn:hover {
    background-color: #e0a800;
}

.save-btn {
    flex-grow: 1;
    padding: 0.5rem;
    border: none;
    background-color: #28a745;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background-color 0.2s;
}

.save-btn:hover {
    background-color: #218838;
}

.view-btn {
    flex-grow: 1;
    padding: 0.5rem;
    border: none;
    background-color: #17a2b8;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.view-btn:hover {
    background-color: #138496;
}

.edit-btn {
    flex-grow: 1;
    padding: 0.5rem;
    border: none;
    background-color: #fd7e14;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.edit-btn:hover {
    background-color: #e36d0a;
}


/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    padding-top: 60px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
}

.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 1200px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
}

.close-modal:hover,
.close-modal:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

.placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    aspect-ratio: 1024 / 1792; /* Match image aspect ratio */
    background-color: #e9ecef;
    border-radius: 4px;
    flex-direction: column;
    gap: 1rem;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #007bff;
    animation: spin 1s ease infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.placeholder.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.placeholder.error .error-icon {
    font-size: 2rem;
    font-weight: bold;
}

.placeholder.error span {
    font-size: 0.9rem;
}