/**
 * AI Document Chatbot - Frontend Styles
 *
 * @package AI_Document_Chatbot
 */

/* ========================================
   Inline Chatbot (Shortcode)
   ======================================== */

.ai-docbot-chatbot-wrapper {
    max-width: 800px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.ai-docbot-chatbot-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background: #fff;
}

.ai-docbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 20px;
    text-align: center;
}

.ai-docbot-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.ai-docbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.ai-docbot-message {
    display: flex;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-docbot-message-avatar {
    font-size: 32px;
    margin-right: 12px;
    flex-shrink: 0;
}

.ai-docbot-message-content {
    flex: 1;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-docbot-bot-message .ai-docbot-message-content {
    background: #fff;
    border: 1px solid #e1e8ed;
    max-width: 80%;
}

.ai-docbot-user-message {
    flex-direction: row-reverse;
}

.ai-docbot-user-message .ai-docbot-message-avatar {
    margin-right: 0;
    margin-left: 12px;
}

.ai-docbot-user-message .ai-docbot-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    max-width: 80%;
}

.ai-docbot-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 13px;
}

.ai-docbot-sources strong {
    display: block;
    margin-bottom: 5px;
}

.ai-docbot-sources small {
    display: inline-block;
    margin-right: 10px;
    color: #666;
}

/* Typing Indicator */
.ai-docbot-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-docbot-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typing 1.4s infinite;
}

.ai-docbot-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-docbot-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.ai-docbot-input-area {
    display: flex;
    padding: 15px;
    background: #fff;
    border-top: 1px solid #e1e8ed;
}

.ai-docbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.ai-docbot-input:focus {
    border-color: #667eea;
}

.ai-docbot-send-btn {
    margin-left: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-docbot-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-docbot-send-btn:active {
    transform: translateY(0);
}

.ai-docbot-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   Floating Chatbot (Popup)
   ======================================== */

.ai-docbot-floating-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.ai-docbot-floating-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.ai-docbot-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.ai-docbot-floating-btn:active {
    transform: scale(0.95);
}

.ai-docbot-popup {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: popupSlide 0.3s ease-out;
}

@keyframes popupSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-docbot-popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-docbot-popup-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-docbot-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.ai-docbot-close-btn:hover {
    transform: rotate(90deg);
}

.ai-docbot-popup-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.ai-docbot-popup-input {
    display: flex;
    padding: 15px;
    background: #fff;
    border-top: 1px solid #e1e8ed;
}

.ai-docbot-popup-input input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.ai-docbot-popup-input input:focus {
    border-color: #667eea;
}

.ai-docbot-popup-send-btn {
    margin-left: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-docbot-popup-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-docbot-popup-send-btn:active {
    transform: scale(0.95);
}

.ai-docbot-popup-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    .ai-docbot-chatbot-wrapper {
        margin: 10px;
    }

    .ai-docbot-popup {
        width: 90vw;
        max-width: 380px;
        right: -5px;
    }

    .ai-docbot-floating-container {
        bottom: 15px;
        right: 15px;
    }

    .ai-docbot-floating-btn {
        width: 55px;
        height: 55px;
    }

    .ai-docbot-message-content {
        font-size: 14px;
    }

    .ai-docbot-bot-message .ai-docbot-message-content,
    .ai-docbot-user-message .ai-docbot-message-content {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .ai-docbot-popup {
        width: calc(100vw - 20px);
        height: 70vh;
        bottom: 75px;
        right: -10px;
    }

    .ai-docbot-header h3,
    .ai-docbot-popup-header h3 {
        font-size: 16px;
    }

    .ai-docbot-message-avatar {
        font-size: 28px;
    }
}

/* ========================================
   Markdown and Code Formatting
   ======================================== */

.ai-docbot-message-content p {
    margin: 0 0 10px 0;
}

.ai-docbot-message-content p:last-child {
    margin-bottom: 0;
}

.ai-docbot-message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.ai-docbot-message-content strong {
    font-weight: 600;
}

.ai-docbot-message-content em {
    font-style: italic;
}

/* ========================================
   Scrollbar Styling
   ======================================== */

.ai-docbot-messages::-webkit-scrollbar,
.ai-docbot-popup-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-docbot-messages::-webkit-scrollbar-track,
.ai-docbot-popup-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-docbot-messages::-webkit-scrollbar-thumb,
.ai-docbot-popup-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.ai-docbot-messages::-webkit-scrollbar-thumb:hover,
.ai-docbot-popup-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}
