/**
 * AI-Антифрод - Стили
 * Защита заказчиков от мошенничества
 * Цветовая схема: оранжевый/красный (предупреждение об опасности)
 * 
 * ВАЖНО: Все анимации имеют уникальные имена (antifraud*) 
 * чтобы не конфликтовать с ai-negotiator.css
 * 
 * @version 1.0.1
 * @date 2025-12-21
 */

/* ==================== OVERLAY & MODAL ==================== */

.ai-antifraud-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-antifraud-overlay.ai-antifraud-visible {
    opacity: 1;
}

.ai-antifraud-modal {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.ai-antifraud-visible .ai-antifraud-modal {
    transform: translateY(0);
}

/* ==================== HEADER ==================== */

.ai-antifraud-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e4e4e4;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.ai-antifraud-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.ai-antifraud-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-antifraud-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==================== BODY ==================== */

.ai-antifraud-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ==================== INPUT SECTION ==================== */

.ai-antifraud-input-section {
    margin-bottom: 16px;
}

.ai-antifraud-input-section label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.ai-antifraud-hint {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: #92400e;
    margin-bottom: 12px;
    line-height: 1.4;
}

.ai-antifraud-textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.ai-antifraud-textarea:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.ai-antifraud-textarea::placeholder {
    color: #999;
    font-size: 13px;
}

.ai-antifraud-char-count {
    text-align: right;
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* ==================== BUTTONS ==================== */

.ai-antifraud-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-antifraud-btn-primary {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
}

.ai-antifraud-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.ai-antifraud-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.ai-antifraud-btn .ai-btn-loader {
    animation: antifraudSpin 1s linear infinite;
}

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

/* ==================== RESULT SECTION ==================== */

.ai-antifraud-result {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e4e4e4;
}

/* Error */
.ai-antifraud-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    color: #dc2626;
    font-size: 14px;
}

/* ==================== RISK BANNER ==================== */

.ai-antifraud-risk-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.ai-risk-icon {
    font-size: 36px;
}

.ai-risk-info {
    flex: 1;
}

.ai-risk-title {
    font-size: 18px;
    font-weight: 700;
}

.ai-risk-description {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

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

.ai-score-value {
    font-size: 24px;
    font-weight: 700;
}

.ai-score-label {
    font-size: 11px;
    text-transform: uppercase;
    opacity: 0.8;
}

/* Risk Levels */
.ai-risk-low {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 2px solid #10b981;
    color: #065f46;
}

.ai-risk-medium {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 2px solid #f59e0b;
    color: #92400e;
}

.ai-risk-high {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 2px solid #ef4444;
    color: #991b1b;
}

.ai-risk-critical {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border: 2px solid #dc2626;
    color: #ffffff;
    animation: antifraudCriticalPulse 2s ease-in-out infinite;
}

@keyframes antifraudCriticalPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* ==================== SECTIONS ==================== */

.ai-antifraud-section {
    margin-bottom: 16px;
}

.ai-antifraud-section .ai-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
}

/* Situation */
.ai-antifraud-section.ai-situation-section {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.ai-situation-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #475569;
}

/* Fraud Scheme */
.ai-fraud-scheme {
    background: #fef2f2;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid #fecaca;
}

.ai-fraud-scheme .ai-section-title {
    color: #dc2626;
}

.ai-scheme-name {
    font-size: 16px;
    font-weight: 600;
    color: #991b1b;
}

/* Flag Lists */
.ai-flag-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ai-flag-list li {
    position: relative;
    padding: 8px 12px 8px 28px;
    margin-bottom: 4px;
    border-radius: 8px;
    font-size: 14px;
}

.ai-flags-danger li {
    background: #fef2f2;
    color: #991b1b;
}

.ai-flags-danger li::before {
    content: '!';
    position: absolute;
    left: 10px;
    color: #ef4444;
    font-weight: bold;
}

.ai-flags-positive li {
    background: #ecfdf5;
    color: #065f46;
}

.ai-flags-positive li::before {
    content: '✓';
    position: absolute;
    left: 10px;
    color: #10b981;
    font-weight: bold;
}

/* Extracted Data */
.ai-extracted-data {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.ai-data-item {
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 13px;
}

.ai-data-label {
    display: block;
    color: #666;
    margin-bottom: 2px;
}

.ai-data-value {
    font-weight: 500;
    color: #333;
}

/* Action Section */
.ai-action-section {
    background: #eff6ff;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #bfdbfe;
}

.ai-action-section .ai-section-title {
    color: #1d4ed8;
}

.ai-action-text {
    font-size: 14px;
    font-weight: 500;
    color: #1e40af;
}

/* Questions Section */
.ai-questions-section {
    background: #f3e8ff;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #ddd6fe;
}

.ai-questions-section .ai-section-title {
    color: #7c3aed;
}

.ai-questions-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: question;
}

.ai-questions-list li {
    position: relative;
    padding: 8px 12px 8px 32px;
    margin-bottom: 4px;
    background: #ede9fe;
    border-radius: 8px;
    font-size: 13px;
    color: #5b21b6;
    counter-increment: question;
}

.ai-questions-list li::before {
    content: counter(question);
    position: absolute;
    left: 8px;
    width: 18px;
    height: 18px;
    background: #7c3aed;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tips Section */
.ai-tips-section {
    background: #ecfdf5;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #a7f3d0;
}

.ai-tips-section .ai-section-title {
    color: #047857;
}

.ai-tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ai-tips-list li {
    padding: 6px 0;
    font-size: 13px;
    color: #065f46;
}

.ai-tips-list li::before {
    content: '💡 ';
}

/* Response Section */
.ai-response-section {
    background: #f0fdf4;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #bbf7d0;
}

.ai-response-section .ai-section-title {
    color: #166534;
}

.ai-suggested-response {
    position: relative;
}

.ai-suggested-response p {
    margin: 0 0 12px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #166534;
    white-space: pre-wrap;
}

.ai-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #22c55e;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-copy-btn:hover {
    background: #16a34a;
}

/* Do Not Section */
.ai-donot-section {
    background: #fef2f2;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #fecaca;
}

.ai-donot-section .ai-section-title {
    color: #b91c1c;
}

.ai-donot-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
}

.ai-donot-list li {
    position: relative;
    padding: 8px 12px 8px 28px;
    margin-bottom: 4px;
    background: #fff5f5;
    border-radius: 8px;
    font-size: 13px;
    color: #991b1b;
}

.ai-donot-list li::before {
    content: '✗';
    position: absolute;
    left: 10px;
    color: #ef4444;
    font-weight: bold;
}

/* Checklist Section */
.ai-checklist-section {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.ai-checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ai-checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
}

.ai-checklist-item:last-child {
    border-bottom: none;
}

.ai-check-icon {
    font-size: 16px;
    color: #6b7280;
}

.ai-check-text {
    flex: 1;
    color: #374151;
}

.ai-check-status {
    font-size: 12px;
    color: #f59e0b;
    font-weight: 500;
}

/* Meta */
.ai-antifraud-meta {
    display: flex;
    justify-content: space-between;
    padding-top: 12px;
    margin-top: 16px;
    border-top: 1px solid #e4e4e4;
    font-size: 12px;
    color: #999;
}

/* ==================== FLOATING BUTTON (FAB) ==================== */
/*
 * НАСТРОЙКИ КНОПКИ:
 * Размеры идентичны ai-negotiator-fab
 * Позиция: слева (симметрично правой кнопке)
 * Цвет: оранжевый (предупреждение)
 */

.ai-antifraud-fab {
    position: fixed;
    bottom: 80px;
    left: 16px;  /* Слева, симметрично AI-Переговорщику справа */
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    z-index: 9999;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-antifraud-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.ai-antifraud-fab:active {
    transform: scale(0.95);
}

/* Иконка внутри FAB (desktop) */
.ai-antifraud-fab-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    pointer-events: none;
}

/* Tooltip - слева от кнопки, появляется справа */
.ai-antifraud-fab::after {
    content: 'AI-Антифрод';
    position: absolute;
    left: 100%;
    margin-left: 12px;
    padding: 6px 12px;
    background: #333;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.ai-antifraud-fab:hover::after {
    opacity: 1;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 480px) {
    .ai-antifraud-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .ai-antifraud-modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 16px 16px 0 0;
    }

    .ai-antifraud-risk-banner {
        flex-wrap: wrap;
    }

    .ai-risk-score {
        width: 100%;
        margin-top: 8px;
        text-align: left;
    }

    .ai-extracted-data {
        grid-template-columns: 1fr;
    }

    /* Mobile FAB - идентичен ai-negotiator-fab mobile */
    .ai-antifraud-fab {
        bottom: 70px;
        left: 20px;
        width: 64px;
        height: 64px;
        font-size: 36px;
    }

    /* Mobile иконка - идентична ai-fab-icon mobile */
    .ai-antifraud-fab-icon {
        width: 54px;
        height: 54px;
    }

    .ai-antifraud-fab::after {
        display: none;
    }
}

/* ==================== АНИМАЦИЯ ПОКАЧИВАНИЯ FAB ==================== */
/*
 * ВАЖНО: Используем уникальное имя antifraudWaveFloat
 * чтобы не конфликтовать с fabWaveFloat из ai-negotiator.css
 *
 * НАСТРОЙКИ АНИМАЦИИ:
 * --antifraud-wave-amplitude: амплитуда (высота подъёма), по умолчанию 6px
 * --antifraud-wave-duration: длительность цикла, по умолчанию 3s
 */

.ai-antifraud-fab {
    --antifraud-wave-amplitude: 6px;   /* ← Амплитуда: 4px (слабо) | 6px (средне) | 10px (сильно) */
    --antifraud-wave-duration: 3s;     /* ← Частота: 2s (быстро) | 3s (средне) | 5s (медленно) */
    
    animation: antifraudWaveFloat var(--antifraud-wave-duration) ease-in-out infinite;
}

@keyframes antifraudWaveFloat {
    0% {
        transform: translateY(0);
        box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    }
    50% {
        transform: translateY(calc(-1 * var(--antifraud-wave-amplitude)));
        box-shadow: 0 8px 24px rgba(245, 158, 11, 0.5);
    }
    100% {
        transform: translateY(0);
        box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    }
}

/* Отключаем анимацию при наведении чтобы не конфликтовала */
.ai-antifraud-fab:hover {
    animation-play-state: paused;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

/* Отключаем анимацию при нажатии */
.ai-antifraud-fab:active {
    animation-play-state: paused;
    transform: scale(0.95);
}

/* ==================== DARK MODE SUPPORT ==================== */

@media (prefers-color-scheme: dark) {
    /* 
     * Пока не включаем тёмную тему, 
     * т.к. Kuvalda+ использует светлую тему
     * Оставляем заготовку на будущее
     */
}
