/**
 * AI FAQ Chatbot - Frontend Styles
 */

/* CSS Variables */
.aifaq-chatbot,
.aifaq-chatbot-embedded {
    --aifaq-theme-color: #0073aa;
    --aifaq-text-color: #333;
    --aifaq-bg-color: #fff;
    --aifaq-border-color: #e0e0e0;
    --aifaq-user-bg: #e3f2fd;
    --aifaq-bot-bg: #f5f5f5;
    --aifaq-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --aifaq-radius: 12px;
    --aifaq-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

/* Floating Widget */
.aifaq-chatbot {
    position: fixed;
    bottom: 20px;
    z-index: 99999;
    font-family: var(--aifaq-font-family);
    font-size: 14px;
}

.aifaq-chatbot.aifaq-position-right {
    right: 20px;
}

.aifaq-chatbot.aifaq-position-left {
    left: 20px;
}

/* Toggle Button */
.aifaq-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aifaq-theme-color);
    border: none;
    cursor: pointer;
    box-shadow: var(--aifaq-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.3s ease;
}

.aifaq-toggle:hover {
    transform: scale(1.1);
}

.aifaq-toggle svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.aifaq-toggle .aifaq-icon-close {
    display: none;
}

.aifaq-chatbot.aifaq-open .aifaq-toggle .aifaq-icon-chat {
    display: none;
}

.aifaq-chatbot.aifaq-open .aifaq-toggle .aifaq-icon-close {
    display: block;
}

/* Chat Window */
.aifaq-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-height: 550px;
    background: var(--aifaq-bg-color);
    border-radius: var(--aifaq-radius);
    box-shadow: var(--aifaq-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.aifaq-position-right .aifaq-window {
    right: 0;
}

.aifaq-position-left .aifaq-window {
    left: 0;
}

.aifaq-chatbot.aifaq-open .aifaq-window {
    display: flex;
    animation: aifaq-slide-up 0.3s ease;
}

@keyframes aifaq-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.aifaq-header {
    background: var(--aifaq-theme-color);
    color: #fff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.aifaq-bot-name {
    font-weight: 600;
    font-size: 16px;
}

.aifaq-minimize {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.aifaq-minimize:hover {
    opacity: 1;
}

.aifaq-minimize svg {
    width: 20px;
    height: 20px;
}

/* Messages Area */
.aifaq-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 350px;
}

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

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

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

.aifaq-message-content {
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.5;
    word-break: break-word;
}

.aifaq-message-user .aifaq-message-content {
    background: var(--aifaq-theme-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

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

/* Input Area */
.aifaq-input-area {
    padding: 15px;
    border-top: 1px solid var(--aifaq-border-color);
    flex-shrink: 0;
}

.aifaq-input-area form,
.aifaq-form {
    display: flex;
    gap: 10px;
}

.aifaq-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--aifaq-border-color);
    border-radius: 25px;
    font-size: 14px;
    font-family: var(--aifaq-font-family);
    outline: none;
    transition: border-color 0.2s;
}

.aifaq-input:focus {
    border-color: var(--aifaq-theme-color);
}

.aifaq-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--aifaq-theme-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.aifaq-send:hover {
    transform: scale(1.05);
}

.aifaq-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.aifaq-send svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

/* Loading Animation */
.aifaq-loading {
    padding: 10px 15px;
}

.aifaq-typing {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
    background: var(--aifaq-bot-bg);
    border-radius: 18px;
    width: fit-content;
}

.aifaq-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: aifaq-typing 1.4s infinite ease-in-out both;
}

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

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

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

/* Embedded Widget */
.aifaq-chatbot-embedded {
    font-family: var(--aifaq-font-family);
    font-size: 14px;
    border: 1px solid var(--aifaq-border-color);
    border-radius: var(--aifaq-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--aifaq-bg-color);
}

.aifaq-chatbot-embedded .aifaq-header {
    border-radius: 0;
}

.aifaq-chatbot-embedded .aifaq-messages {
    flex: 1;
    max-height: none;
}

.aifaq-chatbot-embedded .aifaq-minimize {
    display: none;
}

/* Responsive */
@media (max-width: 480px) {
    .aifaq-chatbot {
        bottom: 10px;
    }

    .aifaq-chatbot.aifaq-position-right {
        right: 10px;
    }

    .aifaq-chatbot.aifaq-position-left {
        left: 10px;
    }

    .aifaq-window {
        width: calc(100vw - 20px);
        max-height: 70vh;
        bottom: 70px;
    }

    .aifaq-toggle {
        width: 50px;
        height: 50px;
    }

    .aifaq-toggle svg {
        width: 24px;
        height: 24px;
    }
}

/* Dark mode support (if theme supports) */
@media (prefers-color-scheme: dark) {
    .aifaq-chatbot,
    .aifaq-chatbot-embedded {
        --aifaq-text-color: #e0e0e0;
        --aifaq-bg-color: #1e1e1e;
        --aifaq-border-color: #333;
        --aifaq-user-bg: #1565c0;
        --aifaq-bot-bg: #2d2d2d;
    }
}

/* Scrollbar Styling */
.aifaq-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.aifaq-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}
