/**
 * Chatbot Frontend Styles
 *
 * @package IvyAiRag
 */

.ivy-ai-chatbot {
    max-width: 600px;
    margin: 0 auto;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ivy-ai-chatbot[data-theme="dark"] {
    background: #1a1a1a;
    border-color: #333;
}

.ivy-ai-chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    text-align: center;
}

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

.ivy-ai-chatbot-messages {
    padding: 20px;
    overflow-y: auto;
    background: #f9f9f9;
}

.ivy-ai-chatbot[data-theme="dark"] .ivy-ai-chatbot-messages {
    background: #2a2a2a;
}

.ivy-ai-chatbot-message {
    margin-bottom: 15px;
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

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

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

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

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

.ivy-ai-chatbot-message-user .ivy-ai-chatbot-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ivy-ai-chatbot-message-bot .ivy-ai-chatbot-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ivy-ai-chatbot[data-theme="dark"] .ivy-ai-chatbot-message-bot .ivy-ai-chatbot-message-content {
    background: #3a3a3a;
    color: #e0e0e0;
}

.ivy-ai-chatbot-message-sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 12px;
}

.ivy-ai-chatbot-message-sources a {
    color: #667eea;
    text-decoration: none;
    display: block;
    margin-top: 5px;
}

.ivy-ai-chatbot-message-sources a:hover {
    text-decoration: underline;
}

.ivy-ai-chatbot-input-wrapper {
    padding: 15px;
    background: white;
    border-top: 1px solid #ddd;
}

.ivy-ai-chatbot[data-theme="dark"] .ivy-ai-chatbot-input-wrapper {
    background: #1a1a1a;
    border-top-color: #333;
}

.ivy-ai-chatbot-form {
    display: flex;
    gap: 10px;
}

.ivy-ai-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.ivy-ai-chatbot-input:focus {
    border-color: #667eea;
}

.ivy-ai-chatbot[data-theme="dark"] .ivy-ai-chatbot-input {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

.ivy-ai-chatbot-submit {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ivy-ai-chatbot-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ivy-ai-chatbot-submit:active {
    transform: translateY(0);
}

.ivy-ai-chatbot-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ivy-ai-chatbot-typing {
    display: inline-flex;
    gap: 4px;
    padding: 8px 0;
}

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

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Floating Button Styles */
.ivy-ai-chatbot-button-wrapper {
    position: fixed;
    z-index: 9999;
}

.ivy-ai-chatbot-button-wrapper.ivy-ai-chatbot-button-bottom-right {
    bottom: 20px;
    right: 20px;
}

.ivy-ai-chatbot-button-wrapper.ivy-ai-chatbot-button-bottom-left {
    bottom: 20px;
    left: 20px;
}

.ivy-ai-chatbot-button-wrapper.ivy-ai-chatbot-button-top-right {
    top: 20px;
    right: 20px;
}

.ivy-ai-chatbot-button-wrapper.ivy-ai-chatbot-button-top-left {
    top: 20px;
    left: 20px;
}

.ivy-ai-chatbot-toggle-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ivy-ai-chatbot-toggle-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ivy-ai-chatbot-popup {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 40px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    overflow: hidden;
}

.ivy-ai-chatbot-button-wrapper.ivy-ai-chatbot-button-bottom-left .ivy-ai-chatbot-popup,
.ivy-ai-chatbot-button-wrapper.ivy-ai-chatbot-button-top-left .ivy-ai-chatbot-popup {
    right: auto;
    left: 0;
}

.ivy-ai-chatbot-button-wrapper.ivy-ai-chatbot-button-top-right .ivy-ai-chatbot-popup,
.ivy-ai-chatbot-button-wrapper.ivy-ai-chatbot-button-top-left .ivy-ai-chatbot-popup {
    bottom: auto;
    top: 80px;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .ivy-ai-chatbot {
        border-radius: 0;
        max-width: 100%;
    }

    .ivy-ai-chatbot-popup {
        width: calc(100vw - 40px);
    }
}
