/* Cloning Studio Styles */
.cloning-studio-container {
    padding: 20px;
}

.studio-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--card-bg);
    border-radius: 8px;
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    min-width: 150px; /* Minimum width for each control group */
}

.control-group label {
    margin-bottom: 5px;
    font-size: 0.9em;
    color: var(--text-color);
}

.control-group select,
.control-group input {
    min-width: 150px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.form-group-wide {
    width: 100%;
    margin-bottom: 15px;
}

.form-group-wide label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--text-color);
}

.form-group-wide .form-control {
    width: 100%;
    resize: vertical;
    min-height: 100px;
    overflow-y: hidden; /* Hide scrollbar */
    height: auto; /* Allow height to adjust automatically */
}

/* Ensure form groups are full width in prompt assembly */
.prompt-assembly .form-group-wide {
    width: 100%;
}

/* Ensure form groups are full width in set management */
.set-management .form-group-wide {
    width: 100%;
}

.studio-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 1200px) {
    .studio-content {
        grid-template-columns: 1fr;
    }

    .set-management, .prompt-assembly {
        min-height: auto;
    }
}

/* Adjustments for control groups on medium screens */
@media (max-width: 1200px) {
    .control-group {
        min-width: 130px;
    }
}

@media (max-width: 992px) {
    .form-row {
        flex-direction: column;
        gap: 15px;
    }

    .control-group {
        min-width: 120px;
    }

    .image-item {
        flex-direction: column;
        text-align: center;
    }

    .image-thumbnail {
        align-self: center;
    }

    .image-actions {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .studio-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .view-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .control-group {
        min-width: auto;
        width: 100%;
        max-width: 200px;
    }

    .character-settings,
    .request-settings {
        width: 100%;
        padding: 12px;
    }

    .image-item {
        flex-direction: row;
        align-items: flex-start;
        padding: 12px;
        min-height: auto;
        gap: 10px;
        width: 100%;
    }

    .image-thumbnail {
        width: 100px;
        height: 140px;
    }

    .image-details {
        height: 140px;
    }
}

@media (max-width: 576px) {
    .cloning-studio-container {
        padding: 10px;
    }

    .studio-controls {
        padding: 10px;
    }

    .view-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        width: 100%;
    }

    .set-management,
    .prompt-assembly {
        padding: 15px;
    }

    .image-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .image-actions button {
        width: 100%;
    }

    .image-item {
        flex-direction: column;
    }

    .image-thumbnail {
        align-self: center;
        width: 120px;
        height: 168px;
    }

    .image-details {
        height: auto;
    }
}

.set-management {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.prompt-assembly {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
}

.prompt-assembly > h2 {
    text-align: center;
    width: 100%;
    margin-top: 0;
    margin-bottom: 20px;
}

.common-prompts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.vertical-image-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
    width: 100%;
}

.image-item {
    display: flex;
    align-items: flex-start;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    min-height: 170px; /* Ensure consistent height */
    gap: 15px; /* Add space between elements */
    position: relative;
    max-width: 100%; /* Prevent container from becoming too wide */
    overflow: hidden; /* Contain any overflowing content */
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.image-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.image-thumbnail-container {
    width: 120px;
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    flex-shrink: 0; /* Prevent shrinking */
}

.image-thumbnail {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Cover the container while maintaining aspect ratio */
    display: block !important;
    box-sizing: border-box !important; /* Include padding and border in element's total width/height */
    min-width: 0 !important; /* Allow flex item to shrink below content size */
    min-height: 0 !important; /* Allow flex item to shrink below content size */
    max-width: 100% !important;
    max-height: 100% !important;
}

.image-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2px; /* Reduced gap between elements */
    min-width: 0; /* Allow flex item to shrink below content size */
    height: 170px; /* Match the image height */
}

.image-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: flex-start; /* Align buttons to the top */
    flex-wrap: wrap;
    margin-bottom: 2px; /* Minimal space between buttons and clothing input */
}

.use-clothing-container {
    display: flex;
    align-items: center;
    gap: 10px;
    align-self: flex-start; /* Align with the top of the buttons */
    margin-top: 0;
}

/* Switch styling for the use clothing toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.clothing-description-input {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text-color);
    resize: vertical;
    min-height: 65px; /* Increased height to align better with image */
    min-width: 150px; /* Minimum width to prevent collapsing */
    width: 100%; /* Take full width of remaining space */
    flex-shrink: 0; /* Prevent shrinking */
    overflow-y: hidden; /* Hide scrollbar */
    height: auto; /* Allow height to adjust automatically */
}

/* Fieldset styling for grouped form elements */
fieldset {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    background-color: var(--card-bg);
    width: 100%;
}

legend {
    font-weight: bold;
    color: var(--text-color);
    padding: 0 10px;
    background-color: var(--card-bg);
}

.results-section {
    margin-top: 20px;
    padding: 20px;
    background-color: var(--card-bg);
    border-radius: 8px;
}

.results-summary {
    margin-bottom: 15px;
}

.results-details .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

/* Button styling for disabled state */
.btn-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Specific styling for queued analyze buttons - reflects needs_analysis=true state */
.analyze-btn[data-status="queued"],
.analyze-btn-queued {
    background-color: #8B0000; /* Dark red color */
    color: white;
    border-color: #6B0000;
    opacity: 1; /* Override the disabled opacity for visual consistency */
}