body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
}

.controls {
    text-align: center;
    position: sticky;
    top: 0;
    background-color: #f4f4f4; 
    z-index: 200; 
    padding: 10px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    width: 100%;
    box-sizing: border-box; 
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.language-select {
    padding: 6px 12px;
    font-size: 0.9em;
    border: 2px solid #667eea;
    border-radius: 5px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.language-select:hover {
    border-color: #764ba2;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3);
}

.language-select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
}

.style-selector-container {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.style-selector-container.visible {
    display: block;
}

.style-selector-title {
    font-size: 1em;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
}

.style-select {
    width: 100%;
    max-width: 500px;
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #667eea;
    border-radius: 5px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.style-select:hover {
    border-color: #764ba2;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3);
}

.style-select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.5);
}

.gallery-title {
    font-size: 14px;
    text-align: center;
    margin: 0;
    color: #555;
    flex: 1;
}

@media (max-width: 768px) {
    .header-controls {
        flex-direction: column;
        text-align: center;
    }
    
    .gallery-title {
        font-size: 13px;
        order: 1;
    }
    
    .language-select {
        order: 2;
        width: auto;
    }
}

.api-key-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    transition: all 0.3s ease;
}

.api-key-section.hidden {
    display: none;
}

.api-key-input {
    flex: 1;
    min-width: 250px;
    padding: 8px 15px;
    font-size: 0.9em;
    border: 2px solid #ff9800;
    border-radius: 5px;
    background: #2a2a2a;
    color: white;
    font-family: monospace;
}

.api-key-input::placeholder {
    color: #888;
}

.api-key-input:focus {
    outline: none;
    border-color: #ffa726;
    box-shadow: 0 0 5px rgba(255, 152, 0, 0.5);
}

.btn-get-api-key {
    padding: 8px 20px;
    font-size: 0.9em;
    color: white;
    background-color: #4caf50;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.btn-get-api-key:hover {
    background-color: #45a049;
}

.btn-start-feed {
    padding: 10px 30px;
    font-size: 1em;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-start-feed:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-start-feed:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.feed-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.model-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.custom-prompt-container {
    display: none;
    max-width: 600px;
    margin: 15px auto 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.custom-prompt-container.visible {
    display: block !important;
}

.custom-prompt-container.hidden {
    display: none;
}

.custom-prompt-label {
    font-size: 0.9em;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    display: block;
}

.custom-prompt-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #667eea;
    border-radius: 5px;
    font-size: 0.9em;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.custom-prompt-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
}

.btn-toggle-prompt {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    background-color: #ff9800;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-toggle-prompt:hover {
    background-color: #f57c00;
}

.btn-toggle-prompt.auto-mode {
    background-color: #2196F3;
}

.btn-toggle-prompt.auto-mode:hover {
    background-color: #1976D2;
}

.btn-styles {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    background-color: #9c27b0;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-styles:hover {
    background-color: #7b1fa2;
}

.btn-styles.active {
    background-color: #4caf50;
}

.btn-styles.active:hover {
    background-color: #45a049;
}

.btn-styles:disabled,
.btn-toggle-prompt:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-api-key {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    background-color: #ff9800;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-api-key:hover {
    background-color: #f57c00;
}

.btn-api-key.active {
    background-color: #4caf50;
}

.btn-api-key.active:hover {
    background-color: #45a049;
}

.btn-api-key:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-model {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.btn-model:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-model.active {
    opacity: 1;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-model:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.btn-model.zimage {
    background-color: #e91e63;
}

.btn-model.zimage:hover:not(:disabled) {
    background-color: #c2185b;
}

.btn-model.flux {
    background-color: #2196F3;
}

.btn-model.flux:hover:not(:disabled) {
    background-color: #1976D2;
}

.btn-model.gptimage {
    background-color: #9c27b0;
}

.btn-model.gptimage:hover:not(:disabled) {
    background-color: #7b1fa2;
}

#btnToggleFeed {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    background-color: #dc3545; 
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-bottom: 0; 
}

#btnToggleFeed:hover {
    background-color: #c82333;
}

#btnToggleFeed.paused {
    background-color: #28a745; 
}
#btnToggleFeed.paused:hover {
    background-color: #1e7e34;
}

.container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 80px 5px 5px; 
}

.image {
    width: 23%;
    min-width: 150px;
    margin: 1%;
    padding: 8px;
    box-sizing: border-box;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.25s ease-in-out, box-shadow 0.25s ease-in-out;
    position: relative; 
}

.image:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.image img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    border-radius: 6px;
}

/* Estilos para el Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px 25px 25px 25px;
    border: none;
    width: auto;
    max-width: 700px;
    max-height: 95vh;
    text-align: center;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-image-container {
    position: relative;
    display: inline-block; 
    line-height: 0; 
    margin-bottom: 15px;
}

#modalImageContent {
    max-width: 100%;
    max-height: 60vh; 
    object-fit: contain;
    border-radius: 8px;
    cursor: pointer;
}


#modalPromptText {
    margin-top: 0;
    font-size: 0.9em;
    color: #444;
    line-height: 1.4;
    word-break: break-word;
    max-height: 15vh; 
    overflow-y: auto;
    padding: 8px 12px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 6px;
    width: 95%;
    box-sizing: border-box;
    margin-bottom: 15px;
}

.modal-actions {
    margin-top: 10px;
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
}

.modal-actions button {
    padding: 10px 18px;
    font-size: 0.9em;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.modal-actions button#btnOpenImageTab {
     background-color: #007bff;
}
.modal-actions button#btnOpenImageTab:hover {
    background-color: #0056b3;
}

.modal-actions button#btnDownloadImage {
    background-color: #28a745;
}
.modal-actions button#btnDownloadImage:hover {
    background-color: #1e7e34;
}


@media (max-width: 768px) {
    .image {
        width: 46%;
    }
    #modalPromptText {
        font-size: 0.85em;
        max-height: 12vh;
    }
    .modal-actions button {
        padding: 8px 15px;
        font-size: 0.85em;
    }
     #modalImageContent {
        max-height: 55vh;
    }
    .api-key-section {
        flex-direction: column;
        padding: 8px;
    }
    .api-key-input {
        min-width: 100%;
        width: 100%;
    }
    .custom-prompt-container {
        margin: 10px;
        padding: 10px;
    }
    .custom-prompt-input {
        font-size: 0.85em;
    }
    .feed-controls {
        flex-direction: column;
        width: 100%;
    }
    .feed-controls button {
        width: 90%;
    }
    .model-buttons {
        flex-direction: column;
        width: 100%;
    }
    .model-buttons button {
        width: 90%;
    }
}
@media (max-width: 480px) {
    .image {
        width: 96%;
    }
    .gallery-title {
        font-size: 13px;
        margin-bottom: 15px; 
    }
    .container {
        padding-top: 85px; 
    }
    .modal-content {
        padding: 15px;
    }
    .modal-image-container {
        margin-bottom: 10px;
    }
    #modalImageContent {
        max-height: 50vh;
    }
    #modalPromptText {
        margin-bottom: 10px;
    }
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }
    .modal-actions button {
        width: 100%;
    }
}

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(400px); opacity: 0; }
}
