/**
 * RFM AI Chat Widget Styles
 */

/* Variables */
:root {
    --rfm-chat-primary: #4A90A4;
    --rfm-chat-primary-dark: #3A7A94;
    --rfm-chat-bg: #ffffff;
    --rfm-chat-text: #333333;
    --rfm-chat-text-light: #666666;
    --rfm-chat-border: #e0e0e0;
    --rfm-chat-user-bg: #4A90A4;
    --rfm-chat-user-text: #ffffff;
    --rfm-chat-assistant-bg: #f5f5f5;
    --rfm-chat-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --rfm-chat-radius: 16px;
}

/* Container */
.rfm-chat-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.rfm-chat-floating {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
}

/* Widget */
.rfm-chat-widget {
    position: relative;
}

/* Toggle Button */
.rfm-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--rfm-chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--rfm-chat-shadow);
    transition: transform 0.2s, background 0.2s;
    position: absolute;
    bottom: 0;
    right: 0;
}

.rfm-chat-toggle:hover {
    background: var(--rfm-chat-primary-dark);
    transform: scale(1.05);
}

.rfm-chat-toggle svg {
    width: 28px;
    height: 28px;
    color: white;
}

.rfm-chat-icon-close {
    display: none;
}

.rfm-chat-open .rfm-chat-icon-open {
    display: none;
}

.rfm-chat-open .rfm-chat-icon-close {
    display: block;
}

/* Chat Window */
.rfm-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--rfm-chat-bg);
    border-radius: var(--rfm-chat-radius);
    box-shadow: var(--rfm-chat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.rfm-chat-open .rfm-chat-window {
    display: flex;
}

/* Header */
.rfm-chat-header {
    background: var(--rfm-chat-primary);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rfm-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rfm-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rfm-chat-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.rfm-chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.rfm-chat-status {
    font-size: 12px;
    opacity: 0.9;
}

.rfm-chat-minimize {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: white;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.rfm-chat-minimize:hover {
    opacity: 1;
}

.rfm-chat-minimize svg {
    width: 20px;
    height: 20px;
}

/* Messages */
.rfm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rfm-chat-welcome {
    text-align: center;
    color: var(--rfm-chat-text-light);
    padding: 20px;
}

.rfm-chat-welcome p {
    margin: 8px 0;
}

.rfm-chat-message {
    max-width: 85%;
    animation: rfm-chat-fade-in 0.3s ease;
}

@keyframes rfm-chat-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rfm-chat-message-user {
    align-self: flex-end;
}

.rfm-chat-message-assistant {
    align-self: flex-start;
}

.rfm-chat-message-content {
    padding: 12px 16px;
    border-radius: 16px;
}

.rfm-chat-message-user .rfm-chat-message-content {
    background: var(--rfm-chat-user-bg);
    color: var(--rfm-chat-user-text);
    border-bottom-right-radius: 4px;
}

.rfm-chat-message-assistant .rfm-chat-message-content {
    background: var(--rfm-chat-assistant-bg);
    color: var(--rfm-chat-text);
    border-bottom-left-radius: 4px;
}

.rfm-chat-message-content p {
    margin: 0 0 8px 0;
}

.rfm-chat-message-content p:last-child {
    margin-bottom: 0;
}

/* Results in messages */
.rfm-chat-results {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--rfm-chat-border);
}

.rfm-chat-results h5 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
}

.rfm-chat-results ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.rfm-chat-results li {
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.rfm-chat-results li:last-child {
    border-bottom: none;
}

.rfm-chat-results a {
    color: var(--rfm-chat-primary);
    text-decoration: none;
    font-weight: 500;
}

.rfm-chat-results a:hover {
    text-decoration: underline;
}

.rfm-chat-results small {
    color: var(--rfm-chat-text-light);
    font-size: 12px;
}

/* Typing indicator */
.rfm-chat-typing .rfm-chat-message-content {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.rfm-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--rfm-chat-text-light);
    border-radius: 50%;
    animation: rfm-typing 1.4s infinite;
}

.rfm-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.rfm-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes rfm-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Suggestions */
.rfm-chat-suggestions {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--rfm-chat-border);
}

.rfm-chat-suggestion {
    background: white;
    border: 1px solid var(--rfm-chat-border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.rfm-chat-suggestion:hover {
    background: var(--rfm-chat-assistant-bg);
    border-color: var(--rfm-chat-primary);
}

/* Input Form */
.rfm-chat-input-form {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--rfm-chat-border);
    background: var(--rfm-chat-bg);
}

.rfm-chat-input {
    flex: 1;
    border: 1px solid var(--rfm-chat-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.rfm-chat-input:focus {
    border-color: var(--rfm-chat-primary);
}

.rfm-chat-input::placeholder {
    color: var(--rfm-chat-text-light);
}

.rfm-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--rfm-chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.rfm-chat-send:hover {
    background: var(--rfm-chat-primary-dark);
}

.rfm-chat-send svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Inline embed mode (not floating) */
.rfm-chat-container:not(.rfm-chat-floating) .rfm-chat-widget {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.rfm-chat-container:not(.rfm-chat-floating) .rfm-chat-toggle {
    display: none;
}

.rfm-chat-container:not(.rfm-chat-floating) .rfm-chat-window {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 500px;
    display: flex;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .rfm-chat-floating {
        bottom: 10px;
        right: 10px;
    }

    .rfm-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -10px;
    }

    .rfm-chat-toggle {
        width: 50px;
        height: 50px;
    }

    .rfm-chat-toggle svg {
        width: 24px;
        height: 24px;
    }
}
