/**
 * AI Service Engine - Frontend Styles
 * Стили для пользовательского интерфейса AI инструментов
 * Основано на стилях REHub Theme
 */

/* Общие стили для AI инструментов */
.ai-tool-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 25px;
    background: #fff;
    border: 1px solid #e3e3e3;
    box-shadow: 0 2px 2px #ECECEC;
    font-family: Roboto,"Helvetica Neue",-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Oxygen-Sans,sans-serif;
    font-size: 15px;
    color: #333;
}

.ai-tool-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.ai-tool-title {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 10px 0;
}

.ai-tool-description {
    font-size: 16px;
    color: #7f8c8d;
    line-height: 1.6;
}

.ai-tool-price {
    display: inline-block;
    background: #e74c3c;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
    margin-top: 10px;
}

/* Стили формы */
.ai-tool-form {
    max-width: 600px;
    margin: 0 auto;
}

.ai-form-group {
    margin-bottom: 25px;
}

.ai-form-label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 14px;
}

.ai-form-input,
.ai-form-textarea,
.ai-form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.ai-form-input:focus,
.ai-form-textarea:focus,
.ai-form-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.ai-form-textarea {
    resize: vertical;
    min-height: 120px;
}

.ai-form-help {
    font-size: 13px;
    color: #95a5a6;
    margin-top: 5px;
    line-height: 1.4;
}

/* Чекбоксы и радиокнопки */
.ai-form-checkbox,
.ai-form-radio {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.ai-form-checkbox input,
.ai-form-radio input {
    margin-right: 10px;
    transform: scale(1.2);
}

/* Загрузка файлов */
.ai-file-upload-area {
    position: relative;
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: #f8f9fa;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ai-file-upload-area:hover {
    border-color: #3498db;
    background: #e3f2fd;
}

.ai-file-upload-area.drag-over {
    border-color: #2ecc71;
    background: #e8f5e8;
}

.ai-file-upload {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.ai-file-upload-text {
    font-size: 16px;
    color: #7f8c8d;
}

.ai-file-upload-icon {
    font-size: 48px;
    color: #bdc3c7;
    margin-bottom: 15px;
}

/* Кнопки */
.ai-btn {
    display: inline-block;
    padding: 12px 25px;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    line-height: 1.42857143;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.ai-btn-primary {
    background: #27ae60;
    color: #fff;
    border-color: #27ae60;
}

.ai-btn-primary:hover {
    background: #219a52;
    border-color: #1e8449;
    color: #fff;
    text-decoration: none;
}

.ai-btn-secondary {
    background: transparent;
    color: #666;
    border-color: #ddd;
}

.ai-btn-secondary:hover {
    background: #f5f5f5;
    border-color: #bbb;
    color: #333;
}

.ai-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.ai-btn-full-width {
    width: 100%;
}

/* Баланс пользователя */
.ai-user-balance {
    background: #fff;
    color: #333;
    padding: 20px;
    border: 1px solid #e3e3e3;
    border-radius: 3px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ai-balance-title {
    font-size: 16px;
    margin-bottom: 10px;
    color: #666;
    font-weight: 500;
}

.ai-balance-amount {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #27ae60;
}

.ai-balance-currency {
    font-size: 14px;
    color: #999;
}

.ai-balance-actions {
    margin-top: 15px;
}

.ai-balance-refresh {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.ai-balance-refresh:hover {
    background: #e9ecef;
    border-color: #bbb;
}

/* Статус задач */
.ai-job-status {
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 3px;
    padding: 15px;
    margin-top: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.ai-status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-status-text {
    font-weight: 500;
    font-size: 14px;
    color: #666;
}

.ai-status-progress {
    flex: 1;
    height: 4px;
    background: #f5f5f5;
    border-radius: 2px;
    overflow: hidden;
}

.ai-progress-bar {
    height: 100%;
    background: #27ae60;
    transition: width 0.3s ease;
}

.ai-progress-bar.indeterminate {
    animation: progress-indeterminate 2s infinite linear;
}

@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Результаты */
.ai-result-container {
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 3px;
    padding: 25px;
    margin-top: 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ai-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.ai-result-title {
    font-size: 18px;
    font-weight: 500;
    color: #333;
    margin: 0;
}

.ai-result-actions {
    display: flex;
    gap: 10px;
}

.ai-result-image {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e3e3e3;
}

.ai-result-text {
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 3px;
    padding: 20px;
    font-family: Roboto,"Helvetica Neue",-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Oxygen-Sans,sans-serif;
    line-height: 1.6;
    white-space: pre-wrap;
    color: #333;
}

.ai-result-code {
    background: #2d3748;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    overflow-x: auto;
    white-space: pre;
}

/* Действия с результатами */
.ai-action-btn {
    background: #fff;
    border: 1px solid #ddd;
    color: #666;
    padding: 8px 16px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.ai-action-btn:hover {
    background: #f5f5f5;
    border-color: #bbb;
    color: #333;
    text-decoration: none;
}

.ai-action-btn.success {
    border-color: #27ae60;
    color: #27ae60;
}

.ai-action-btn.success:hover {
    background: #27ae60;
    color: white;
    border-color: #27ae60;
}

/* Уведомления */
.ai-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.ai-notification-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.ai-notification-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.ai-notification-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

.ai-notification-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    color: inherit;
}

.ai-notification-close:hover {
    opacity: 1;
}

/* Адаптивность */
@media (max-width: 768px) {
    .ai-tool-container {
        margin: 10px;
        padding: 15px;
    }
    
    .ai-tool-title {
        font-size: 24px;
    }
    
    .ai-form-input,
    .ai-form-textarea,
    .ai-form-select {
        font-size: 16px; /* Предотвращает зум на iOS */
    }
    
    .ai-btn {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .ai-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .ai-result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .ai-result-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .ai-tool-container {
        margin: 5px;
        padding: 10px;
    }
    
    .ai-file-upload-area {
        padding: 30px 15px;
    }
    
    .ai-user-balance {
        padding: 15px;
    }
    
    .ai-balance-amount {
        font-size: 28px;
    }
}

/* Анимации загрузки */
.ai-loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.ai-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    border-radius: inherit;
    z-index: 1;
}

.ai-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: ai-spin 1s linear infinite;
}

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

/* Дополнительные утилиты */
.ai-hidden {
    display: none !important;
}

.ai-text-center {
    text-align: center;
}

.ai-mb-0 { margin-bottom: 0 !important; }
.ai-mb-1 { margin-bottom: 8px !important; }
.ai-mb-2 { margin-bottom: 16px !important; }
.ai-mb-3 { margin-bottom: 24px !important; }

.ai-mt-0 { margin-top: 0 !important; }
.ai-mt-1 { margin-top: 8px !important; }
.ai-mt-2 { margin-top: 16px !important; }
.ai-mt-3 { margin-top: 24px !important; }

/* Эффекты для интерактивности */
.ai-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.ai-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.ai-pulse {
    animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

/* Дополнительные классы для REHub совместимости */
.ai-tool-light-theme {
    font-family: Roboto,"Helvetica Neue",-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Oxygen-Sans,sans-serif;
    line-height: 1.6;
}

.ai-tool-light-theme .ai-form-input:focus,
.ai-tool-light-theme .ai-form-textarea:focus,
.ai-tool-light-theme .ai-form-select:focus {
    border-color: #27ae60;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.2);
}

.ai-tool-light-theme .ai-btn-primary {
    background: #27ae60;
    border-color: #27ae60;
}

.ai-tool-light-theme .ai-btn-primary:hover {
    background: #219a52;
    border-color: #1e8449;
}

/* Загрузка с REHub стилями */
.ai-loading::after {
    background: rgba(255, 255, 255, 0.9);
}

.ai-spinner {
    border-color: #f3f3f3;
    border-top-color: #27ae60;
}