/* FAQ Chat Widget Styles */
/* © 2025 Crafty Software IP LLC. All rights reserved. */

/* CSS Variables for theming */
:root {
    --faq-primary: #3a86ff;
    --faq-primary-dark: #2463cc;
    --faq-secondary: #f8f9fa;
    --faq-text: #333;
    --faq-text-light: #666;
    --faq-border: #e0e0e0;
    --faq-user-bg: #3a86ff;
    --faq-user-text: #fff;
    --faq-assistant-bg: #f0f2f5;
    --faq-assistant-text: #333;
    --faq-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --faq-widget-width: 380px;
    --faq-widget-max-height: 500px;
    --faq-widget-expanded-width: 550px;
    --faq-widget-expanded-max-height: 650px;
    --faq-toggle-size: 60px;
}

/* Floating Toggle Button */
.faq-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: var(--faq-toggle-size);
    height: var(--faq-toggle-size);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--faq-primary) 0%, #8338ec 100%);
    border: none;
    box-shadow: var(--faq-shadow);
    cursor: pointer;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.faq-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 25px rgba(58, 134, 255, 0.4);
}

.faq-chat-toggle:active {
    transform: scale(0.95);
}

.faq-chat-toggle i {
    font-size: 26px;
    color: #fff;
}

.faq-chat-toggle.is-open i::before {
    content: "\F62a"; /* bi-x-lg */
}

/* Chat Widget Panel */
.faq-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: var(--faq-widget-width);
    max-height: var(--faq-widget-max-height);
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--faq-shadow);
    z-index: 1049;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease, width 0.25s ease, max-height 0.25s ease;
}

.faq-chat-widget.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.faq-chat-header {
    background: linear-gradient(135deg, var(--faq-primary) 0%, #8338ec 100%);
    color: #fff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.faq-chat-header-content {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
}

.faq-chat-header-content i {
    font-size: 20px;
}

.faq-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.faq-chat-remaining {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
}

.faq-chat-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.15s ease;
}

.faq-chat-close:hover {
    opacity: 1;
}

.faq-chat-close i {
    font-size: 18px;
}

/* Expand Button */
.faq-chat-expand {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.15s ease;
}

.faq-chat-expand:hover {
    opacity: 1;
}

.faq-chat-expand i {
    font-size: 16px;
}

/* Icon swap when expanded */
.faq-chat-widget.is-expanded .faq-chat-expand i::before {
    content: "\F3d8"; /* bi-fullscreen-exit */
}

/* Expanded State */
.faq-chat-widget.is-expanded {
    width: var(--faq-widget-expanded-width);
    max-height: var(--faq-widget-expanded-max-height);
}

.faq-chat-widget.is-expanded .faq-chat-messages {
    min-height: 400px;
    max-height: 470px;
}

/* Messages Container */
.faq-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 250px;
    max-height: 320px;
    background: #fafbfc;
    transition: min-height 0.25s ease, max-height 0.25s ease;
}

/* Message Bubbles */
.faq-message {
    display: flex;
    max-width: 85%;
}

.faq-message-user {
    align-self: flex-end;
    justify-content: flex-end;
}

.faq-message-assistant {
    align-self: flex-start;
}

.faq-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.faq-message-user .faq-message-content {
    background: var(--faq-user-bg);
    color: var(--faq-user-text);
    border-bottom-right-radius: 4px;
}

.faq-message-assistant .faq-message-content {
    background: var(--faq-assistant-bg);
    color: var(--faq-assistant-text);
    border-bottom-left-radius: 4px;
}

.faq-message-content p {
    margin: 0 0 8px 0;
}

.faq-message-content p:last-child {
    margin-bottom: 0;
}

.faq-message-hint {
    font-size: 12px;
    color: var(--faq-text-light);
    font-style: italic;
}

/* Loading indicator */
.faq-message-loading .faq-message-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.faq-loading-dots {
    display: flex;
    gap: 4px;
}

.faq-loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--faq-text-light);
    border-radius: 50%;
    animation: faq-bounce 1.4s infinite ease-in-out both;
}

.faq-loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.faq-loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* Error message */
.faq-message-error .faq-message-content {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Input Container */
.faq-chat-input-container {
    border-top: 1px solid var(--faq-border);
    background: #fff;
    flex-shrink: 0;
}

.faq-chat-form {
    display: flex;
    align-items: flex-end;
    padding: 12px;
    gap: 8px;
}

.faq-chat-input {
    flex: 1;
    border: 1px solid var(--faq-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.15s ease;
}

.faq-chat-input:focus {
    outline: none;
    border-color: var(--faq-primary);
}

.faq-chat-input::placeholder {
    color: #aaa;
}

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

.faq-chat-send:hover {
    background: var(--faq-primary-dark);
}

.faq-chat-send:active {
    transform: scale(0.92);
}

.faq-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.faq-chat-send i {
    font-size: 16px;
}

/* Email Support Button */
.faq-chat-actions {
    padding: 0 12px 12px;
    text-align: center;
}

.faq-email-support-btn {
    background: none;
    border: 1px solid var(--faq-border);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 12px;
    color: var(--faq-text-light);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.faq-email-support-btn:hover {
    border-color: var(--faq-primary);
    color: var(--faq-primary);
}

/* Rate limit warning */
.faq-rate-limit-warning {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 12px;
    font-size: 13px;
    color: #856404;
    text-align: center;
}

.faq-rate-limit-warning a {
    color: #856404;
    font-weight: 600;
}

/* Mobile Full-Screen Modal */
@media (max-width: 768px) {
    .faq-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .faq-chat-toggle i {
        font-size: 22px;
    }

    .faq-chat-widget {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }

    .faq-chat-widget.is-visible {
        transform: translateY(0);
    }

    .faq-chat-header {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .faq-chat-messages {
        min-height: auto;
        max-height: none;
        flex: 1;
    }

    .faq-chat-input-container {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    /* Hide expand button on mobile (already full-screen) */
    .faq-chat-expand {
        display: none;
    }
}

/* Scrollbar styling for messages */
.faq-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.faq-chat-messages::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.faq-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}
