/**
 * Product AI Matcher Widget Styles
 * Умный поиск товаров с AI
 */

/* Секция виджета */
.product-ai-matcher-section {
    background: #f5f5f5;
    padding: 160px 20px 160px;
    min-height: auto;
}

.product-ai-matcher-container {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    position: relative;
}

/* Подсказка drag-and-drop с иконкой файла (только на ПК) */
.product-ai-matcher-floating-hint {
    position: absolute;
    left: -200px;
    top: -100px;
    display: none; /* Скрыто по умолчанию (мобильные) */
    opacity: 0.8;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Не блокирует клики */
    align-items: center;
    gap: 15px;
}

.product-ai-matcher-floating-hint:hover {
    opacity: 1;
}

.product-ai-matcher-hint-svg {
    width: 100px;
    height: 100px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.08));
}

.product-ai-matcher-hint-text {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-style: italic;
    font-size: 18px;
    font-weight: 400;
    color: #222;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

/* Стрелка от файла к полю */
.product-ai-matcher-hint-arrow {
    position: absolute;
    left: -150px;
    top: -10px;
    display: none; /* Скрыто по умолчанию (мобильные) */
    opacity: 0.8;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Не блокирует клики */
}

.product-ai-matcher-hint-arrow svg {
    width: 150px;
    height: 150px;
}

.product-ai-matcher-hint-arrow .arrow-triangle {
    transform: rotate(30deg);
    transform-origin: 130px 135px;
}

/* Показываем подсказку только на десктопах (ширина больше 1200px) */
@media (min-width: 1200px) {
    .product-ai-matcher-floating-hint {
        display: flex;
    }

    .product-ai-matcher-hint-arrow {
        display: block;
    }
}

/* Заголовок */
.product-ai-matcher-header {
    text-align: center;
    margin-bottom: 40px;
}

.product-ai-matcher-title {
    font-weight: 600;
    font-size: 28px;
    line-height: 40px;
    color: #212121;
    margin: 0;
}

/* Главная область ввода */
.product-ai-matcher-input-container {
    position: relative;
    background: #ffffff;
    border: 1px solid #dfe1e5;
    border-radius: 16px;
    padding: 14px 80px 14px 14px;
    min-height: 100px;
    transition: all 0.3s ease;
}

.product-ai-matcher-input-container:hover {
    border-color: #c6c9cc;
    box-shadow: 0 2px 8px rgba(32, 33, 36, 0.1);
}

.product-ai-matcher-input-container.focused {
    border-color: #00A2E2;
    box-shadow: 0 2px 12px rgba(0, 162, 226, 0.2);
}

.product-ai-matcher-input-container.loading {
    pointer-events: none;
}

/* Скрепка и камера всегда кликабельны, даже при loading */
.product-ai-matcher-input-container.loading .product-ai-matcher-file-icon-btn,
.product-ai-matcher-input-container.loading .product-ai-matcher-camera-icon-btn {
    pointer-events: auto;
}

/* Drag and drop состояние */
.product-ai-matcher-input-container.drag-over {
    border-color: #00A2E2;
    border-width: 2px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    box-shadow: 0 4px 16px rgba(0, 162, 226, 0.3);
}

.product-ai-matcher-input-container.drag-over .product-ai-matcher-drag-hint {
    color: #00A2E2;
    font-weight: 600;
    font-size: 12px;
}

/* Контейнер для чипсов и textarea */
.product-ai-matcher-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
    padding-bottom: 28px;
}

/* Микрофон - скрыт на десктопе, показан на мобиле */
.product-ai-matcher-mic-button-inline {
    display: none;
}

/* Чипсы внутри поля */
.product-ai-matcher-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: default;
    transition: all 0.2s ease;
    animation: productAiMatcherChipAppear 0.3s ease;
    max-width: calc(100% - 12px);
}

@keyframes productAiMatcherChipAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.product-ai-matcher-chip.removing {
    animation: productAiMatcherChipRemove 0.2s ease forwards;
}

@keyframes productAiMatcherChipRemove {
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

.product-ai-matcher-chip-blue {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
}

.product-ai-matcher-chip-orange {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    color: #c2410c;
}

.product-ai-matcher-chip-purple {
    background: linear-gradient(135deg, #e9d5ff 0%, #d8b4fe 100%);
    color: #7e22ce;
}

.product-ai-matcher-chip-gray {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #475569;
}

/* Кнопка очистить всё - справа наверху на ПК */
.product-ai-matcher-clear-all {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 12px;
    font-weight: 500;
    color: #4b5563;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, color 0.2s ease;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.product-ai-matcher-clear-all.visible {
    opacity: 0.8;
}

.product-ai-matcher-clear-all:hover {
    opacity: 1;
    color: #374151;
}

.product-ai-matcher-clear-all-icon {
    font-size: 14px;
    font-weight: 400;
}

.product-ai-matcher-chip-remove {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 0;
    flex-shrink: 0;
}

.product-ai-matcher-chip-remove:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: scale(1.1);
}

/* Textarea */
.product-ai-matcher-input-field {
    flex: 1;
    min-width: 200px;
    border: none;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #202124;
    background: transparent;
    outline: none;
    resize: none;
    line-height: 1.6;
    overflow: hidden;
}

.product-ai-matcher-input-field::placeholder {
    color: #80868b;
}

.product-ai-matcher-input-wrapper.has-chips .product-ai-matcher-input-field::placeholder {
    opacity: 0;
}

/* Loader внутри поля */
.product-ai-matcher-loader {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 13px;
    color: #00A2E2;
}

.product-ai-matcher-loader.active {
    display: flex;
}

.product-ai-matcher-loader-icon {
    width: 16px;
    height: 16px;
    animation: productAiMatcherSpin 1s linear infinite;
}

@keyframes productAiMatcherSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Подпись о drag & drop с иконкой */
.product-ai-matcher-drag-hint {
    position: absolute;
    bottom: 8px;
    left: 14px;
    font-size: 10px;
    color: #80868b;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Контейнер для иконок с отступом для тултипа */
.product-ai-matcher-icons-wrapper {
    margin-bottom: 10px;
}

/* Скрываем только текст подсказки когда идет загрузка, но оставляем скрепку */
.product-ai-matcher-input-container.loading .product-ai-matcher-drag-hint span {
    opacity: 0;
    visibility: hidden;
}

/* Скрепка, камера и тултип всегда видимы */
.product-ai-matcher-input-container.loading .product-ai-matcher-icons-wrapper {
    opacity: 1;
    visibility: visible;
}

.product-ai-matcher-drag-hint strong {
    color: #00A2E2;
    font-weight: 500;
}

/* Кнопка камеры (только на мобиле) */
.product-ai-matcher-camera-container {
    display: none; /* Скрыто на десктопе */
}

.product-ai-matcher-camera-icon-btn {
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid rgba(0, 162, 226, 0.2);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.6;
    padding: 0;
    pointer-events: auto;
}

.product-ai-matcher-camera-icon-btn:hover {
    opacity: 1;
    border-color: rgba(0, 162, 226, 0.4);
    background: rgba(0, 162, 226, 0.05);
}

.product-ai-matcher-camera-icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Иконка скрепки рядом с drag-hint */
.product-ai-matcher-file-icon-btn {
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid rgba(0, 162, 226, 0.2);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.6;
    padding: 0;
    position: relative;
    pointer-events: auto;
}

.product-ai-matcher-file-icon-btn:hover {
    opacity: 1;
    border-color: rgba(0, 162, 226, 0.4);
    background: rgba(0, 162, 226, 0.05);
}

.product-ai-matcher-file-icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Меню для скрепки */
.product-ai-matcher-file-menu {
    position: absolute;
    bottom: 32px;
    left: 0;
    background: white;
    border: 1px solid #dfe1e5;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    min-width: 200px;
    display: none;
    z-index: 1000;
    pointer-events: auto;
}

.product-ai-matcher-file-menu.active {
    display: block;
    animation: productAiMatcherMenuAppear 0.2s ease;
}

@keyframes productAiMatcherMenuAppear {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-ai-matcher-file-menu-item {
    padding: 10px 16px;
    font-size: 13px;
    color: #202124;
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-ai-matcher-file-menu-item:hover {
    background: #f5f5f5;
}

.product-ai-matcher-file-menu-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

/* Кнопка камеры только на мобильных */
.product-ai-matcher-file-menu-item-mobile {
    display: none;
}

@media (max-width: 768px) {
    .product-ai-matcher-file-menu-item-mobile {
        display: flex;
    }
}

/* Волшебная кнопка - всегда активная, аккуратная */
.product-ai-matcher-magic-button {
    position: absolute;
    right: 14px;
    bottom: 12px;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #00A2E2 0%, #0088c2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 1;
}

.product-ai-matcher-magic-button:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 162, 226, 0.3);
}

.product-ai-matcher-magic-button:active {
    transform: scale(0.98);
}

.product-ai-matcher-magic-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.product-ai-matcher-ai-icon {
    width: 24px;
    height: 24px;
}

/* Подпись под кнопкой */
.product-ai-matcher-button-label {
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
    color: #5f6368;
    opacity: 1;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.product-ai-matcher-button-label-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .product-ai-matcher-section {
        padding: 80px 15px;
    }

    .product-ai-matcher-title {
        font-size: 20px;
    }

    .product-ai-matcher-input-container {
        padding: 12px 12px 80px 12px;
    }

    .product-ai-matcher-magic-button {
        width: 48px;
        height: 48px;
        right: 12px;
        bottom: 45px;
    }

    .product-ai-matcher-ai-icon {
        width: 28px;
        height: 28px;
    }

    .product-ai-matcher-input-field {
        font-size: 14px;
        min-height: 100px;
    }

    .product-ai-matcher-input-field::placeholder {
        font-size: 13px;
    }

    /* Чипсы адаптивной ширины */
    .product-ai-matcher-chip {
        padding: 9px 6px;
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        gap: 4px;
        justify-content: space-between;
        box-sizing: border-box;
    }

    .product-ai-matcher-chip span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
        min-width: 0;
    }

    /* Кнопка удаления чипса */
    .product-ai-matcher-chip-remove {
        width: 20px;
        height: 20px;
        font-size: 12px;
        flex-shrink: 0;
        background: rgba(0, 0, 0, 0.3);
    }

    .product-ai-matcher-chip-remove:active {
        background: rgba(0, 0, 0, 0.5);
        transform: scale(0.95);
    }

    /* Кнопка "Очистить" после микрофона в потоке */
    .product-ai-matcher-clear-all {
        position: static;
        width: auto;
        padding: 12px 12px;
        font-size: 11px;
        background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        color: #6b7280;
        font-weight: 500;
        display: none;
        transition: all 0.2s ease;
        flex-shrink: 0;
        margin-right: 4px;
    }

    .product-ai-matcher-clear-all.visible {
        display: flex;
    }

    .product-ai-matcher-clear-all:active {
        background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
        transform: scale(0.98);
    }

    /* Показываем кнопку камеры на мобиле */
    .product-ai-matcher-camera-container {
        display: block;
    }

    /* Вертикальное расположение иконок камеры и скрепки */
    .product-ai-matcher-icons-wrapper {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .product-ai-matcher-clear-all-icon {
        display: none;
    }

    /* Textarea всегда видна для продолжения ввода */

    /* На мобиле НЕ скрываем скрепку и подсказку даже когда есть чипсы */
    .product-ai-matcher-input-wrapper.has-chips ~ .product-ai-matcher-drag-hint,
    .product-ai-matcher-input-wrapper.has-chips ~ .product-ai-matcher-drag-hint span {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .product-ai-matcher-button-label {
        margin-top: 20px;
    }

    /* Микрофон в начале строки - фиксированная иконка */
    .product-ai-matcher-mic-button-inline {
        display: flex;
        width: 36px;
        height: 36px;
        background: white;
        border: 1px solid rgba(0, 162, 226, 0.2);
        border-radius: 8px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        opacity: 0.6;
        padding: 0;
        flex-shrink: 0;
        margin-right: 4px;
    }

    .product-ai-matcher-mic-button-inline:active {
        opacity: 1;
        border-color: rgba(0, 162, 226, 0.4);
        background: rgba(0, 162, 226, 0.05);
    }

    .product-ai-matcher-mic-button-inline svg {
        width: 21px;
        height: 21px;
    }

    /* Input wrapper */
    .product-ai-matcher-input-wrapper {
        padding-bottom: 60px;
        gap: 4px;
    }

    /* Контейнер drag-hint для скрепки */
    .product-ai-matcher-drag-hint {
        position: absolute;
        bottom: 12px;
        left: 12px;
        right: 12px;
    }

    /* Скрепка */
    .product-ai-matcher-file-icon-btn {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    .product-ai-matcher-file-icon-btn svg {
        width: 21px;
        height: 21px;
    }

    /* Текст подсказки у самого низа справа от скрепки на всю ширину */
    .product-ai-matcher-drag-hint span {
        flex: 1;
        padding-right: 80px;
        font-size: 9px;
        white-space: normal;
        line-height: 1.3;
    }

    /* Волшебная кнопка справа над подсказкой */
    .product-ai-matcher-magic-button {
        right: 12px;
        bottom: 45px;
        width: 56px;
        height: 56px;
    }

    .product-ai-matcher-ai-icon {
        width: 36px;
        height: 36px;
    }
}
