/* AI-chat widget — стиль под бренд center-clinic (--hoverColor, Manrope) */
#aiChatRoot {
    position: fixed; right: 30px; bottom: 30px; z-index: 9998;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --aichat-accent: var(--hoverColor, #e1612c);
    --aichat-accent-hover: var(--hoverColor, #c8531f);
    --aichat-border: #e8ebee;
    --aichat-bg: #fff;
    --aichat-bg-soft: #f6f7f9;
    --aichat-text: #1f2937;
    --aichat-muted: #6b7280;
}

#aiChatLauncher {
    position: relative;
    width: 92px; height: 92px; border-radius: 50%;
    border: 0; background: var(--aichat-accent); color: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: transform .2s ease, background .2s;
}
#aiChatLauncher::before {
    content: ''; position: absolute; inset: 0;
    border-radius: 50%; pointer-events: none;
    background: rgba(60, 190, 140, .85);
    animation: aichat-launcher-wave 2.4s ease-out infinite;
    z-index: -1;
}
#aiChatLauncher:hover { transform: scale(1.06); background: var(--aichat-accent-hover); }
#aiChatLauncher:hover::before,
#aiChatLauncher.is-open::before { animation: none; opacity: 0; }
#aiChatLauncher.is-open { background: #6c757d; }
@keyframes aichat-launcher-wave {
    0%   { transform: scale(1);   opacity: .9; }
    100% { transform: scale(1.6); opacity: 0; }
}
.aichat__unread {
    position: absolute; top: 2px; right: 2px;
    min-width: 22px; height: 22px; padding: 0 6px;
    border-radius: 11px; background: #d9322a; color: #fff;
    font-size: 12px; font-weight: 700; line-height: 22px;
    text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.25);
    box-sizing: border-box;
    animation: aichat-pulse 1.6s ease-in-out infinite;
}
@keyframes aichat-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); box-shadow: 0 2px 12px rgba(217,50,42,.55); }
}
#aiChatLauncher, #aiChatClose, #aiChatClear, #aiChatSend,
.aichat__card-pick, .aichat__auth-btn, .aichat__sched-chip, .aichat__chip,
.aichat__auth-link {
    outline: none;
}
#aiChatLauncher:focus, #aiChatLauncher:active,
#aiChatClose:focus, #aiChatClose:active,
#aiChatClear:focus, #aiChatClear:active,
#aiChatSend:focus, #aiChatSend:active,
.aichat__card-pick:focus, .aichat__card-pick:active,
.aichat__auth-btn:focus, .aichat__auth-btn:active,
.aichat__sched-chip:focus, .aichat__sched-chip:active,
.aichat__chip:focus, .aichat__chip:active,
.aichat__auth-link:focus, .aichat__auth-link:active {
    outline: none; box-shadow: none;
}
#aiChatLauncher::-moz-focus-inner,
#aiChatClose::-moz-focus-inner,
#aiChatClear::-moz-focus-inner,
#aiChatSend::-moz-focus-inner,
.aichat__card-pick::-moz-focus-inner,
.aichat__auth-btn::-moz-focus-inner,
.aichat__sched-chip::-moz-focus-inner,
.aichat__chip::-moz-focus-inner { border: 0; }

#aiChatTip {
    position: absolute; right: 106px; bottom: 24px;
    background: #fff; color: var(--aichat-text);
    padding: 11px 16px; border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
    font-size: 16px; font-weight: 500; line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0; transform: translateX(8px);
    transition: opacity .25s, transform .25s;
}
#aiChatTip::after {
    content: ''; position: absolute; right: -6px; top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 10px; height: 10px; background: #fff;
    box-shadow: 2px -2px 4px rgba(0, 0, 0, .04);
}
#aiChatRoot:not(.is-open-state) #aiChatTip { opacity: 1; transform: translateX(0); }
@media (max-width: 560px) {
    #aiChatTip { display: none; }
}

#aiChatPanel {
    position: fixed; right: 30px; bottom: 132px;
    width: 420px; max-width: calc(100vw - 32px);
    height: 640px; max-height: calc(100vh - 150px);
    background: var(--aichat-bg); border-radius: 16px;
    box-shadow: 0 20px 56px rgba(0, 0, 0, .2);
    display: flex; flex-direction: column; overflow: hidden;
    font-family: inherit;
}
#aiChatPanel[hidden] { display: none; }

.aichat__head {
    background: var(--aichat-accent); color: #fff;
    padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
    position: relative;
}
.aichat__avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(255,255,255,.18); color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.aichat__head-text { flex: 1; min-width: 0; line-height: 1.2; }
.aichat__title { font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.aichat__subtitle {
    font-size: 12.5px; opacity: .92; margin-top: 3px;
    display: flex; align-items: center; gap: 6px;
}
.aichat__online-dot {
    width: 7px; height: 7px; border-radius: 50%; background: #6ee7a8;
    box-shadow: 0 0 0 0 rgba(110, 231, 168, .8);
    animation: aichatPulse 2s infinite;
}
@keyframes aichatPulse {
    0% { box-shadow: 0 0 0 0 rgba(110, 231, 168, .65); }
    70% { box-shadow: 0 0 0 6px rgba(110, 231, 168, 0); }
    100% { box-shadow: 0 0 0 0 rgba(110, 231, 168, 0); }
}
#aiChatClose {
    background: transparent; border: 0; color: #fff;
    font-size: 26px; line-height: 1; cursor: pointer; padding: 0 6px;
    opacity: .85; flex-shrink: 0;
}
#aiChatClose:hover { opacity: 1; }
#aiChatClear, #aiChatOperator {
    background: transparent; border: 0; color: #fff;
    cursor: pointer; padding: 4px 6px; opacity: .8; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
#aiChatClear:hover, #aiChatOperator:hover { opacity: 1; }

.aichat__messages {
    flex: 1; overflow-y: auto; padding: 16px 18px;
    background: var(--aichat-bg-soft);
    display: flex; flex-direction: column; gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #3cbe8c transparent;
}
.aichat__messages::-webkit-scrollbar { width: 2px; }
.aichat__messages::-webkit-scrollbar-track { background: transparent; }
.aichat__messages::-webkit-scrollbar-thumb { background: #3cbe8c; border-radius: 2px; }
.aichat__messages::-webkit-scrollbar-thumb:hover { background: #2ea876; }
.aichat__msg {
    max-width: 85%; padding: 11px 14px; border-radius: 14px;
    font-size: 15px; line-height: 1.5; word-wrap: break-word; white-space: pre-wrap;
}
.aichat__msg--user {
    align-self: flex-end; background: var(--aichat-accent); color: #fff;
    border-bottom-right-radius: 4px;
}
.aichat__msg--bot {
    align-self: flex-start; background: var(--aichat-bg);
    color: var(--aichat-text); border: 1px solid var(--aichat-border);
    border-bottom-left-radius: 4px;
}
.aichat__msg--system {
    align-self: center; background: #fff3cd; color: #856404;
    font-size: 12.5px; border: 1px solid #ffe9a4;
}
.aichat__typing {
    align-self: flex-start; padding: 10px 14px;
    background: var(--aichat-bg); border: 1px solid var(--aichat-border); border-radius: 12px;
}
.aichat__typing span {
    display: inline-block; width: 6px; height: 6px; margin: 0 2px;
    background: #98a2b3; border-radius: 50%; animation: aichatBlink 1.2s infinite;
}
.aichat__typing span:nth-child(2) { animation-delay: .2s; }
.aichat__typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aichatBlink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.aichat__cards { display: flex; flex-direction: column; gap: 8px; }
.aichat__card {
    background: var(--aichat-bg); border: 1px solid var(--aichat-border);
    border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 10px;
}
.aichat__card-top { display: flex; gap: 10px; align-items: flex-start; }
.aichat__card-img {
    width: 56px; height: 56px; border-radius: 50%;
    background-size: cover; background-position: center top;
    background-color: #eef0f3; flex-shrink: 0;
}
.aichat__card-info { flex: 1; min-width: 0; }
.aichat__card-name { font-weight: 600; font-size: 14px; color: var(--aichat-text); line-height: 1.3; }
.aichat__card-post { font-size: 12.5px; color: var(--aichat-muted); margin-top: 2px; line-height: 1.3; }
.aichat__card-exp { font-size: 12px; color: var(--aichat-muted); margin-top: 4px; }
.aichat__card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.aichat__card-price { font-size: 13px; display: flex; align-items: baseline; gap: 6px; }
.aichat__card-price-old { color: var(--aichat-muted); text-decoration: line-through; font-size: 11.5px; }
.aichat__card-price-now { color: var(--aichat-text); font-weight: 600; }
.aichat__card-pick {
    background: var(--aichat-accent); color: #fff; border: 0; padding: 7px 14px;
    border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit;
    transition: background .2s;
}
.aichat__card-pick:hover { background: var(--aichat-accent-hover); }

.aichat__sched-head { display: flex; gap: 10px; align-items: center; padding-bottom: 8px; border-bottom: 1px dashed var(--aichat-border); }
.aichat__sched-img { width: 40px; height: 40px; }
.aichat__sched-slots { display: flex; flex-direction: column; gap: 8px; }
.aichat__sched-day { display: flex; flex-direction: column; gap: 5px; }
.aichat__sched-day-label { font-size: 12px; color: var(--aichat-muted); font-weight: 500; }
.aichat__sched-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.aichat__sched-chip {
    padding: 5px 11px; background: var(--aichat-bg-soft);
    border: 1px solid var(--aichat-border); color: var(--aichat-text);
    border-radius: 8px; font-size: 13px; cursor: pointer; font-family: inherit;
    transition: background .15s, border-color .15s, color .15s;
}
.aichat__sched-chip:hover { background: var(--aichat-accent); color: #fff; border-color: var(--aichat-accent); }
.aichat__sched-more { font-size: 12px; color: var(--aichat-muted); padding: 0 4px; }
.aichat__sched-moredays { font-size: 12px; color: var(--aichat-muted); font-style: italic; padding-top: 4px; }

.aichat__auth {
    background: var(--aichat-bg); border: 1px solid var(--aichat-border);
    border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.aichat__auth-title { font-weight: 600; font-size: 14px; color: var(--aichat-text); }
.aichat__auth-summary { font-size: 13px; color: var(--aichat-muted); padding-bottom: 6px; border-bottom: 1px dashed var(--aichat-border); }
.aichat__auth-step { display: flex; flex-direction: column; gap: 6px; }
.aichat__auth-step label { font-size: 12px; color: var(--aichat-muted); }
.aichat__auth-input {
    border: 1px solid #d8dee4; border-radius: 8px; padding: 9px 11px;
    font: inherit; font-size: 14px; outline: none; color: var(--aichat-text);
}
.aichat__auth-input:focus { border-color: var(--aichat-accent); }
.aichat__auth-btn {
    background: var(--aichat-accent); color: #fff; border: 0;
    padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: inherit; transition: background .2s;
}
.aichat__auth-btn:hover:not(:disabled) { background: var(--aichat-accent-hover); }
.aichat__auth-btn:disabled { background: #c5cdd5; cursor: not-allowed; }
.aichat__auth-link {
    background: transparent; color: var(--aichat-accent); border: 0;
    padding: 4px 0; font-size: 12.5px; cursor: pointer; text-align: left;
    font-family: inherit; text-decoration: underline;
}
.aichat__auth-status { font-size: 12.5px; min-height: 16px; }
.aichat__auth-status--err { color: #c83030; }
.aichat__auth-status--ok { color: #1f8a3a; }
.aichat__auth-status--info { color: var(--aichat-muted); }

.aichat__confirm {
    background: #f0f9f1; border: 1px solid #b6e0bd;
    border-radius: 12px; padding: 16px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-align: center;
}
.aichat__confirm-icon { color: #1f8a3a; }
.aichat__confirm-head { font-weight: 600; font-size: 15px; color: #1f8a3a; }
.aichat__confirm-body { font-size: 13px; color: var(--aichat-text); line-height: 1.5; }

.aichat__chips {
    padding: 8px 14px 0; display: flex; flex-wrap: wrap; gap: 7px;
    background: var(--aichat-bg-soft);
}
.aichat__chip {
    padding: 7px 14px; background: var(--aichat-bg);
    border: 1px solid var(--aichat-accent); color: var(--aichat-accent);
    border-radius: 20px; font-size: 14px; cursor: pointer;
    font-family: inherit;
}
.aichat__chip:hover { background: var(--aichat-accent); color: #fff; }

.aichat__form {
    display: flex; gap: 8px; padding: 12px 14px;
    border-top: 1px solid var(--aichat-border); background: var(--aichat-bg);
    align-items: flex-end;
}
#aiChatInput {
    flex: 1; resize: none; border: 1px solid #d8dee4;
    border-radius: 11px; padding: 11px 14px;
    font: inherit; font-size: 15px; line-height: 1.45;
    min-height: 64px; max-height: 150px; outline: none;
    color: var(--aichat-text);
    overflow-y: hidden;
}
#aiChatInput:focus { border-color: var(--aichat-accent); overflow-y: auto; }
#aiChatInput::-webkit-scrollbar { width: 0; height: 0; }
#aiChatInput { scrollbar-width: none; }
#aiChatSend {
    width: 44px; height: 44px; border: 0;
    background: var(--aichat-accent); color: #fff; border-radius: 11px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: background .2s;
}
#aiChatSend:hover { background: var(--aichat-accent-hover); }
#aiChatSend:disabled { background: #c5cdd5; cursor: not-allowed; }

/* Модальное подтверждение внутри панели (очистка истории и т.п.) */
.aichat__modal-backdrop {
    position: absolute; inset: 0; background: rgba(20, 24, 30, .42);
    display: flex; align-items: center; justify-content: center;
    z-index: 10; padding: 18px; border-radius: 16px;
    animation: aichat-fade-in .15s ease-out;
}
.aichat__modal {
    background: var(--aichat-bg); border-radius: 14px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .22);
    padding: 20px 22px; width: 100%; max-width: 320px;
    display: flex; flex-direction: column; gap: 12px; text-align: center;
    animation: aichat-pop-in .18s ease-out;
}
.aichat__modal-title { font-size: 16px; font-weight: 600; color: var(--aichat-text); }
.aichat__modal-text { font-size: 14px; line-height: 1.45; color: var(--aichat-muted); }
.aichat__modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.aichat__modal-btn {
    flex: 1; padding: 11px 14px; border-radius: 10px; border: 0;
    font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background .15s, color .15s;
}
.aichat__modal-btn--secondary {
    background: var(--aichat-bg-soft); color: var(--aichat-text);
    border: 1px solid var(--aichat-border);
}
.aichat__modal-btn--secondary:hover { background: #eceff3; }
.aichat__modal-btn--danger { background: #d9322a; color: #fff; }
.aichat__modal-btn--danger:hover { background: #b8281f; }
@keyframes aichat-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes aichat-pop-in {
    from { opacity: 0; transform: scale(.94); }
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 560px) {
    #aiChatPanel { right: 0; bottom: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; border-radius: 0; }
    #aiChatRoot { right: 18px; bottom: 18px; }
    #aiChatLauncher { width: 72px; height: 72px; }
}
