.rafbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

.rafbot-widget[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
}

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

.rafbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background-color: var(--rafbot-primary, #2563eb);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    opacity: 1;
}

.rafbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.rafbot-toggle:focus-visible {
    outline: 3px solid var(--rafbot-primary, #2563eb);
    outline-offset: 3px;
}

.rafbot-chat {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: rafbot-slide-up 0.25s ease-out;
    transform-origin: bottom right;
}

.rafbot-widget[data-position="bottom-left"] .rafbot-chat {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

@keyframes rafbot-slide-up {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.rafbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background-color: var(--rafbot-primary, #2563eb);
    color: #fff;
    flex-shrink: 0;
}

.rafbot-name {
    font-weight: 600;
    font-size: 15px;
}

.rafbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.rafbot-close:hover {
    opacity: 1;
}

.rafbot-close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    border-radius: 2px;
}

.rafbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

.rafbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.rafbot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.rafbot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.rafbot-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    word-wrap: break-word;
    animation: rafbot-message-in 0.2s ease-out;
}

@keyframes rafbot-message-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rafbot-message--bot {
    align-self: flex-start;
    background: #f1f3f5;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.rafbot-message--user {
    align-self: flex-end;
    background-color: var(--rafbot-primary, #2563eb);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.rafbot-message-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    opacity: 0.85;
}

.rafbot-message--bot .rafbot-message-title {
    color: #374151;
}

.rafbot-message--user .rafbot-message-title {
    color: rgba(255, 255, 255, 0.9);
}

.rafbot-message--typing {
    align-self: flex-start;
    background: #f1f3f5;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 50px;
    justify-content: center;
}

.rafbot-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: rafbot-dot-bounce 1.4s infinite ease-in-out both;
}

.rafbot-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.rafbot-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.rafbot-typing-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes rafbot-dot-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.rafbot-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    animation: rafbot-message-in 0.2s ease-out;
}

.rafbot-button {
    padding: 6px 14px;
    border: 1.5px solid var(--rafbot-primary, #2563eb);
    background: #fff;
    color: var(--rafbot-primary, #2563eb);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.rafbot-button:hover {
    background: var(--rafbot-primary, #2563eb);
    color: #fff;
    transform: scale(1.03);
}

.rafbot-button:focus-visible {
    outline: 2px solid var(--rafbot-primary, #2563eb);
    outline-offset: 2px;
}

.rafbot-contact-link {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 16px;
    background-color: var(--rafbot-primary, #2563eb);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.15s;
    animation: rafbot-message-in 0.2s ease-out;
}

.rafbot-contact-link:hover {
    opacity: 0.9;
}

.rafbot-contact-link:focus-visible {
    outline: 2px solid var(--rafbot-primary, #2563eb);
    outline-offset: 2px;
}

.rafbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.rafbot-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

.rafbot-input:focus {
    border-color: var(--rafbot-primary, #2563eb);
}

.rafbot-input::placeholder {
    color: #9ca3af;
}

.rafbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: var(--rafbot-primary, #2563eb);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.rafbot-send:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.rafbot-send:focus-visible {
    outline: 2px solid var(--rafbot-primary, #2563eb);
    outline-offset: 2px;
}

.rafbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.rafbot-priority--high {
    color: #dc2626;
    font-weight: 600;
}

.rafbot-priority--medium {
    color: #d97706;
    font-weight: 600;
}

.rafbot-priority--low {
    color: #6b7280;
}

@media (max-width: 480px) {
    .rafbot-chat {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .rafbot-toggle {
        width: 48px;
        height: 48px;
    }
}
