/* Віджет AI-чату Daikin AIR */
.chat-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 250;
    font-family: 'Lato', 'Segoe UI', Arial, sans-serif;
}
@media (max-width: 767px) {
    /* над липкою панеллю дій */
    .chat-widget { bottom: calc(74px + env(safe-area-inset-bottom)); right: 14px; }
}

.chat-toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--c-orange, #FF6D00);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(255, 109, 0, .4);
    transition: transform .15s, background-color .15s;
}
.chat-toggle:hover { transform: scale(1.06); background: #E45F00; }
.chat-toggle .icon-close { display: none; }
.chat-toggle.is-open .icon-chat { display: none; }
.chat-toggle.is-open .icon-close { display: block; }

.chat-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 360px;
    max-width: calc(100vw - 28px);
    height: 480px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(24, 24, 24, .22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-panel[hidden] { display: none; }

.chat-head {
    background: var(--c-dark, #181818);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-head-title { font-weight: 700; font-size: 15px; }
.chat-status { font-size: 12px; color: #9fd89f; }
.chat-close {
    margin-left: auto;
    color: #ccc;
    font-size: 26px;
    line-height: 1;
    padding: 0 4px;
}
.chat-close:hover { color: #fff; }

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: var(--c-card, #F9FBFC);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-msg--bot {
    background: #fff;
    border: 1px solid var(--c-line-soft, #E9EBEB);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-msg--user {
    background: var(--c-orange, #FF6D00);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-msg--system {
    align-self: center;
    background: none;
    color: var(--c-muted, #696B70);
    font-size: 12.5px;
    text-align: center;
    padding: 2px 8px;
}
.chat-msg-who {
    font-size: 11px;
    font-weight: 700;
    color: var(--c-daikin, #0097E0);
    margin-bottom: 3px;
}

/* Посилання у повідомленнях менеджера/бота — кнопкою */
.chat-msg .chat-link {
    display: inline-block;
    margin: 6px 0 2px;
    padding: 8px 14px;
    background: var(--c-orange, #FF6D00);
    color: #fff;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-all;
}
.chat-msg .chat-link:hover { background: #E45F00; }

.chat-typing { display: flex; gap: 4px; padding: 12px 14px; }
.chat-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--c-muted, #696B70);
    animation: chat-blink 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chat-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.chat-fallback {
    background: #fff;
    border: 1px solid var(--c-line-soft, #E9EBEB);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
}
.chat-fallback input {
    padding: 9px 12px;
    border: 1px solid var(--c-line, #DADBDB);
    border-radius: 4px;
    font: inherit;
}
.chat-fallback input.invalid { border-color: #d33; }
.chat-fallback .btn { padding: 10px 16px; font-size: 14px; }

.chat-form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--c-line-soft, #E9EBEB);
    background: #fff;
}
.chat-form textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--c-line, #DADBDB);
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
    height: 42px;
    max-height: 90px;
}
.chat-form textarea:focus { outline: none; border-color: var(--c-daikin, #0097E0); }
.chat-form button {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--c-orange, #FF6D00);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-form button:hover { background: #E45F00; }
.chat-form button:disabled { opacity: .5; }

.chat-note {
    font-size: 11px;
    color: var(--c-muted, #696B70);
    text-align: center;
    padding: 0 10px 8px;
    background: #fff;
}
