/* Превью интерфейса продукта — блок .product-chat-preview */
.chat-container.product-chat-preview {
    --p-bg: #0d0d0d;
    --p-surface: #1a1a1a;
    --p-surface-2: #242424;
    --p-border: #2e2e2e;
    --p-text: #ececec;
    --p-muted: #a3a3a3;
    --p-dim: #737373;
    --p-accent: #d4d4d8;
    --p-accent-ink: #171717;
    --p-query-bg: #1c1810;
    --p-query-border: #3d3520;
    --p-query-ink: #ffd54f;
    max-width: 800px;
    margin: 0 auto;
    background: var(--p-bg);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06);
    border: 1px solid var(--p-border);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.premium-laptop__viewport .chat-container.product-chat-preview {
    max-width: none;
    width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
}
.product-chat-preview .chat-messages {
    padding: 24px 20px 20px;
    min-height: 360px;
    background: var(--p-bg);
}
.product-chat-preview--fixed-messages .chat-messages {
    box-sizing: border-box;
    min-height: 420px;
    height: 420px;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: auto;
}
.product-chat-preview .chat-message.ai {
    transition: opacity 0.07s ease, transform 0.07s ease;
}
.product-chat-preview .chat-message.ai.demo-ai--out {
    opacity: 0;
    transform: translateY(6px);
}
.product-chat-preview .chat-message.ai.demo-ai--in {
    animation: demoAiReveal 0.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes demoAiReveal {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.product-chat-preview .chat-message.user .chat-bubble.demo-q-pop {
    animation: demoQPop 0.16s ease-out;
}
@keyframes demoQPop {
    from { opacity: 0.45; transform: translateX(5px) scale(0.985); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
.product-chat-preview .chat-message.user .chat-bubble.demo-q-pending {
    opacity: 0;
    transform: translateX(6px) scale(0.98);
}
.product-chat-preview .chat-input-box.demo-input-typing input {
    caret-color: #fbbf24;
}
.product-chat-preview .demo-ai-cursor {
    display: inline-block;
    width: 8px;
    height: 1.05em;
    min-height: 14px;
    background: rgba(228, 228, 231, 0.9);
    border-radius: 2px;
    vertical-align: text-bottom;
    margin: 2px 0 8px;
    animation: demoAiCaretBlink 0.8s step-end infinite;
}
@keyframes demoAiCaretBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.12; }
}
.product-chat-preview .demo-ai-streaming-text::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 0.95em;
    margin-left: 1px;
    vertical-align: -0.06em;
    background: rgba(228, 228, 231, 0.85);
    animation: demoAiCaretBlink 0.8s step-end infinite;
}
.product-chat-preview .demo-ai-chunk {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}
.product-chat-preview .demo-ai-chunk--in {
    opacity: 1;
    transform: translateY(0);
}
@keyframes demoVizBarIn {
    from { transform: scaleX(0.08); opacity: 0.35; }
    to { transform: scaleX(1); opacity: 1; }
}
@keyframes demoVizFadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.product-chat-preview .viz-live .act-bytype__block {
    transform-origin: left center;
    animation: demoVizBarIn 0.48s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.product-chat-preview .viz-live .act-bytype__row:nth-child(1) .act-bytype__block { animation-delay: 0.05s; }
.product-chat-preview .viz-live .act-bytype__row:nth-child(2) .act-bytype__block { animation-delay: 0.12s; }
.product-chat-preview .viz-live .act-bytype__row:nth-child(3) .act-bytype__block { animation-delay: 0.19s; }
.product-chat-preview .viz-live .act-bytype__row:nth-child(4) .act-bytype__block { animation-delay: 0.26s; }
.product-chat-preview .viz-live .act-bytype__row:nth-child(5) .act-bytype__block { animation-delay: 0.33s; }
.product-chat-preview .viz-live .exp-donut__leg-item,
.product-chat-preview .viz-live .exp-det-chips__group {
    animation: demoVizFadeUp 0.42s ease backwards;
}
.product-chat-preview .viz-live .exp-donut__leg-item:nth-child(1) { animation-delay: 0.05s; }
.product-chat-preview .viz-live .exp-donut__leg-item:nth-child(2) { animation-delay: 0.11s; }
.product-chat-preview .viz-live .exp-donut__leg-item:nth-child(3) { animation-delay: 0.17s; }
.product-chat-preview .viz-live .exp-donut__leg-item:nth-child(4) { animation-delay: 0.23s; }
.product-chat-preview .viz-live .exp-donut__leg-item:nth-child(5) { animation-delay: 0.29s; }
.product-chat-preview .viz-live .exp-det-chips__group:nth-child(1) { animation-delay: 0.08s; }
.product-chat-preview .viz-live .exp-det-chips__group:nth-child(2) { animation-delay: 0.14s; }
.product-chat-preview .viz-live .exp-det-chips__group:nth-child(3) { animation-delay: 0.2s; }
.product-chat-preview .viz-live .call-dropdown__item {
    animation: demoVizFadeUp 0.42s ease backwards;
}
.product-chat-preview .viz-live .call-dropdown__item:nth-child(1) { animation-delay: 0.04s; }
.product-chat-preview .viz-live .call-dropdown__item:nth-child(2) { animation-delay: 0.1s; }
.product-chat-preview .viz-live .call-dropdown__item:nth-child(3) { animation-delay: 0.16s; }
.product-chat-preview .viz-live .call-dropdown__item:nth-child(4) { animation-delay: 0.22s; }
.product-chat-preview .viz-live .call-dropdown__item:nth-child(5) { animation-delay: 0.28s; }
@media (prefers-reduced-motion: reduce) {
    .product-chat-preview .chat-message.ai { transition: none; }
    .product-chat-preview .chat-message.ai.demo-ai--out {
        opacity: 1;
        transform: none;
    }
    .product-chat-preview .chat-message.ai.demo-ai--in { animation: none; }
    .product-chat-preview .chat-message.user .chat-bubble.demo-q-pop { animation: none; }
    .product-chat-preview .chat-message.user .chat-bubble.demo-q-pending {
        opacity: 1;
        transform: none;
    }
    .product-chat-preview .demo-ai-cursor,
    .product-chat-preview .demo-ai-streaming-text::after { display: none; animation: none; }
    .product-chat-preview .demo-ai-chunk,
    .product-chat-preview .demo-ai-chunk--in {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .product-chat-preview .viz-live .act-bytype__block,
    .product-chat-preview .viz-live .exp-donut__leg-item,
    .product-chat-preview .viz-live .exp-det-chips__group,
    .product-chat-preview .viz-live .call-dropdown__item {
        animation: none;
    }
}
.product-chat-preview .chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    align-items: flex-start;
}
.product-chat-preview .chat-message.user {
    justify-content: flex-end;
}
.product-chat-preview .chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}
.product-chat-preview .chat-avatar.user-avatar {
    background: #52525b;
    color: #fafafa;
}
.product-chat-preview .chat-avatar.ai-avatar {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    color: var(--p-muted);
}
.product-chat-preview .chat-bubble { max-width: min(88%, 620px); }
.product-chat-preview .chat-message.user .chat-bubble {
    background: var(--p-query-bg);
    border: 1px solid var(--p-query-border);
    border-radius: 18px;
    padding: 14px 18px;
    color: var(--p-query-ink);
    font-size: 0.9375rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.product-chat-preview .chat-message.ai .chat-content {
    color: var(--p-muted);
    line-height: 1.65;
    font-size: 0.9375rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
}
.product-chat-preview .chat-message.ai .chat-content p { margin-bottom: 12px; color: var(--p-text); }
.product-chat-preview .chat-message.ai .chat-content strong { color: var(--p-text); font-weight: 600; }
.product-chat-preview .chat-message.ai .chat-content ul { margin: 10px 0; padding-left: 0; list-style: none; }
.product-chat-preview .chat-message.ai .chat-content li {
    padding: 6px 0 6px 20px;
    position: relative;
    color: var(--p-text);
}
.product-chat-preview .chat-message.ai .chat-content li::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 13px;
    width: 5px;
    height: 5px;
    background: var(--p-accent);
    border-radius: 50%;
}
.product-chat-preview .chat-message.ai .chat-content .detail {
    color: var(--p-muted);
    font-size: 0.8125rem;
    margin-left: 0;
    margin-top: 4px;
}
.product-chat-preview .chat-sources {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--p-border);
}
.product-chat-preview .chat-sources-title {
    color: var(--p-dim);
    font-size: 0.75rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.product-chat-preview .chat-source-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--p-surface);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8125rem;
    color: var(--p-muted);
    margin: 4px 4px 4px 0;
    border: 1px solid var(--p-border);
}
.product-chat-preview .chat-source-tag:hover {
    border-color: var(--p-accent);
    color: var(--p-text);
}
.product-chat-preview .chat-input-area {
    background: linear-gradient(to top, var(--p-bg) 60%, transparent);
    padding: 12px 16px 18px;
    border-top: none;
}
.product-chat-preview .chat-input-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--p-surface);
    border-radius: 9999px;
    padding: 8px 10px 8px 14px;
    border: 1px solid var(--p-border);
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.product-chat-preview .chat-input-box .product-composer-attach {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: var(--p-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    flex-shrink: 0;
}
.product-chat-preview .chat-input-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--p-text);
    font-size: 0.9375rem;
    outline: none;
    min-width: 0;
}
.product-chat-preview .chat-input-box input::placeholder { color: var(--p-dim); }
.product-chat-preview .product-composer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.product-chat-preview .product-composer-actions button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    flex-shrink: 0;
}
.product-chat-preview .product-composer-actions .product-btn-accent {
    background: var(--p-accent);
    color: var(--p-accent-ink);
}
.product-chat-preview .product-composer-actions .product-btn-ghost {
    background: transparent;
    color: var(--p-muted);
}

@media (max-width: 900px) {
    .chat-container.product-chat-preview { margin: 0 10px; }
    .premium-laptop__viewport .chat-container.product-chat-preview { margin: 0; }
}

@media (max-width: 720px) {
    .product-chat-preview .chat-messages {
        padding: 16px 14px 14px;
    }
    /* Отступ под Dynamic Island (он накладывается поверх viewport) */
    .premium-laptop__viewport .chat-messages {
        padding-top: 38px;
    }
    .premium-laptop__viewport .product-chat-preview--fixed-messages .chat-messages {
        min-height: 620px;
        height: 620px;
        max-height: 620px;
    }
    .product-chat-preview--fixed-messages .chat-messages {
        min-height: 360px;
        height: 360px;
        max-height: 360px;
    }
    .product-chat-preview .chat-message {
        gap: 10px;
        margin-bottom: 18px;
    }
    .product-chat-preview .chat-message.user .chat-bubble,
    .product-chat-preview .chat-message.ai .chat-content {
        font-size: 0.875rem;
    }
    .product-chat-preview .chat-bubble {
        max-width: min(92%, 620px);
    }
    .product-chat-preview .chat-input-area {
        padding: 10px 12px 14px;
    }
    .product-chat-preview .chat-input-box {
        gap: 6px;
        padding: 6px 8px 6px 10px;
    }
    .product-chat-preview .chat-input-box input {
        font-size: 0.875rem;
    }
    .product-chat-preview .chat-input-box .product-composer-attach,
    .product-chat-preview .product-composer-actions button {
        width: 32px;
        height: 32px;
    }
    .product-chat-preview .product-composer-actions button svg {
        width: 16px;
        height: 16px;
    }
    .product-chat-preview .chat-source-tag {
        font-size: 0.75rem;
        padding: 5px 10px;
    }
}

@media (max-width: 520px) {
    .premium-laptop__viewport .product-chat-preview--fixed-messages .chat-messages {
        min-height: 560px;
        height: 560px;
        max-height: 560px;
    }
    .product-chat-preview--fixed-messages .chat-messages {
        min-height: 320px;
        height: 320px;
        max-height: 320px;
    }
    .product-chat-preview .chat-input-box .product-composer-attach {
        display: none;
    }
    .product-chat-preview .chat-input-box {
        padding-left: 12px;
    }
}

html[data-color-scheme="light"] .chat-container.product-chat-preview {
    --p-bg: #ffffff;
    --p-surface: #f1f5f9;
    --p-surface-2: #e2e8f0;
    --p-border: #cbd5e1;
    --p-text: #0f172a;
    --p-muted: #475569;
    --p-dim: #64748b;
    --p-accent: #2563eb;
    --p-accent-ink: #ffffff;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.1), 0 0 0 1px #cbd5e1;
}
html[data-color-scheme="light"] .premium-laptop__viewport .chat-container.product-chat-preview {
    box-shadow: none;
    border: none;
}
html[data-color-scheme="light"] .product-chat-preview .chat-input-box {
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.08);
}
html[data-color-scheme="light"] .product-chat-preview .chat-message.user .chat-bubble {
    background: #1c1810;
    border-color: #3d3520;
    color: #ffd54f;
}
html[data-color-scheme="light"] .product-chat-preview .chat-avatar.user-avatar {
    background: #3b82f6;
    color: #fff;
}
