/**
 * Spexo AI Image Field Styles
 * 
 * Styles for AI image generation in Elementor editor
 *
 * @package Spexo_Addons
 * @since 1.0.28
 */

/* AI Image Generation Button */
.spexo-ai-image-generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    text-decoration: none;
    margin-top: 8px;
}

.spexo-ai-image-generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    color: white;
}

.spexo-ai-image-generate-btn img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

.spexo-ai-image-generate-btn.is-active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* AI Image Field Wrapper */
.spexo-ai-image-field-wrapper {
    margin-top: 8px;
}

.spexo-ai-image-btn-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* AI Image Prompt Container */
.spexo-ai-image-prompt-container {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 8px 0 !important;
    animation: fadeIn 0.3s ease;
    border-bottom: 1px solid #e9ecef !important;
    padding-bottom: 12px !important;
}

.spexo-ai-image-prompt-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
    transition: border-color 0.3s ease;
    background: white;
    color: #495057;
    box-sizing: border-box;
}

.spexo-ai-image-prompt-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.spexo-ai-image-prompt-input::placeholder {
    color: #adb5bd;
}

/* AI Image Field Rows */
.spexo-ai-image-field-row {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    margin-bottom: 8px !important;
    flex-wrap: nowrap !important;
}

.spexo-ai-image-field-row:last-child {
    margin-bottom: 0 !important;
}

.spexo-ai-image-field-row--buttons {
    justify-content: space-between !important;
    gap: 8px !important;
    margin-top: 12px !important;
    margin-bottom: 0 !important;
}

.spexo-ai-image-field-label {
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #495057 !important;
    min-width: 60px !important;
    max-width: 60px !important;
    margin: 0 !important;
    display: inline-block !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
}

/* AI Image Controls */
.spexo-ai-image-quality,
.spexo-ai-image-resolution,
.spexo-ai-image-model {
    flex: 1 !important;
    padding: 6px 10px !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    background: white !important;
    color: #495057 !important;
    min-width: 120px !important;
    transition: border-color 0.3s ease !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
}

.spexo-ai-image-quality:hover,
.spexo-ai-image-resolution:hover,
.spexo-ai-image-model:hover {
    border-color: #999 !important;
}

.spexo-ai-image-quality:focus,
.spexo-ai-image-resolution:focus,
.spexo-ai-image-model:focus {
    border-color: #667eea !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1) !important;
}

/* Disabled Model dropdown (Pro feature) */
.spexo-ai-image-model:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    background: #f5f5f5 !important;
}

/* Background Checkbox */
.spexo-ai-image-bg-checkbox-label {
    /*display: flex !important;*/
    display: flex;
    align-items: center !important;
    font-size: 13px !important;
    color: #495057 !important;
    cursor: pointer !important;
    margin: 0 !important;
}

.spexo-ai-image-bg-checkbox {
    margin-right: 8px !important;
    accent-color: #667eea !important;
    cursor: pointer !important;
}

/* AI Image Action Buttons */
.spexo-ai-image-prompt-submit {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 16px !important;
    background: linear-gradient(135deg, #6A1B9A, #E91E63) !important;
    border: none !important;
    border-radius: 6px !important;
    color: white !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 8px rgba(106, 27, 154, 0.3) !important;
    flex: 1 !important;
    justify-content: center !important;
}

.spexo-ai-image-prompt-submit:hover {
    background: linear-gradient(135deg, #7B1FA2, #D81B60) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 16px rgba(106, 27, 154, 0.4) !important;
}

.spexo-ai-image-prompt-submit.is-processing {
    background: linear-gradient(135deg, #9C27B0, #F06292) !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    opacity: 0.8 !important;
}

.spexo-ai-image-prompt-submit.is-processing img {
    animation: spexo-ai-spin 1s linear infinite !important;
}

.spexo-ai-image-prompt-submit img {
    width: 16px !important;
    height: 16px !important;
    filter: brightness(0) invert(1) !important;
}

.spexo-ai-image-prompt-cancel {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    background: white !important;
    border: 1px solid #e9ecef !important;
    border-radius: 6px !important;
    color: #6c757d !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-size: 18px !important;
    flex-shrink: 0 !important;
}

.spexo-ai-image-prompt-cancel:hover {
    border-color: #dc3545 !important;
    color: #dc3545 !important;
    background: #fff5f5 !important;
}

.spexo-ai-cancel-icon {
    font-size: 18px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* AI Image Prompt Note */
.spexo-ai-image-prompt-note {
    font-size: 11px;
    color: #6c757d;
    margin: 12px 0 0 0;
    padding: 8px 12px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    font-style: normal;
    line-height: 1.4;
}

/* Error Messages */
.spexo-ai-image-error-message {
    background: #fff5f5;
    color: #dc3545;
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
    margin: 8px 0;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: fadeIn 0.3s ease;
}

.spexo-ai-image-error-message a {
    color: #0073aa;
    text-decoration: underline;
    white-space: nowrap;
    margin-left: 10px;
}

.spexo-ai-image-error-message a:hover {
    color: #005177;
}

/* Field Animation */
.spexo-ai-field-pulsing {
    animation: spexo-ai-pulse 1.5s infinite cubic-bezier(0.66, 0, 0, 1) !important;
    border-color: #667eea !important;
}

@keyframes spexo-ai-pulse {
    0% { 
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4), inset 0 0 0 1px rgba(102, 126, 234, 0.4); 
    }
    50% { 
        box-shadow: 0 0 0 5px rgba(102, 126, 234, 0.2), inset 0 0 0 1px rgba(102, 126, 234, 0.6); 
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.1), inset 0 0 0 1px rgba(102, 126, 234, 0.4); 
    }
}

/* Image Generating Animation (matching reference plugin) */
.spexo-ai-image-generating {
    position: relative;
    overflow: hidden;
}

.spexo-ai-image-generating::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.3), transparent);
    animation: spexo-ai-shimmer 2s infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes spexo-ai-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.elementor-control-media__preview.spexo-ai-field-pulsing,
.elementor-control-media__area.spexo-ai-image-generating {
    border: 2px solid #667eea !important;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.4) !important;
    position: relative;
}

.elementor-control-media__preview.spexo-ai-field-pulsing::after,
.elementor-control-media__area.spexo-ai-image-generating::after {
    content: '✨';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    z-index: 2;
    animation: spexo-ai-float 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes spexo-ai-float {
    0%, 100% {
        transform: translate(-50%, -50%) translateY(0);
        opacity: 0.7;
    }
    50% {
        transform: translate(-50%, -50%) translateY(-10px);
        opacity: 1;
    }
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .spexo-ai-image-field-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .spexo-ai-image-field-label {
        min-width: auto;
        margin-bottom: 4px;
    }
    
    .spexo-ai-image-quality,
    .spexo-ai-image-resolution,
    .spexo-ai-image-model {
        width: 100%;
        min-width: auto;
    }
    
    .spexo-ai-image-field-row--buttons {
        flex-direction: row;
        justify-content: center;
    }
    
    .spexo-ai-image-prompt-submit {
        flex: 1;
        justify-content: center;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .spexo-ai-image-prompt-container {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .spexo-ai-image-prompt-input {
        background: #4a5568;
        border-color: #718096;
        color: white;
    }
    
    .spexo-ai-image-prompt-input:focus {
        border-color: #667eea;
        background: #4a5568;
    }
    
    .spexo-ai-image-quality,
    .spexo-ai-image-resolution,
    .spexo-ai-image-model {
        background: #4a5568;
        border-color: #718096;
        color: white;
    }
    
    .spexo-ai-image-quality:focus,
    .spexo-ai-image-resolution:focus,
    .spexo-ai-image-model:focus {
        border-color: #667eea;
        background: #4a5568;
    }
    
    .spexo-ai-image-field-label {
        color: #e2e8f0;
    }
    
    .spexo-ai-image-bg-checkbox-label {
        color: #e2e8f0;
    }
    
    .spexo-ai-image-prompt-cancel {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .spexo-ai-image-prompt-cancel:hover {
        background: #718096;
        border-color: #dc3545;
        color: #dc3545;
    }
    
    .spexo-ai-image-prompt-note {
        color: #fbbf24;
        background: rgba(251, 191, 36, 0.1);
        border-color: rgba(251, 191, 36, 0.3);
    }
    
    .elementor-control-media__preview.spexo-ai-field-pulsing::after,
    .elementor-control-media__area.spexo-ai-image-generating::after {
        filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
    }
}

/* Elementor Integration Specific */
.elementor-control .spexo-ai-image-generate-btn {
    margin-top: 10px;
}

.elementor-control-media__preview.spexo-ai-field-pulsing {
    border: 2px solid #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

/* Loading State */
.spexo-ai-image-loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.spexo-ai-image-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spexo-ai-spin 1s linear infinite;
}
