/**
 * Simple AI Chatbot — Стили виджета
 */

/* === Плавающая кнопка === */
.sacb-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #4f46e5;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 28px;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    z-index: 99999;
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sacb-toggle:hover {
    transform: scale(1.1);
    background: #4338ca;
}

/* === Окно чата === */
.sacb-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
}

/* Хедер */
.sacb-header {
    background: #4f46e5;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sacb-header-title {
    font-weight: 600;
    font-size: 15px;
}

.sacb-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
}

.sacb-close-btn:hover {
    opacity: 1;
}

/* === Сообщения === */
.sacb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    max-height: 340px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sacb-message {
    max-width: 85%;
    animation: sacbFadeIn 0.2s ease;
}

.sacb-message-bot {
    align-self: flex-start;
}

.sacb-message-user {
    align-self: flex-end;
}

.sacb-message-text {
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    word-wrap: break-word;
}

.sacb-message-bot .sacb-message-text {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.sacb-message-user .sacb-message-text {
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.sacb-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.sacb-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: sacbBounce 1.4s infinite;
}

.sacb-typing span:nth-child(2) { animation-delay: 0.2s; }
.sacb-typing span:nth-child(3) { animation-delay: 0.4s; }

/* === Карточка товара === */
.sacb-product-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}

.sacb-product-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.sacb-product-card-body {
    padding: 10px 12px;
}

.sacb-product-name {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 4px;
}

.sacb-product-name a {
    color: #1f2937;
    text-decoration: none;
}

.sacb-product-name a:hover {
    color: #4f46e5;
}

.sacb-product-price {
    font-size: 16px;
    font-weight: 700;
    color: #059669;
    margin-bottom: 8px;
}

.sacb-product-actions {
    display: flex;
    gap: 8px;
}

.sacb-btn-cart {
    flex: 1;
    background: #4f46e5;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.sacb-btn-cart:hover {
    background: #4338ca;
}

.sacb-btn-link {
    background: #f3f4f6;
    color: #4b5563;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s;
}

.sacb-btn-link:hover {
    background: #e5e7eb;
}

/* === Поле ввода === */
.sacb-input-area {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
}

.sacb-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.sacb-input:focus {
    border-color: #4f46e5;
}

.sacb-send-btn {
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 42px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
}

.sacb-send-btn:hover {
    background: #4338ca;
}

.sacb-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* === Debug & Meta lines === */
.sacb-debug {
    font-size: 11px;
    color: #9ca3af;
    padding: 4px 12px 2px;
    text-align: center;
}
.sacb-meta {
    font-size: 10px;
    color: #c4b5fd;
    padding: 0 12px 8px;
    text-align: center;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* === Анимации === */
@keyframes sacbFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes sacbBounce {
    0%, 80%, 100% { transform: scale(0.6); }
    40% { transform: scale(1); }
}

/* === Мобильная адаптация === */
@media (max-width: 480px) {
    .sacb-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 80px;
        max-height: 70vh;
    }
}
