/* chat.css — панель чата проектирования */

.aichat {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 0;
    border-radius: 0;
    font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
    z-index: 999;
    overflow: hidden;
    height: 100%;

    /* маскот: спрайт 1003×326, 4 кадра по 246 px, шаг 252 px,
       полезная высота кадра 313 px */
    --mascot-url: url(/img/mascot6.png);
    --mascot-w: 40px;


}
.ai_mini_case .aichat{
    position: relative;
}

.aichat_actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.aichat_tokens {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    opacity: .8;
    white-space: nowrap;
}

.aichat_topup {
    font-size: 12px;
    white-space: nowrap;
        color: var(--font-color2);
    text-decoration: underline;
}
.aichat_send {
    margin-left: auto;     /* кнопка уходит вправо, токены и ссылка остаются слева */
}


.aichat_head {
    padding: 10px 15px;
    margin: 0;
    font-size: 12px;
    color: var(--font-color);
    position: relative;
    line-height: 1.2;
    cursor: pointer;
}
.aichat_head span{
    color: #fff;
}
.aichat_head:after {
    display: inline-flex;
    content: "";
    background-image: url(/img/arrow_down_black.svg);
    background-size: 100%;
    height: 18px;
    width: 18px;
    position: relative;
    top: 8px;
    background-repeat: no-repeat;
    position: absolute;
    right: 11px;
    opacity: 0.5;
    filter: var(--filter-icon);
    transform: rotate(180deg);
}

.aichat_collapsed .aichat_head:after {
    transform: rotate(0deg);
}
.aichat_collapsed .aichat_head {
    border-bottom: 1px solid var(--brd-color);
}
.aichat_toggle {
    background: none;
    border: 0;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    padding: 0 4px;
}
.aichat_mat_text{
    padding: 0 12px;
    font-size: 12px;
    border-top: 1px solid #eef0f2;
    padding-top: 5px;
}
.aichat_collapsed .aichat_messages,
.aichat_collapsed .aichat_chip,
.aichat_collapsed .aichat_materials,
.aichat_collapsed .aichat_inputrow,
.aichat_collapsed .aichat_mat_text,
.aichat_collapsed .aichat_warning {
    display: none !important;
}
.aichat_warn{
    color:#222;
}
.aichat_warning{
    font-size: 12px;
    text-align: center;
    background: #f7f7f7;
    color: #333;
    padding: 5px 12px;
    line-height: 1.2;

    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.aichat_powered{
    min-height: auto;
}
.ai_logo_link{
    font-size: 10px; 
    font-weight: bold;
}
.ai_mini_case .aichat_collapsed .aichat_head{
    line-height: 50px;
    display: flex;
    align-items: center;
    font-size: 16px;
    height: 50px;
    box-sizing: border-box;
}
.ai_mini_case .aichat_collapsed .aichat_head:after{
    top:auto;
}
.ai_mini_case:has(.aichat_collapsed) {
    border-radius: 50px;
    max-width: max-content;
}

.ai_mini_case:has(.aichat_collapsed) .aichat_head:after{
    position: relative;
    right: auto;
}

/* ── маскот (спрайт) ── */
.aichat_mascot {
    flex: 0 0 auto;
    width: var(--mascot-w);
    height: calc(var(--mascot-w) * 313 / 246);
    background-image: var(--mascot-url);
    background-repeat: no-repeat;
    background-size: calc(var(--mascot-w) * 1003 / 246) auto;
    background-position: 0 0;
    /* тёмная тема: раскомментировать
    filter: var(--filter-icon); */
}

/* 0 — палец (подсказка) │ 1 — лайк (успех) │ 2 — растерян (ошибка) │ 3 — нейтральный (думает) */
.aichat_mascot[data-m="0"] { background-position: calc(var(--mascot-w) * -756 / 246) 0; }
.aichat_mascot[data-m="1"] { background-position: calc(var(--mascot-w) * -252 / 246) 0; }
.aichat_mascot[data-m="2"] { background-position: calc(var(--mascot-w) * -504 / 246) 0; }
.aichat_mascot[data-m="3"] { background-position: 0 0; }

/* ── выбор материала для новых модулей ── */
.aichat_materials {
    display: flex;
    gap: 8px;
    padding: 0px 12px ;
    flex: 0 0 auto;
}

.aichat_matbtn {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 6px 8px;
    background: #f7f9fb;
    border: 1px solid #dde2e7;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: border-color .12s, background .12s;
}

.aichat_matbtn:hover {
    border-color: #0D99FF;
    background: #f0f8ff;
}

.aichat_matbtn_sw {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    object-fit: cover;
    border: 1px solid #cfd6dd;
    flex: 0 0 auto;
    background: #e9edf1;
}

.aichat_matbtn_txt {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.aichat_matbtn_role {
    font-size: 11px;
    color: #7a828b;
}

.aichat_matbtn_name {
    font-size: 9px;
    color: #222;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aichat_messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;

}
.ai_mini_case .aichat_messages{
    min-height: 250px;
    max-height: 250px;
}


/* Замечание — не отказ: мебель построена, просто стоит посмотреть.
   Поэтому цветная только иконка, текст обычный. */
.aichat_warn {
    position: relative;
    margin-top: 10px;
    padding-left: 22px;
    white-space: pre-line;
}
.aichat_warn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 2px;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23e0a800'%3E%3Cpath d='M12 2 1 21h22L12 2zm1 15h-2v-2h2v2zm0-4h-2V8h2v5z'/%3E%3C/svg%3E") no-repeat center/contain;
}
/* ── строка сообщения: [маскот] + пузырь ── */
.aichat_row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

.aichat_row_user      { justify-content: flex-end; }
.aichat_row_assistant { justify-content: flex-start; }

.aichat_row_assistant .aichat_mascot {
    --mascot-w: 34px;
    animation: aichat-pop .22s ease-out;
}

@keyframes aichat-pop {
    from { transform: translateY(6px) scale(.9); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

.aichat_msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    white-space: pre-wrap;
    word-break: break-word;
            -webkit-user-select:text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select:text;
    user-select: text;
}

.aichat_msg_user {
    background: #0D99FF;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.aichat_msg_assistant {
    background: #f1f3f5;
    color: #222;
    border-bottom-left-radius: 4px;
}

.aichat_chip {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 12px 6px;
    padding: 5px 10px;
    background: #e8f4ff;
    border: 1px solid #b8dfff;
    border-radius: 16px;
    color: #0b6ec2;
    font-size: 12.5px;
    flex: 0 0 auto;
}

.aichat_chip_label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #222;
}

.aichat_chip_x {
    background: none;
    border: 0;
    color: #0b6ec2;
    cursor: pointer;
    font-size: 12px;
    padding: 0 2px;
    display: none;
}

/* объект вне зоны ИИ — красный чип */
.aichat_chip.is-locked{
    background:#fdecec;
    border:1px solid #fdecec;
}

.aichat_chip.is-locked .aichat_chip_x{ color:#b42318; }

/* заблокированный ввод */
.aichat_locked .aichat_input{
    color:#9a9a9a;
    cursor:not-allowed;
}

/* ── ввод: textarea во всю ширину, кнопка снизу справа ── */
.aichat_inputrow {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 12px;
    flex: 0 0 auto;
    padding-bottom: 8px;
}

.aichat_input {
    width: 100%;
    box-sizing: border-box;
    min-height: 66px;
    max-height: 180px;
    resize: none;
    border: 1px solid #d7dbe0;
    border-radius: 8px;
    padding: 9px 11px;
    font: inherit;
    outline: none;
    overflow-y: auto;
}

.aichat_input:focus { border-color: #0D99FF; }


.aichat_send {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 8px;
    background: #0D99FF;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    flex: 0 0 auto;
}

.aichat_send:disabled {
    background: #ccc;
    cursor: default;
}

/* слот справа от кнопки: маскот + точки.
   min-width держит место постоянно, чтобы кнопка не прыгала */
.aichat_status {
    --mascot-w: 34px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    min-width: calc(var(--mascot-w) + 6px + 33px);
    opacity: 0;
    transition: opacity .15s;
    pointer-events: none;
}

.aichat_status.is-on { opacity: 1; }

/* .aichat_status .aichat_mascot {
    animation: aichat-bob 1.1s ease-in-out infinite;
} */

@keyframes aichat-bob {
    0%, 100% { transform: translateY(0)    rotate(0deg); }
    50%      { transform: translateY(-3px) rotate(-4deg); }
}

.aichat_typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
}

.aichat_typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ec9ec;
    animation: aichat-b 1s infinite;
}

.aichat_typing span:nth-child(2) { animation-delay: .15s; }
.aichat_typing span:nth-child(3) { animation-delay: .3s; }

@keyframes aichat-b {
    0%, 100% { transform: translateY(0); opacity: .5; }
    50%      { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .aichat_status .aichat_mascot,
    .aichat_row_assistant .aichat_mascot,
    .aichat_typing span { animation: none; }
}

@media (max-width: 640px) {

    .ai_mini_case {
        right: 15px;
        left: 15px;
        width: auto;
        bottom: 75px;
        max-width: unset;
    }
    .aichat_input { min-height: 64px; }


    .ai_mini_case:has(.aichat_collapsed) {
        left: auto;
    }
}



/* specForm.css — панель настроек спецификации (вставляется в контейнер) */

.specform {
    color: #222;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    overflow-y: auto;
    width: 100%;
    padding-bottom: 15px;
}

.specform_empty {
    color: #8a929b;
    text-align: center;
    padding: 24px 12px;
    font-size: 13px;
}

.specform_title {
    font-size: 15px;
    font-weight: 700;
    color: #0D99FF;
    padding-bottom: 4px;
    display: none;
    border-bottom: 1px solid #eef0f2;
}

.specform_section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.specform_section_h {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #8a929b;
    margin-top: 4px;
}

.specform_row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.specform_lbl {
    flex: 0 0 auto;
}

.specform_num,
.specform_sel {
    flex: 0 0 auto;
    width: 110px;
    border: 1px solid var(--input-brd-color);
    border-radius: 6px;
    padding: 5px 8px;
    font: inherit;
    outline: none;
        background: var(--txta-bg);
    flex: 1;
    max-width: 80px;
}



.specform_node {
    border-left: 2px solid #eef0f2;
    padding: 6px 0 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.specform_fill {
    font-size: 12px;
    color: #8a929b;
    font-style: italic;
}

.specform_sub {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.6;
}

.specform_front {
    background: var(--bg2-color);
    border: 0;
    border-radius: 6px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.specform_rot {
    display: flex;
    align-items: center;
    gap: 8px;
}

.specform_rotval {
    font-weight: 600;
   
    min-width: 34px;
    text-align: right;
}

.specform_rotbtn {
    border:0;
    border-radius: 6px;
    background: var(--btn-color);
    padding: 5px 10px;
    font: inherit;
    cursor: pointer;
}



.specform_apply {
    margin-top: 6px;
    border: 0;
    border-radius: 8px;
    background: #0D99FF;
    color: #fff;
    font: inherit;
    font-weight: 600;
    padding: 10px;
    cursor: pointer;
}

.specform_apply:hover { background: #0b86e0; }
.specform_apply:active { background: #0a78c9; }

.specform_notice {
    display: none;
    font-size: 12px;
    padding: 7px 9px;
    border-radius: 6px;
    background: #eef7ee;
    color: #2b6a2f;
    border: 1px solid #cfe6d0;
}

.specform_notice_err {
    background: #fdeeee;
    color: #a12b2b;
    border-color: #f2c9c9;
}

.specform_nodehead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.specform_nodecap {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.6;
}

.specform_del {
    border: 0;
    background: none;
    color: #b9c0c7;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
}

.specform_del:hover {
    color:#000000;
}

.specform_shelves {
    background: #f7f9fb;
    border: 1px solid #e6eaee;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.specform_convert {
    border: 0;
    border-radius: 6px;
    padding: 6px 8px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    background: var(--btn-color);
}


.specform_advbtn {
    border-radius: 8px;
    background: var(--btn-color);
    padding: 9px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    position: relative;
        border: 0;
}



.specform_advbtn:after {
    display: inline-flex;
    content: "";
    background-image: url(/img/arrow_down_black.svg);
    background-size: 100%;
    height: 18px;
    width: 18px;
    position: relative;
    top: 8px;
    background-repeat: no-repeat;
    position: absolute;
    right: 11px;
    opacity: 0.5;
    filter: var(--filter-icon);
}
.specform_open:after {
    transform: rotate(180deg);
}







/* ────────────────────────────────────────────────────────────────────────
 * Inline-кнопки выбора типа мебели в потоке чата (chat.js → renderChoices).
 * Кладутся в тот же .aichat_messages, что и обычные сообщения, и должны
 * читаться как варианты ответа ассистента, а не как форма.
 * Подгоните цвета под свои переменные — здесь нейтральный минимум.
 * ──────────────────────────────────────────────────────────────────────── */

.aichat_choices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 2px 0 10px;
    /* выравнивание под пузырь ассистента: если у .aichat_row_assistant
       есть отступ слева под маскота, кнопки встанут по той же линии */
}

.aichat_choice {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #d6dae0;
    background: #fff;
    color: #1f2430;
    border-radius: 16px;
    padding: 6px 14px;
    font: inherit;
    font-size: 13px;
    line-height: 18px;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}

.aichat_choice:hover {
    border-color: #0d99ff;
    color: #0d99ff;
}

.aichat_choice:active {
    background: #0d99ff;
    border-color: #0d99ff;
    color: #fff;
}

.aichat_choice:focus-visible {
    outline: 2px solid #0d99ff;
    outline-offset: 1px;
}

/* тёмная тема — если она у вас есть; иначе блок можно удалить */
@media (prefers-color-scheme: dark) {
    .aichat_choice {
        border-color: #3a4150;
        background: #212633;
        color: #e6e9ef;
    }
}