/* ========================================
   Solutions Optinet – Chatbot Widget
   ======================================== */

#so-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--so-font-body, 'Inter', sans-serif);
}

/* ── Toggle Button ── */
.so-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--so-accent, #D4A843), var(--so-accent-dark, #b8912e));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(212, 168, 67, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.so-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(212, 168, 67, 0.5);
}

.so-chat-toggle__close {
    display: none;
}

.so-chat-toggle--open .so-chat-toggle__icon {
    display: none;
}

.so-chat-toggle--open .so-chat-toggle__close {
    display: block;
}

.so-chat-toggle__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.so-chat-toggle__badge--pulse {
    animation: soChatPulse 2s infinite;
}

@keyframes soChatPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ── Chat Window ── */
.so-chat {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.so-chat--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ── */
.so-chat__header {
    background: linear-gradient(135deg, var(--so-primary, #1B3A5C), var(--so-primary-dark, #122840));
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.so-chat__header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.so-chat__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--so-accent, #D4A843);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.so-chat__name {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
}

.so-chat__status {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.so-chat__status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
}

.so-chat__close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.so-chat__close:hover {
    color: #fff;
}

/* ── Body ── */
.so-chat__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 300px;
    max-height: 340px;
    background: #f9fafb;
}

/* ── Messages ── */
.so-chat__msg {
    display: flex;
    gap: 8px;
    max-width: 90%;
}

.so-chat__msg--bot {
    align-self: flex-start;
}

.so-chat__msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.so-chat__msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--so-primary, #1B3A5C);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.so-chat__msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.so-chat__msg--bot .so-chat__msg-bubble {
    background: #fff;
    color: var(--so-text, #2D2D2D);
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.so-chat__msg--user .so-chat__msg-bubble {
    background: var(--so-primary, #1B3A5C);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Animation ── */
.so-chat__msg--appear {
    animation: soChatMsgIn 0.3s ease forwards;
}

@keyframes soChatMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Options ── */
.so-chat__options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 36px;
}

.so-chat__option {
    padding: 8px 16px;
    border: 1.5px solid var(--so-accent, #D4A843);
    border-radius: 20px;
    background: #fff;
    color: var(--so-primary, #1B3A5C);
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.so-chat__option:hover {
    background: var(--so-accent, #D4A843);
    color: #fff;
    transform: translateY(-1px);
}

/* ── Typing Indicator ── */
.so-chat__typing {
    display: flex;
    gap: 8px;
    align-items: center;
}

.so-chat__typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.so-chat__typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: soTypingBounce 1.4s infinite;
}

.so-chat__typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.so-chat__typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes soTypingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* ── Actions ── */
.so-chat__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 36px;
}

.so-chat__action-btn {
    display: block;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
    border: none;
}

.so-chat__action-btn--primary {
    background: var(--so-accent, #D4A843);
    color: #fff;
}

.so-chat__action-btn--primary:hover {
    background: var(--so-accent-dark, #b8912e);
    transform: translateY(-1px);
}

.so-chat__action-btn--outline {
    background: transparent;
    border: 1.5px solid var(--so-primary, #1B3A5C);
    color: var(--so-primary, #1B3A5C);
}

.so-chat__action-btn--outline:hover {
    background: var(--so-primary, #1B3A5C);
    color: #fff;
}

.so-chat__action-btn--link {
    background: none;
    color: var(--so-text-muted, #9CA3AF);
    font-size: 0.8rem;
    font-weight: 400;
    padding: 4px;
}

.so-chat__action-btn--link:hover {
    color: var(--so-accent, #D4A843);
}

/* ── Text Input Area ── */
.so-chat__input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.so-chat__text-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: #f9fafb;
}

.so-chat__text-input:focus {
    border-color: var(--so-accent, #D4A843);
    background: #fff;
}

.so-chat__send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--so-accent, #D4A843);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

.so-chat__send-btn:hover {
    background: var(--so-accent-dark, #b8912e);
    transform: scale(1.06);
}

/* ── WhatsApp Button ── */
.so-chat__action-btn--whatsapp {
    background: #25D366;
    color: #fff !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.so-chat__action-btn--whatsapp:hover {
    background: #1ebe57;
    transform: translateY(-1px);
}

/* ── Footer ── */
.so-chat__footer {
    padding: 10px 16px;
    text-align: center;
    border-top: 1px solid #f3f4f6;
}

.so-chat__powered {
    font-size: 0.7rem;
    color: #9ca3af;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    #so-chat-container {
        bottom: 16px;
        right: 16px;
    }

    .so-chat {
        width: calc(100vw - 32px);
        max-height: 70vh;
        right: 0;
        bottom: 72px;
    }

    .so-chat-toggle {
        width: 52px;
        height: 52px;
    }
}
