/* AI-консультант: плавающий чат-виджет (стиль сайта fgos.pro) */
#ai-consultant-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9998;
    font-family: 'Vksand', Arial, sans-serif;
}

.aic-bubble {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--gradient-primary, linear-gradient(135deg, #0077FF 0%, #0088FF 100%));
    box-shadow: 0 8px 24px rgba(0, 119, 255, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}
.aic-bubble:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 12px 28px rgba(0, 119, 255, 0.45);
}
.aic-bubble:active { transform: scale(0.97); }

.aic-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent, #C62828);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.aic-panel {
    display: none;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(0, 119, 255, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    flex-direction: column;
    position: absolute;
    right: 0;
    bottom: 80px;
    border: 1px solid rgba(0, 119, 255, 0.08);
}
.aic-panel.open { display: flex; }

.aic-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.aic-header {
    flex: 0 0 auto;
    background: var(--gradient-primary, linear-gradient(135deg, #0077FF 0%, #0088FF 100%));
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.aic-header-title { font-weight: 600; font-size: 16px; line-height: 1.2; }
.aic-header-subtitle { font-size: 12px; opacity: 0.9; margin-top: 3px; }
.aic-header-actions { display: flex; gap: 8px; }
.aic-header-btn {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.aic-header-btn:hover { background: rgba(255, 255, 255, 0.32); }

.aic-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    background: var(--bg-light, #F5F7FA);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.aic-msg {
    max-width: 85%;
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.aic-msg.user {
    align-self: flex-end;
    background: var(--gradient-primary, linear-gradient(135deg, #0077FF 0%, #0088FF 100%));
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 119, 255, 0.2);
}
.aic-msg.assistant {
    align-self: flex-start;
    background: #fff;
    color: var(--text-dark, #2C3E50);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.aic-msg.system {
    align-self: center;
    background: #FFF8E1;
    color: #8E6B00;
    font-size: 12px;
    border-radius: 10px;
}

.aic-products {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    white-space: normal;
}
.aic-product {
    background: #fff;
    border: 1px solid #E1ECFF;
    border-radius: 12px;
    padding: 10px 12px;
    display: block;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    line-height: 1.3;
}
.aic-product:hover {
    border-color: var(--primary-purple, #0077FF);
    box-shadow: 0 4px 12px rgba(0, 119, 255, 0.12);
    transform: translateY(-1px);
    opacity: 1;
}
.aic-product-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark, #2C3E50);
    line-height: 1.35;
}
.aic-product-row {
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.aic-product-meta { font-size: 11px; color: var(--text-light, #718096); }
.aic-product-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-purple, #0077FF);
    white-space: nowrap;
}

.aic-typing {
    align-self: flex-start;
    background: #fff;
    padding: 12px 14px;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 4px;
}
.aic-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--secondary-light, #3399FF);
    animation: aic-bounce 1.4s infinite ease-in-out both;
}
.aic-typing span:nth-child(1) { animation-delay: -0.32s; }
.aic-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes aic-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.aic-input-area {
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #E1ECFF;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex: 0 0 auto;
}
.aic-input {
    flex: 1;
    border: 1px solid #E1ECFF;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
    background: var(--bg-light, #F5F7FA);
    transition: border-color 0.2s, background 0.2s;
}
.aic-input:focus {
    border-color: var(--primary-purple, #0077FF);
    background: #fff;
}
.aic-send {
    background: var(--gradient-primary, linear-gradient(135deg, #0077FF 0%, #0088FF 100%));
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(0, 119, 255, 0.3);
}
.aic-send:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 119, 255, 0.4);
}
.aic-send:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.aic-offline {
    padding: 12px 16px;
    background: #FFF8E1;
    color: #8E6B00;
    font-size: 13px;
    text-align: center;
    border-top: 1px solid #FDE68A;
}

/* Форма алерта */
.aic-alert-form {
    padding: 20px 18px;
    background: #fff;
    overflow-y: auto;
    flex: 1;
}
.aic-alert-form h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--text-dark, #2C3E50);
    font-weight: 600;
}
.aic-alert-form p {
    margin: 0 0 18px;
    font-size: 14px;
    color: var(--text-light, #718096);
    line-height: 1.5;
}
.aic-field { margin-bottom: 14px; }
.aic-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-medium, #4A5568);
    margin-bottom: 6px;
}
.aic-field input, .aic-field textarea {
    width: 100%;
    border: 1px solid #E1ECFF;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    background: var(--bg-light, #F5F7FA);
    transition: border-color 0.2s, background 0.2s;
}
.aic-field input:focus, .aic-field textarea:focus {
    border-color: var(--primary-purple, #0077FF);
    background: #fff;
}
.aic-field textarea { resize: vertical; min-height: 80px; }
.aic-field .aic-error { color: var(--accent, #C62828); font-size: 12px; margin-top: 4px; display: none; }
.aic-field.has-error .aic-error { display: block; }
.aic-field.has-error input, .aic-field.has-error textarea { border-color: var(--accent, #C62828); }

.aic-btn-primary {
    width: 100%;
    background: var(--gradient-primary, linear-gradient(135deg, #0077FF 0%, #0088FF 100%));
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    font-family: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 119, 255, 0.25);
}
.aic-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 119, 255, 0.35);
}
.aic-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }

.aic-btn-secondary {
    width: 100%;
    background: #fff;
    color: var(--primary-purple, #0077FF);
    border: 1.5px solid var(--primary-purple, #0077FF);
    padding: 11px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    font-family: inherit;
    transition: background 0.2s;
}
.aic-btn-secondary:hover { background: var(--light-purple, #E8F1FF); }

.aic-success {
    text-align: center;
    padding: 36px 24px;
    color: var(--text-dark, #2C3E50);
}
.aic-success-icon { font-size: 52px; margin-bottom: 14px; }
.aic-success h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.aic-success p { margin: 0; color: var(--text-light, #718096); font-size: 14px; line-height: 1.5; }

@media (max-width: 480px) {
    #ai-consultant-root { right: 16px; bottom: 16px; }
    .aic-panel { width: calc(100vw - 32px); height: calc(100vh - 96px); bottom: 76px; border-radius: 20px; }
    .aic-bubble { width: 58px; height: 58px; font-size: 24px; }
}
