/* AI Chat Widget - Start */

/* Переменные */
:root {
    --aca-primary: #007cba;
    --aca-primary-hover: #005a87;
    --aca-secondary: #f0f0f1;
    --aca-text: #1e1e1e;
    --aca-text-light: #757575;
    --aca-border: #dcdcde;
    --aca-white: #ffffff;
    --aca-success: #00a32a;
    --aca-error: #d63638;
    --aca-warning: #dba617;
    --aca-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --aca-shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
    --aca-radius: 12px;
    --aca-radius-small: 8px;
    --aca-transition: all 0.3s ease;
}

/* Темная тема */
.op-aca-chat-widget[data-theme="dark"] {
    --aca-primary: #0073aa;
    --aca-secondary: #23282d;
    --aca-text: #ffffff;
    --aca-text-light: #a0a5aa;
    --aca-border: #32373c;
    --aca-white: #191f25;
}

/* Основной контейнер */
.op-aca-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: var(--aca-text);
}

/* Позиционирование */
.op-aca-chat-widget[data-position="bottom-right"] {
	bottom: 20px;
	right: 100px;
}

.op-aca-chat-widget[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
}

/* Кнопка открытия чата */
.aca-chat-button {
    position: relative;
    width: 60px;
    height: 60px;
    background: var(--aca-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--aca-shadow);
    transition: var(--aca-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: aca-pulse 2s infinite;
}

.aca-chat-button:hover {
    background: var(--aca-primary-hover);
    box-shadow: var(--aca-shadow-hover);
    transform: scale(1.05);
}

.aca-chat-button img {
    width: 30px;
    height: 30px;
    filter: brightness(0) invert(1);
}

/* Анимация пульсации */
@keyframes aca-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 124, 186, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(0, 124, 186, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 124, 186, 0);
    }
}

/* Бейдж уведомлений */
.aca-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--aca-error);
    color: var(--aca-white);
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 500;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Окно чата */
.aca-chat-window {
    position: absolute;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 100px);
    background: var(--aca-white);
    border-radius: var(--aca-radius);
    box-shadow: var(--aca-shadow-hover);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--aca-transition);
    transform-origin: bottom right;
}

.op-aca-chat-widget[data-position="bottom-right"] .aca-chat-window {
    bottom: 80px;
    right: 0;
}

.op-aca-chat-widget[data-position="bottom-left"] .aca-chat-window {
    bottom: 80px;
    left: 0;
    transform-origin: bottom left;
}

/* Анимация появления */
.aca-chat-window {
    animation: aca-slideUp 0.3s ease-out;
}

@keyframes aca-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Шапка чата */
.aca-chat-header {
    background: var(--aca-primary);
    color: var(--aca-white);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.aca-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aca-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--aca-success);
    position: relative;
}

.aca-status-indicator.online {
    animation: aca-blink 2s infinite;
}

@keyframes aca-blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.aca-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.aca-company-name {
    font-size: 16px;
    font-weight: 500;
}

.aca-status-text {
    font-size: 12px;
    opacity: 0.9;
}

.aca-header-actions {
    display: flex;
    gap: 8px;
}

.aca-header-actions button {
    background: none;
    border: none;
    color: var(--aca-white);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--aca-transition);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aca-header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.aca-minimize-btn span {
    font-size: 20px;
    line-height: 1;
}

.aca-close-btn img {
    width: 14px;
    height: 14px;
    filter: brightness(0) invert(1);
}

/* Область сообщений */
.aca-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
}

.aca-messages-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Стили сообщений */
.aca-message {
    max-width: 75%;
    word-wrap: break-word;
    animation: aca-fadeIn 0.3s ease-out;
}

@keyframes aca-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aca-message.visitor {
    align-self: flex-end;
}

.aca-message.bot,
.aca-message.operator,
.aca-message.system {
    align-self: flex-start;
}

.aca-message-bubble {
    padding: 12px 16px;
    border-radius: var(--aca-radius-small);
    position: relative;
}

.aca-message.visitor .aca-message-bubble {
    background: var(--aca-primary);
    color: var(--aca-white);
    border-bottom-right-radius: 2px;
}

.aca-message.bot .aca-message-bubble,
.aca-message.operator .aca-message-bubble {
    background: var(--aca-white);
    color: var(--aca-text);
    border: 1px solid var(--aca-border);
    border-bottom-left-radius: 2px;
}

.aca-message.system .aca-message-bubble {
    background: var(--aca-secondary);
    color: var(--aca-text-light);
    font-style: italic;
    text-align: center;
    align-self: center;
    font-size: 12px;
}

.aca-message-time {
    font-size: 11px;
    color: var(--aca-text-light);
    margin-top: 4px;
}

.aca-message.visitor .aca-message-time {
    text-align: right;
}

.aca-message-sender {
    font-size: 11px;
    color: var(--aca-text-light);
    margin-bottom: 4px;
    font-weight: 500;
}

/* Индикатор печати */
.aca-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--aca-white);
    border: 1px solid var(--aca-border);
    border-radius: var(--aca-radius-small);
    width: fit-content;
    margin-top: 12px;
}

.aca-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--aca-text-light);
    border-radius: 50%;
    animation: aca-typing 1.4s infinite;
}

.aca-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.aca-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes aca-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Быстрые действия */
.aca-quick-actions {
    padding: 10px 20px;
    background: var(--aca-secondary);
    border-top: 1px solid var(--aca-border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.aca-quick-action {
    padding: 6px 12px;
    background: var(--aca-white);
    border: 1px solid var(--aca-border);
    border-radius: var(--aca-radius-small);
    font-size: 12px;
    cursor: pointer;
    transition: var(--aca-transition);
}

.aca-quick-action:hover {
    background: var(--aca-primary);
    color: var(--aca-white);
    border-color: var(--aca-primary);
}

/* Форма ввода сообщения */
.aca-chat-input {
    padding: 15px;
    background: var(--aca-white);
    border-top: 1px solid var(--aca-border);
    flex-shrink: 0;
}

.aca-message-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.aca-message-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--aca-border);
    border-radius: var(--aca-radius-small);
    font-size: 14px;
    transition: var(--aca-transition);
    background: var(--aca-white);
    color: var(--aca-text);
}

.aca-message-input:focus {
    outline: none;
    border-color: var(--aca-primary);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.aca-message-input:disabled {
    background: var(--aca-secondary);
    cursor: not-allowed;
}

.aca-send-btn {
    padding: 10px;
    background: var(--aca-primary);
    border: none;
    border-radius: var(--aca-radius-small);
    cursor: pointer;
    transition: var(--aca-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.aca-send-btn:hover:not(:disabled) {
    background: var(--aca-primary-hover);
    transform: scale(1.05);
}

.aca-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aca-send-btn img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

/* Форма контактов */
.aca-contact-form {
    padding: 20px;
    background: var(--aca-white);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.aca-form-title {
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 10px;
}

.aca-contact-form-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aca-contact-form input {
    padding: 10px 15px;
    border: 1px solid var(--aca-border);
    border-radius: var(--aca-radius-small);
    font-size: 14px;
    transition: var(--aca-transition);
}

.aca-contact-form input:focus {
    outline: none;
    border-color: var(--aca-primary);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.aca-submit-contact {
    padding: 12px 20px;
    background: var(--aca-primary);
    color: var(--aca-white);
    border: none;
    border-radius: var(--aca-radius-small);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--aca-transition);
}

.aca-submit-contact:hover {
    background: var(--aca-primary-hover);
}

/* Скроллбар */
.aca-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.aca-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.aca-chat-messages::-webkit-scrollbar-thumb {
    background: var(--aca-border);
    border-radius: 3px;
}

.aca-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--aca-text-light);
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    .op-aca-chat-widget {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
    }
    
    .aca-chat-button {
        bottom: 20px;
        right: 20px;
        position: fixed;
    }
    
    .aca-chat-window {
        position: fixed;
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0;
    }
    
    .aca-chat-header {
        border-radius: 0;
    }
    
    .aca-message {
        max-width: 85%;
    }
}

/* Состояние загрузки */
.aca-loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--aca-border);
    border-radius: 50%;
    border-top-color: var(--aca-primary);
    animation: aca-spin 0.8s linear infinite;
    margin: 0 8px;
}

@keyframes aca-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Голосові повідомлення */
.aca-voice-btn {
    padding: 10px;
    background: transparent;
    border: 1px solid var(--aca-border);
    border-radius: var(--aca-radius-small);
    cursor: pointer;
    transition: var(--aca-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--aca-text-light);
    position: relative;
}

.aca-voice-btn:hover:not(:disabled) {
    background: var(--aca-secondary);
    border-color: var(--aca-primary);
    color: var(--aca-primary);
}

.aca-voice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aca-voice-btn.recording {
    background: var(--aca-error);
    border-color: var(--aca-error);
    color: var(--aca-white);
    animation: aca-recording-pulse 1s infinite;
}

.aca-voice-btn.recording::after {
    content: attr(data-time);
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--aca-error);
    color: var(--aca-white);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    white-space: nowrap;
}

@keyframes aca-recording-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(214, 54, 56, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(214, 54, 56, 0);
    }
}

/* Голосове повідомлення в чаті */
.aca-voice-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px !important;
    min-width: 180px;
}

.aca-voice-play {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--aca-primary);
    color: var(--aca-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--aca-transition);
}

.aca-voice-play:hover {
    background: var(--aca-primary-hover);
    transform: scale(1.05);
}

.aca-voice-play.playing {
    background: var(--aca-error);
}

.aca-message.visitor .aca-voice-play {
    background: rgba(255, 255, 255, 0.3);
}

.aca-message.visitor .aca-voice-play:hover {
    background: rgba(255, 255, 255, 0.5);
}

.aca-voice-wave {
    flex: 1;
    height: 24px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        currentColor 5%, 
        currentColor 6%, 
        transparent 6%, 
        transparent 10%,
        currentColor 10%,
        currentColor 11%,
        transparent 11%,
        transparent 15%,
        currentColor 15%,
        currentColor 18%,
        transparent 18%,
        transparent 22%,
        currentColor 22%,
        currentColor 26%,
        transparent 26%,
        transparent 30%,
        currentColor 30%,
        currentColor 32%,
        transparent 32%,
        transparent 36%,
        currentColor 36%,
        currentColor 42%,
        transparent 42%,
        transparent 46%,
        currentColor 46%,
        currentColor 50%,
        transparent 50%,
        transparent 54%,
        currentColor 54%,
        currentColor 58%,
        transparent 58%,
        transparent 62%,
        currentColor 62%,
        currentColor 68%,
        transparent 68%,
        transparent 72%,
        currentColor 72%,
        currentColor 74%,
        transparent 74%,
        transparent 78%,
        currentColor 78%,
        currentColor 82%,
        transparent 82%,
        transparent 86%,
        currentColor 86%,
        currentColor 88%,
        transparent 88%,
        transparent 92%,
        currentColor 92%,
        currentColor 94%,
        transparent 94%
    );
    opacity: 0.5;
    border-radius: 2px;
}

.aca-message.visitor .aca-voice-wave {
    opacity: 0.7;
}

.aca-voice-duration {
    font-size: 12px;
    color: var(--aca-text-light);
    min-width: 35px;
    text-align: right;
}

.aca-message.visitor .aca-voice-duration {
    color: rgba(255, 255, 255, 0.8);
}

/* AI Chat Widget - End */