/* Form base styles */
#ai-image-form {
    margin-bottom: 20px;
}

/* Form Controls Grid */
.form-controls-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1rem 0;
}

.form-control-item {
    width: 100%;
}

.form-control-item label {
    display: block;
    margin-bottom: 0.5rem;
}

.form-control-item select,
.form-control-item input {
    width: 100%;
}

/* Form Elements */
#ai-image-form input,
#ai-image-form textarea,
#ai-image-form select,
#ai-image-form button {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

#ai-image-form button {
    background-color: #046BD2;
    color: white;
    border: none;
    padding: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#ai-image-form button:hover {
    background-color: #0354A0; /* Darker shade for hover */
}

#ai-image-form button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Image Grid */
#image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px;
    margin-top: 20px;
    max-height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.image-item {
    position: relative;
    width: 100%;
    background-color: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
}

.image-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Overlay and Loader */
.image-item .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

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

/* Upload Box Styles */
.upload-box {
    position: relative;
    width: 100%;
    min-height: 210px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    margin: 20px 0;
    transition: all 0.3s ease;
    background: #f9f9f9;
    cursor: pointer;
    overflow: hidden;
}

.upload-box:hover,
.upload-box.dragover {
    border-color: #2196f3;
    background: #e3f2fd;
}

.upload-box input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.upload-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
    padding: 20px;
    z-index: 1;
}

.upload-content svg {
    color: #666;
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

.upload-box:hover .upload-content svg {
    color: #2196f3;
}

.upload-content h3 {
    margin: 0 0 10px;
    color: #333;
    font-size: 18px;
    font-weight: 500;
}

.upload-content p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

#image-thumbnail {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 180px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

/* Lightbox styles */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.close-lightbox {
    position: absolute;
    right: 25px;
    top: 15px;
    color: #f1f1f1;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
}

/* Lightbox Navigation */
.prev-image,
.next-image {
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 16px;
    color: white;
    font-weight: bold;
    font-size: 20px;
    transition: 0.6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    -webkit-user-select: none;
}

.next-image {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.prev-image {
    left: 0;
}

.prev-image:hover,
.next-image:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Image Actions */
.image-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.image-item:hover .image-actions {
    opacity: 1;
}

.image-actions .copy-icon,
.image-actions .download-icon {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    padding: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.image-actions .copy-icon:hover,
.image-actions .download-icon:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.image-actions svg {
    display: block;
    width: 20px;
    height: 20px;
    color: #333;
}


/* Responsive Styles */
@media screen and (max-width: 768px) {
    .form-controls-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    /* Make size selector take full width */
    .form-control-item:last-child {
        grid-column: 1 / -1;
    }

    #image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .upload-box {
        min-height: 210px;
    }

    .upload-content h3 {
        font-size: 16px;
    }

    .upload-content p {
        font-size: 12px;
    }
}

@media screen and (max-width: 480px) {
    .upload-box {
        min-height: 210px;
    }

    .upload-content svg {
        width: 32px;
        height: 32px;
    }

    .upload-content h3 {
        font-size: 14px;
        margin-bottom: 5px;
    }

    .upload-content p {
        font-size: 12px;
    }

    .lightbox-content {
        max-width: 95%;
    }

    .close-lightbox {
        right: 15px;
        top: 10px;
        font-size: 28px;
    }
}