/**
 * Watson AI Images for Elementor
 * 
 * Стили для модального окна генерации изображений
 */

/* Стили для модального окна Watson AI Images */
.ws-images-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none; /* Скрыто по умолчанию */
    align-items: center;
    justify-content: center;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* Показываем модальное окно, когда оно имеет класс .open */
.ws-images-modal.open {
    display: flex;
}

.ws-images-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.ws-images-modal-container {
    position: relative;
    width: 1100px;
    max-width: 95%;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: zoomIn 0.3s ease;
}

.ws-images-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6d7882;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.ws-images-modal-body {
    height: 100%;
}

/* Стили для двухколоночного макета */
.ws-images-columns {
    display: flex; 
    height: 100%;
    justify-content: center;
    align-items: center;
}

.ws-images-column {
    flex: 1;
    max-width: 50%;
}

.ws-images-column-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 30px 60px;
}

.ws-images-column-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

/* Стили для плейсхолдера изображения */
.ws-images-preview {
    background-color: #f7f7f7;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 550px;
    overflow: hidden;
}

.ws-images-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 550px;
    height: 550px;
    position: relative;
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.ws-images-placeholder-pulse {
    width: 550px;
    height: 550px;
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Стили для плейсхолдера в состоянии загрузки */
.ws-images-placeholder.loading {
    background: linear-gradient(-45deg, #e0e0e0, #f5f5f5, #e0e0e0, #f0f0f0);
    background-size: 400% 400%;
    animation: gradientAnimation 1.5s ease infinite, pulseShadow 1.5s infinite alternate;
    box-shadow: 0 0 20px rgba(0, 120, 255, 0.4);
    position: relative;
    overflow: hidden;
}

.ws-images-placeholder.loading:after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: shimmerEffect 1.2s infinite;
}

@keyframes shimmerEffect {
    0% {
        left: -100%;
    }
    100% {
        left: 150%;
    }
}

@keyframes pulseShadow {
    0% {
        box-shadow: 0 0 20px rgba(0, 120, 255, 0.4);
    }
    100% {
        box-shadow: 0 0 30px rgba(0, 120, 255, 0.7);
    }
}

@keyframes gradientAnimation {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Стили для плейсхолдера с изображением */
.ws-images-placeholder.with-image {
    animation: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Затемнение при наведении */
.ws-images-placeholder.with-image:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Темный фон */
    opacity: 0;
    transition: opacity 0.2s ease; /* Простая анимация только прозрачности */
    z-index: 5;
}

.ws-images-placeholder.with-image:hover:before {
    opacity: 1;
}

/* Кнопки при наведении */
.ws-images-buttons-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Центрирование без масштабирования */
    display: flex;
    gap: 15px; /* Расстояние между кнопками */
    opacity: 0;
    transition: opacity 0.2s ease; /* Простая анимация только прозрачности */
    z-index: 10;
}

.ws-images-placeholder.with-image:hover .ws-images-buttons-container {
    opacity: 1;
}

/* Стили кнопок */
.ws-images-use-button,
.ws-images-zoom-button {
    background-color: white;
    color: #333;
    border: none;
    padding: 12px 18px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.ws-images-zoom-button {
    padding: 12px;
    min-width: auto;
}

.ws-images-zoom-button svg {
    width: 20px;
    height: 20px;
}

.ws-images-placeholder.with-image:hover .ws-images-use-button {
    opacity: 1;
}

/* Спиннер на кнопке */
.ws-images-use-button.loading {
    position: relative;
    padding-right: 40px !important;
}

.ws-images-use-button.loading:after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    margin-top: -8px;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Стили для блока баланса */

.ws-images-balance-info {
    background-color: #f7f7f7;
    border-radius: 4px 0 0 4px;
    padding: 8px 12px;
    font-size: 12px;
    color: #333;
    height: 30px;
    display: inline-block;
}
.ws-images-balance-refresh {
    border: none;
    background: none;
    color: #999;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    margin-left: 5px;
}

.ws-images-balance-refresh:hover {
    color: #000;
}

.ws-images-balance-refresh.rotating {
    animation: ws-rotate 1s linear infinite;
}

@keyframes ws-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ws-images-balance-add {
    height: 30px;
    width: 30px;
    border: none;
    background: rgb(60, 65, 230);
    color: #fff;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

.ws-images-balance-info strong {
    font-weight: 600;
}

/* Стили для формы ввода промпта */
.ws-images-prompt-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 5px 0;
}

/* Стили для заголовков */
.ws-images-section-title {
    font-size: 18px;
    font-weight: 400;
    margin-top: 0;
    margin-bottom: 0px;
    color: #333;
    line-height: 32px;
}

.ws-images-section-title span {
    font-weight: 600;
}
.ws-images-options-title {
    font-size: 12px;
    font-weight: 400;
    margin-top: 0;
    margin-bottom: 10px;
    color: #000;
}

/* Стили для секций настроек */
.ws-images-options-section {
    margin-bottom: 20px;
}


/* Стили для группы радио-кнопок */
.ws-images-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Скрываем стандартные радио-кнопки */
.ws-images-radio-button input[type="radio"] {
    display: none;
}

/* Стилизуем метки как кнопки */
.ws-images-radio-label {
    display: inline-block;
    padding: 8px 12px;
    background: rgb(255, 255, 255);
    color: rgb(0, 0, 0);
    border-width: 1px;
    border-style: solid;
    border-color: rgb(234, 234, 234);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Стиль при наведении */
.ws-images-radio-button input[type="radio"]:not(:checked) + .ws-images-radio-label:hover {
    background-color: #f5f5f5;
    border-color: #ddd;
}

/* Стиль для выбранной опции */
.ws-images-radio-button input[type="radio"]:checked + .ws-images-radio-label {
    background-color: rgb(239, 239, 253);
    color: rgb(60, 65, 230);
    border-color: rgb(60, 65, 230);
}

/* Стиль при наведении на выбранную опцию */
.ws-images-radio-button input[type="radio"]:checked:hover + .ws-images-radio-label {
    background-color: rgb(229, 229, 253);
    border-color: rgb(60, 65, 230);
}

/* Стили для кнопки отправки */
.ws-images-submit-button {
    padding: 12px 20px;
    background-color: rgb(60, 65, 230);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 5px;
    text-align: center;
    width: 100%;
    margin-top: -10px;;
}

.ws-images-submit-button:hover {
    background-color: rgb(50, 55, 210);
}

.ws-images-submit-button:disabled {
    background-color: rgb(180, 180, 230);
    cursor: not-allowed;
}

/* Стили для статусов и сообщений */
.ws-images-status {
    background-color: #fff;
    border-left: 4px solid #000;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 14px;
    color: #000;
    display: flex;
    align-items: center;
    position: absolute;
    top: 20px;
    left: 20px;
}

.ws-images-status:before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(143, 143, 143, 0.2);
    border-top-color: #000;
    border-radius: 50%;
    margin-right: 15px;
    animation: spin 1s linear infinite;
}

.ws-images-status-success {
    background-color: #f0fff4;
    border-left-color: #38a169;
}

.ws-images-status-success:before {
    border-color: rgba(56, 161, 105, 0.2);
    border-top-color: #38a169;
}

.ws-images-error {
    background-color: #fff5f5;
    border-left: 4px solid #e53e3e;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 14px;
    color: #000;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.ws-images-retry-button {
    background-color: #e53e3e;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: auto;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.ws-images-retry-button:hover {
    background-color: #c53030;
}

/* Стили для результата генерации */
.ws-images-result-container {
    position: relative;
    overflow: hidden;
}

.ws-images-generated-image {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.ws-images-result-container:hover .ws-images-generated-image {
    filter: brightness(0.7);
    transition: filter 0.3s ease;
}

.ws-images-actions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ws-images-result-container:hover .ws-images-actions {
    opacity: 1;
}

.ws-images-use-btn,
.ws-images-zoom-btn {
    background-color: white !important;
    color: #333 !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 8px 15px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2) !important;
    transition: all 0.2s ease !important;
}

.ws-images-use-btn:hover,
.ws-images-zoom-btn:hover {
    background-color: #f0f0f0 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
}

/* Стили для уведомления при использовании изображения */
.ws-images-notification {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(60, 65, 230, 0.9);
    color: white;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-100%);
    transition: all 0.3s ease;
    z-index: 10;
}

.ws-images-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.ws-images-regenerate-btn {
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.ws-images-use-btn {
    background-color: #3c41e6;
    color: white;
    border: none;
}

.ws-images-use-btn:hover {
    background-color: #2f33b3;
}

.ws-images-regenerate-btn {
    background-color: white;
    color: #333;
    border: 1px solid #ddd;
}

.ws-images-regenerate-btn:hover {
    background-color: #f5f5f5;
}

/* Стили для модального окна пополнения баланса */
.ws-add-balance-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000; /* Выше, чем у основного модального окна */
    display: none;
    align-items: center;
    justify-content: center;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.ws-add-balance-modal.open {
    display: flex;
}

.ws-add-balance-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.ws-add-balance-modal-container {
    position: relative;
    width: 90%;
    max-width: 368px;
    max-height: 90vh;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.ws-add-balance-modal-close {
    position: absolute;
    top: -25px;
    right: -25px;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    z-index: 2;
}

.ws-add-balance-modal-body {
    overflow-y: auto;
    max-height: 90vh;
    border-radius: 10px;
}

.ws-add-balance-title {
    font-size: 20px;
    font-weight: 500;
    margin-top: 0;
    margin-bottom: 20px;
    color: #fff;
}

.ws-add-balance-frame-container {
    width: 100%;
    height: 70vh;
    overflow: hidden;
}

#ws-add-balance-frame {
    width: 100%;
    height: 100%;
    border: none;
}

/* Стили для лайтбокса */
.ws-images-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ws-images-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.ws-images-lightbox-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ws-images-lightbox.active .ws-images-lightbox-image {
    transform: scale(1);
}

.ws-images-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: #333;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.ws-images-lightbox-close:hover {
    transform: rotate(90deg);
    background-color: #f0f0f0;
}

/* Стили для заголовка колонки */
.ws-images-column-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.ws-images-prompt-textarea {
    width: 100%;
    padding: 15px;
    border-radius: 4px;
    resize: none;
    flex-grow: 1;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 0px;
}

.ws-images-prompt-textarea:focus {
    border-color: #000;
    outline: none;
}


/* Стили для состояния загрузки */
.ws-images-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 0;
}

.ws-images-loading-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #000;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.ws-images-loading-text {
    font-size: 14px;
    color: #6d7882;
}

/* Стили для результата генерации */
.ws-images-result {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    
}

.ws-images-result-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    object-fit: contain;
}


/* Стили для сообщений об ошибках */
.ws-images-error {
    color: #e63946;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 12px 15px;
    margin-bottom: 15px;
    font-size: 14px;
    position: absolute;
    top: 20px;
    left: 20px;
}

/* Анимации */
@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

/* Кнопка Watson AI в элементе управления изображением Elementor */
.elementor-control-media__tools .ws-ai-image-button {
    background-color: #000;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: auto;
}

.elementor-control-media__tools .ws-ai-image-button:hover {
    background-color: #333;
    transform: translateY(-1px);
}

.elementor-control-media__tools .ws-ai-image-button svg {
    width: 16px;
    height: 16px;
    margin-right: 5px;
}
