/**
 * Frontend Styles for PDF AI Chatbot
 */

/* CSS Variables */
:root {
    --pdf-ai-chat-bg: #ffffff;
    --pdf-ai-chat-text: #333333;
    --pdf-ai-chat-header-bg: #0073aa;
    --pdf-ai-chat-header-text: #ffffff;
    --pdf-ai-icon-bg: #0073aa;
    --pdf-ai-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --pdf-ai-transition: all 0.3s ease;
}

/* Reset for chatbot container */
.pdf-ai-chatbot-wrapper {
    all: initial;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.pdf-ai-chatbot-wrapper * {
    box-sizing: border-box;
}

/* Floating Icon */
.pdf-ai-chatbot-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--pdf-ai-icon-bg);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--pdf-ai-shadow);
    z-index: 999998;
    transition: var(--pdf-ai-transition);
    animation: pdf-ai-pulse 2s infinite;
}

.pdf-ai-chatbot-icon:hover {
    transform: scale(1.1);
}

.pdf-ai-chatbot-icon svg {
    width: 30px;
    height: 30px;
}

/* Pulse Animation */
@keyframes pdf-ai-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 115, 170, 0.4);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(0, 115, 170, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 115, 170, 0);
    }
}

/* Welcome Bubble */
.pdf-ai-chatbot-bubble {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: #fff;
    color: #333;
    padding: 10px 15px;
    border-radius: 12px;
    box-shadow: var(--pdf-ai-shadow);
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--pdf-ai-transition);
    animation: pdf-ai-bubble-pop 0.5s ease forwards;
    animation-delay: 1s;
}

.pdf-ai-chatbot-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

@keyframes pdf-ai-bubble-pop {
    0% {
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px) scale(0.8);
    }
    100% {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
    }
}

/* Chat Widget */
.pdf-ai-chatbot-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--pdf-ai-chat-bg);
    border-radius: 16px;
    box-shadow: var(--pdf-ai-shadow);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pdf-ai-slide-up 0.3s ease;
}

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

/* Header */
.pdf-ai-chatbot-header {
    background: var(--pdf-ai-chat-header-bg);
    color: var(--pdf-ai-chat-header-text);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.pdf-ai-chatbot-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: inherit;
}

.pdf-ai-chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.pdf-ai-chatbot-header-actions button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.pdf-ai-chatbot-header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Container */
.pdf-ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubbles */
.pdf-ai-chatbot-message {
    display: flex;
    animation: pdf-ai-message-in 0.3s ease;
}

@keyframes pdf-ai-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pdf-ai-chatbot-message.user {
    justify-content: flex-end;
}

.pdf-ai-chatbot-message.bot {
    justify-content: flex-start;
}

.pdf-ai-chatbot-message .message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.pdf-ai-chatbot-message.user .message-content {
    background: var(--pdf-ai-chat-header-bg);
    color: var(--pdf-ai-chat-header-text);
    border-bottom-right-radius: 4px;
}

.pdf-ai-chatbot-message.bot .message-content {
    background: #f0f0f1;
    color: var(--pdf-ai-chat-text);
    border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.pdf-ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.pdf-ai-typing span {
    width: 8px;
    height: 8px;
    background: #646970;
    border-radius: 50%;
    animation: pdf-ai-typing 1.4s infinite;
}

.pdf-ai-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.pdf-ai-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pdf-ai-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Input Area */
.pdf-ai-chatbot-input {
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.pdf-ai-chatbot-input-field {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--pdf-ai-chat-bg);
    color: var(--pdf-ai-chat-text);
}

.pdf-ai-chatbot-input-field:focus {
    border-color: var(--pdf-ai-chat-header-bg);
}

.pdf-ai-chatbot-input-field::placeholder {
    color: #999;
}

.pdf-ai-chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--pdf-ai-chat-header-bg);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.pdf-ai-chatbot-send:hover {
    transform: scale(1.05);
    background: var(--pdf-ai-chat-header-bg);
    filter: brightness(1.1);
}

.pdf-ai-chatbot-send:active {
    transform: scale(0.95);
}

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

.pdf-ai-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.pdf-ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: #c3c4c7;
    border-radius: 3px;
}

.pdf-ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .pdf-ai-chatbot-widget {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .pdf-ai-chatbot-icon {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
    }
    
    .pdf-ai-chatbot-bubble {
        display: none;
    }
}
