/**
 * 1QR AI Chatbot - Frontend Styles
 *
 * @package QRBot
 */

/* Container */
.qrbot-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 8px;
}

.qrbot-chat-window[hidden] {
    display: none !important;
}

/* Chat Button Wrapper */
.qrbot-chat-button-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qrbot-bot-label {
    background: #fff;
    color: #1e293b;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    white-space: nowrap;
    border: 1px solid #e2e8f0;
    line-height: 1;
}

/* Chat Button */
.qrbot-chat-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.qrbot-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.4);
}

.qrbot-chat-button svg {
    fill: none !important;
    stroke: #fff !important;
    color: #fff !important;
    display: block;
    flex-shrink: 0;
}

.qrbot-chat-button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
}

/* Chat Window */
.qrbot-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: qrbot-slideIn 0.25s ease-out;
}

@keyframes qrbot-slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.qrbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #2563eb;
    color: #fff;
    flex-shrink: 0;
}

.qrbot-header-title {
    font-weight: 600;
    font-size: 16px;
}

.qrbot-close-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.qrbot-close-button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.qrbot-close-button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Messages Area */
.qrbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #f8f9fb;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* Message */
.qrbot-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: qrbot-fadeIn 0.2s ease;
}

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

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

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

.qrbot-message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.qrbot-message-user .qrbot-message-content {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.qrbot-message-assistant .qrbot-message-content {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* Loading Indicator */
.qrbot-loading {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.qrbot-loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: qrbot-bounce 1.4s infinite ease-in-out both;
}

.qrbot-loading-dot:nth-child(1) { animation-delay: -0.32s; }
.qrbot-loading-dot:nth-child(2) { animation-delay: -0.16s; }
.qrbot-loading-dot:nth-child(3) { animation-delay: 0s; }

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

/* Input Area */
.qrbot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.qrbot-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    max-height: 120px;
    min-height: 24px;
    color: #1e293b;
    background: #f8f9fb;
}

.qrbot-input:focus {
    border-color: #2563eb;
    background: #fff;
}

.qrbot-input::placeholder {
    color: #94a3b8;
}

.qrbot-send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.qrbot-send-button:hover {
    background: #1d4ed8;
}

.qrbot-send-button:active {
    transform: scale(0.95);
}

.qrbot-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.qrbot-send-button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.qrbot-send-button svg,
.qrbot-close-button svg {
    fill: none !important;
    stroke: currentColor !important;
    display: block;
    flex-shrink: 0;
}

/* Error Message */
.qrbot-message-error .qrbot-message-content {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .qrbot-chat-window {
        bottom: 90px;
        right: 12px;
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        height: 480px;
        max-height: calc(100vh - 120px);
        border-radius: 16px;
    }

    .qrbot-chat-container {
        bottom: 12px;
        right: 12px;
    }

    .qrbot-chat-button {
        width: 48px;
        height: 48px;
    }

    .qrbot-bot-label {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12px;
        padding: 8px 12px;
    }
}