/**
 * AI Assistant Chat Widget Styles
 * Полностью изолированные стили с префиксом .ai-assistant__
 */

/* ===== CONTAINER ===== */
.ai-assistant__widget {
    font-family: "ProximaNovaRegular", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ===== FLOATING BUTTON ===== */
.ai-assistant__fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    height: 48px;
    padding: 0 15px 0 15px;
    border-radius: 26px;
    background: #295e45;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(41, 94, 69, 0.4);
    z-index: 999999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: ai-assistant__pulse 2s infinite;
}

.ai-assistant__fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(41, 94, 69, 0.55);
}

.ai-assistant__fab-logo {
    height: 26px;
    flex-shrink: 0;
}

.ai-assistant__fab-label {
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    white-space: nowrap;
}

@keyframes ai-assistant__pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(41, 94, 69, 0.4); }
    50% { box-shadow: 0 4px 28px rgba(41, 94, 69, 0.65); }
}

/* ===== CHAT PANEL ===== */
.ai-assistant__panel {
    width: 20vw;
    height: 65vh;
    min-width: 400px;
    min-height: 580px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    position: fixed;
    bottom: 25px;
    left: 25px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 999998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: ai-assistant__slideIn 0.3s ease;
}

.ai-assistant__panel--open {
    display: flex;
}

@keyframes ai-assistant__slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== HEADER ===== */
.ai-assistant__header {
    background: #295e45;
    color: #fff;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-assistant__header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-assistant__avatar {
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-assistant__avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ai-assistant__title {
    font-size: 18px;
    font-weight: 600;
}

.ai-assistant__subtitle {
    font-size: 13px;
    opacity: 0.8;
}

.ai-assistant__new-chat {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    height: 32px;
    padding: 0 12px;
    border-radius: 24px;
    background: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #2e5e45;
    font-size: 14px;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #2e5e45;
    font-weight: bold;
}

.ai-assistant__new-chat:hover {
    transform: translateX(-50%) scale(1.02);
    box-shadow: 0 4px 14px rgba(35, 94, 69, 0.5);
}

.ai-assistant__close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-assistant__close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ai-assistant__close svg {
    width: 24px;
    height: 24px;
}

/* ===== MESSAGES AREA ===== */
.ai-assistant__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
}

.ai-assistant__messages::-webkit-scrollbar {
    width: 5px;
}

.ai-assistant__messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ===== SCROLL-TO-BOTTOM BUTTON ===== */
.ai-assistant__scroll-down {
    position: absolute;
    bottom: 68px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #2e5e45;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2e5e45;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.2s, box-shadow 0.2s;
    padding: 0;
}

.ai-assistant__scroll-down--visible {
    opacity: 1;
    pointer-events: auto;
}

.ai-assistant__scroll-down:hover {
    transform: translateX(-50%) scale(1.08);
    box-shadow: 0 4px 14px rgba(35, 94, 69, 0.5);
}

/* ===== MESSAGE BUBBLES ===== */
.ai-assistant__msg {
    max-width: 95%;
    padding: 7px 15px;
    border-radius: 15px;
    word-break: break-word;
    animation: ai-assistant__msgIn 0.25s ease;
}

.ai-assistant__msg strong {
    font-weight: 600;
}

@keyframes ai-assistant__msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-assistant__msg--bot {
    align-self: flex-start;
    background: #f8f8f8;
    color: #1f2937;
    border-bottom-left-radius: 0;
    white-space: pre-wrap;
}

.ai-assistant__msg--bot strong {
    font-weight: 700;
    color: #111827;
}

.ai-assistant__suggestions {
    margin-top: 12px;
}

.ai-assistant__suggestion-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-top: 7px;
}

.ai-assistant__suggestion {
    padding: 0;
    border: 0;
    background: transparent;
    color: #295e45;
    font: inherit;
    line-height: 1.4;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.ai-assistant__suggestion:hover,
.ai-assistant__suggestion:focus-visible {
    color: #1f4936;
}

.ai-assistant__msg--bot .ai-assistant__article-link {
    color: #295e45;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ai-assistant__msg--bot .ai-assistant__article-link:hover {
    color: #1f4936;
}

.ai-assistant__msg--bot .ai-assistant__article-results {
    margin-top: 12px;
}

.ai-assistant__msg--bot .ai-assistant__article-results ul {
    margin: 6px 0 0;
    padding-left: 20px;
}

.ai-assistant__msg--bot .ai-assistant__article-results li {
    margin-top: 4px;
}

.ai-assistant__msg--user {
    align-self: flex-end;
    background: #295e45;
    color: #fff;
    border-bottom-right-radius: 0;
}

.ai-assistant__msg--status {
    color: #9ca3af;
    background: #f8f8f8;
    font-style: italic;
}

.ai-assistant__msg--error {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

/* ===== ANSWER FEEDBACK ===== */
.ai-assistant__feedback {
    align-self: flex-start;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 95%;
    padding: 7px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    color: #6b7280;
    font-size: 14px;
    animation: ai-assistant__msgIn 0.25s ease;
}

.ai-assistant__feedback-button {
    padding: 2px 10px;
    border: 1px solid #2e5e45;
    border-radius: 16px;
    background: #fff;
    color: #2e5e45;
    font: inherit;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.ai-assistant__feedback-button[data-feedback-vote="no"] {
    border-color: #dc2626;
    color: #dc2626;
}

.ai-assistant__feedback-button:hover,
.ai-assistant__feedback-button:focus-visible {
    background: #def0e8;
    outline: none;
}

.ai-assistant__feedback-button[data-feedback-vote="no"]:hover,
.ai-assistant__feedback-button[data-feedback-vote="no"]:focus-visible {
    background: #fef2f2;
}

.ai-assistant__feedback-response {
    color: #2e5e45;
}

/* ===== CATALOG BUTTON (внутри сообщений) ===== */
.ai-assistant__catalog-btn {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 24px;
    background: #ffffff;
    border: 1px solid #2e5e45;
    color: #2e5e45;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    margin: 6px 0 2px 0;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.ai-assistant__catalog-btn:hover,
.ai-assistant__catalog-btn:focus,
.ai-assistant__catalog-btn:active {
    background: #def0e8;
    text-decoration: none;
    color: #2e5e45;
    outline: none;
}

.ai-assistant__catalog-btn:visited {
    background: #ffffff;
    text-decoration: none;
    color: #2e5e45;
    outline: none;
}

/* Центрирование кнопок внутри ответа */
.ai-btn-center {
    text-align: center;
}

/* ===== ADD-ALL TO CART (Добавить в корзину) ===== */
.ai-add-all,
.ai-add-all:hover,
.ai-add-all:focus,
.ai-add-all:active,
.ai-add-all--loading,
.ai-add-all--done {
    background: #295e45;
    border-color: #295e45;
    color: #ffffff;
    text-decoration: none !important;
    outline: none;
}

.ai-add-all--loading,
.ai-add-all--done {
    pointer-events: none;
    cursor: default;
}

.ai-add-all--loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ai-add-all--loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: ai-add-all-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes ai-add-all-spin {
    to { transform: rotate(360deg); }
}

/* ===== TYPING INDICATOR ===== */
.ai-assistant__typing {
    align-self: flex-start;
    background: #f8f8f8;
    border-radius: 16px;
    border-bottom-left-radius: 0;
    padding: 12px 16px;
    display: none;
}

.ai-assistant__typing--visible {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ai-assistant__typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ai-assistant__typing-text {
    color: #9da3af;
    font-size: 14px;
    font-weight: bold;
}

.ai-assistant__typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: ai-assistant__bounce 1.4s infinite;
}

.ai-assistant__typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-assistant__typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-assistant__bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ===== FILE CHIP ===== */
.ai-assistant__file-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    margin: 6px 12px 0 12px;
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    font-size: 13px;
    color: #2e5e45;
    flex-shrink: 0;
}

.ai-assistant__file-chip-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-assistant__file-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.ai-assistant__file-chip-remove:hover {
    background: #fecaca;
    color: #dc2626;
}

/* ===== ATTACH BUTTON ===== */
.ai-assistant__attach {
    position: absolute;
    right: 52px;
    bottom: 11px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
    color: #9ca3af;
    padding-top: 2px;
}

.ai-assistant__attach:hover {
    background: rgba(41, 94, 69, 0.08);
    color: #295e45;
}

/* ===== INPUT AREA ===== */
.ai-assistant__input-area {
    padding: 8px 12px;
    display: flex;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
    position: relative;
}

.ai-assistant__input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 88px 10px 16px;
    font-size: 16px;
    outline: none;
    resize: none;
    font-family: inherit;
    text-align: left;
    color: #1f2937;
    background: #efefef;
    max-height: 160px;
    overflow-y: auto;
    scrollbar-width: none;
}

.ai-assistant__input::-webkit-scrollbar {
    display: none;
}

.ai-assistant__input::placeholder {
    color: #9ca3af;
    font-size: 16px;
    text-align: left;
}

.ai-assistant__send {
    position: absolute;
    right: 16px;
    bottom: 11px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, opacity 0.2s;
    padding-left: 5px;
}

.ai-assistant__send:hover {
    background: rgba(41, 94, 69, 0.08);
}

.ai-assistant__send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: transparent;
}

.ai-assistant__send svg {
    width: 24px;
    height: 24px;
    fill: #295e45;
}

/* ===== RESIZE HANDLE ===== */
.ai-assistant__resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 28px;
    cursor: nesw-resize;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 5px 5px 0 0;
    z-index: 10;
    opacity: 0.35;
    transition: opacity 0.2s;
}

.ai-assistant__resize-handle:hover {
    opacity: 0.8;
}

.ai-assistant__resize-handle svg {
    pointer-events: none;
    flex-shrink: 0;
}

/* Скрываем ручку ресайза на мобильных */
@media (max-width: 480px) {
    .ai-assistant__resize-handle {
        display: none;
    }
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 480px) {
    .ai-assistant__panel {
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .ai-assistant__fab {
        bottom: 58px;
        left: 10px;
        padding: 0 15px 0 15px;
        border-radius: 24px;
    }

    .ai-assistant__fab-label {
        font-size: 13px;
    }
}
