/* ИИ-чат подбора запчастей: floating-панель над плитками каталогов. */

.is-disabled {
    pointer-events: none;
    cursor: default;
}

.ai-chat {
    --ai-accent: var(--ps-brand, #0083ca);
    --ai-accent-dark: #0071b0;
    --ai-user-bubble: #3ba6db;
    position: fixed;
    top: 18vh;
    left: 16px;
    z-index: 1500;
    display: none;
    flex-direction: column;
    min-width: 300px;
    min-height: 240px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 40, 70, 0.25);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: #1c2333;
    overflow: hidden;
}

.ai-chat.is-visible {
    display: flex;
}

.ai-chat__header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: var(--ai-accent);
    color: #ffffff;
    cursor: move;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.ai-chat__header:active {
    cursor: grabbing;
}

.ai-chat__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    white-space: normal;
}

.ai-chat__toggle {
    flex: 0 0 auto;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.ai-chat__body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ai-chat__log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    background: #eef1f6;
}

.ai-chat__hint {
    color: #7b8498;
    font-size: 13px;
    line-height: 1.45;
    padding: 10px 12px;
    background: #e7eaf0;
    border-radius: 12px;
    border-top-left-radius: 4px;
    align-self: flex-start;
    max-width: 88%;
}

.ai-chat__bubble {
    max-width: 84%;
    padding: 9px 13px;
    border-radius: 13px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.ai-chat__bubble--user {
    align-self: flex-end;
    background: var(--ai-user-bubble);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ai-chat__bubble--assistant {
    align-self: flex-start;
    background: #ffffff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(20, 40, 90, 0.08);
}

.ai-chat__bubble--error {
    align-self: center;
    background: #fdecec;
    color: #a11;
    font-size: 13px;
}

.ai-chat__words {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.ai-chat__chip {
    display: inline-block;
    padding: 5px 10px;
    background: #e7f4fb;
    border: 1px solid #b8ddf1;
    border-radius: 999px;
    color: var(--ai-accent-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}

.ai-chat__chip:hover {
    background: #d3ebf7;
}

.ai-chat__dots {
    display: inline-flex;
    gap: 5px;
    padding: 4px 0;
}

.ai-chat__dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7b8498;
    animation: ai-chat-pulse 1.2s infinite ease-in-out;
}

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

@keyframes ai-chat-pulse {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

.ai-chat__footer {
    flex: 0 0 auto;
    border-top: 1px solid #dde2ea;
    padding: 10px 12px;
    background: #ffffff;
}

.ai-chat__disclaimer {
    font-size: 11px;
    color: #7b8498;
    line-height: 1.35;
    margin-bottom: 8px;
}

.ai-chat__form {
    display: flex;
    gap: 8px;
}

.ai-chat__input {
    flex: 1;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid #c9d1de;
    border-radius: 10px;
    min-width: 0;
}

.ai-chat__send {
    padding: 9px 16px;
    font-size: 14px;
    border: none;
    border-radius: 10px;
    background: var(--ai-accent);
    color: #ffffff;
    cursor: pointer;
}

.ai-chat__send:hover { filter: brightness(1.08); }

.ai-chat__send:disabled,
.ai-chat__input:disabled {
    opacity: 0.65;
    cursor: progress;
}

.ai-chat__actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
    padding-right: 16px;
}

.ai-chat__reset {
    border: none;
    background: none;
    color: var(--ai-accent-dark);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

.ai-chat__reset:hover { text-decoration: underline; }

.ai-chat__resizer {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    touch-action: none;
    background:
        linear-gradient(135deg, transparent 0 50%, var(--ai-accent) 50% 60%,
            transparent 60% 70%, var(--ai-accent) 70% 80%, transparent 80%);
    opacity: 0.6;
}

.ai-chat__resizer:hover {
    opacity: 1;
}

/* Кнопка «ИИ-подбор» в шапке, над «Каталог». Выравнивается по верхней
   границе блока поиска (без утопления вниз). */
.nav-catalog {
    margin-top: 0;
}

.nav-ai-btn {
    position: relative;
    width: 170px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    margin-bottom: 8px;
    text-transform: uppercase;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    line-height: 20px;
    color: #ffffff;
    background: linear-gradient(135deg, #00a0e9 0%, #0071b0 100%);
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 113, 176, 0.35);
    animation: nav-ai-glow 2.4s ease-out infinite;
    transition: transform 0.12s ease;
}

.nav-ai-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.nav-ai-btn__text {
    white-space: nowrap;
}

.nav-ai-btn__icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: #ffffff;
}

/* Бейдж «NEW», чтобы кнопка читалась как новинка. */
.nav-ai-btn::after {
    content: 'NEW';
    position: absolute;
    top: -8px;
    right: -8px;
    padding: 3px 5px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.5px;
    color: #ffffff;
    background: #e74c3c;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

@keyframes nav-ai-glow {
    0% { box-shadow: 0 2px 8px rgba(0, 113, 176, 0.35), 0 0 0 0 rgba(0, 160, 233, 0.55); }
    70% { box-shadow: 0 2px 8px rgba(0, 113, 176, 0.35), 0 0 0 9px rgba(0, 160, 233, 0); }
    100% { box-shadow: 0 2px 8px rgba(0, 113, 176, 0.35), 0 0 0 0 rgba(0, 160, 233, 0); }
}
