/**
 * Marcolino Chatbot Widget Styles
 */

/* Widget Container */
#chatbot-widget-container {
    --chatbot-primary: #1a1a1a;
    --chatbot-primary-light: #f5f5f5;
    --chatbot-border: #e0e0e0;
    --chatbot-text: #333;
    --chatbot-text-light: #666;
    --chatbot-user-bg: #007bff;
    --chatbot-assistant-bg: #f0f0f0;
    --chatbot-system-bg: #fff3cd;
}

.chatbot-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
}

/* Toggle Button */
.chatbot-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    padding: 0;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle-btn:active {
    transform: scale(0.95);
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window--hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Header */
.chatbot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--chatbot-border);
    background: var(--chatbot-primary-light);
    border-radius: 12px 12px 0 0;
}

.chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--chatbot-text);
}

.chatbot-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--chatbot-text-light);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.chatbot-close-btn:hover {
    color: var(--chatbot-text);
}

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

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: var(--chatbot-primary-light);
}

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

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

/* Message Bubble */
.chatbot-message {
    display: flex;
    animation: slideIn 0.3s ease;
}

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

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

.chatbot-message--assistant {
    justify-content: flex-start;
}

.chatbot-message--system {
    justify-content: center;
}

.chatbot-message-content {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.4;
}

.chatbot-message--user .chatbot-message-content {
    background: var(--chatbot-user-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.chatbot-message--system .chatbot-message-content {
    background: var(--chatbot-system-bg);
    color: #856404;
    font-size: 12px;
    max-width: 90%;
}

/* Loading Indicator */
.chatbot-loader {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

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

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

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

@keyframes bounce {
    0%, 80%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--chatbot-border);
    background: var(--chatbot-primary-light);
    border-radius: 0 0 12px 12px;
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chatbot-input:focus {
    border-color: var(--chatbot-user-bg);
}

.chatbot-input::placeholder {
    color: var(--chatbot-text-light);
}

.chatbot-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.chatbot-send-btn:hover {
    background: #0d0d0d;
    transform: scale(1.05);
}

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

/* Follow-up Suggestions */
.chatbot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-suggestion-btn {
    background: var(--chatbot-primary-light);
    border: 1px solid var(--chatbot-border);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--chatbot-text);
    transition: all 0.2s ease;
    text-align: left;
}

.chatbot-suggestion-btn:hover {
    background: var(--chatbot-primary);
    color: white;
    border-color: var(--chatbot-primary);
}

/* Mobile Styles */
@media (max-width: 600px) {
    .chatbot-widget {
        bottom: 10px;
        right: 10px;
    }

    .chatbot-window {
        width: 100%;
        height: 100%;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        right: 0;
        bottom: 0;
        border-radius: 16px;
    }

    .chatbot-message-content {
        max-width: 85%;
    }

    .chatbot-toggle-btn {
        width: 48px;
        height: 48px;
    }

    /* Prevent keyboard overlap */
    @supports (padding: max(0px)) {
        .chatbot-widget {
            bottom: max(10px, env(safe-area-inset-bottom));
            right: max(10px, env(safe-area-inset-right));
        }

        .chatbot-input-area {
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    #chatbot-widget-container {
        --chatbot-primary: #f5f5f5;
        --chatbot-primary-light: #1a1a1a;
        --chatbot-border: #333;
        --chatbot-text: #f5f5f5;
        --chatbot-text-light: #999;
        --chatbot-assistant-bg: #2a2a2a;
    }

    .chatbot-toggle-btn {
        background: var(--chatbot-text);
        color: var(--chatbot-primary);
    }

    .chatbot-window {
        background: var(--chatbot-primary-light);
        color: var(--chatbot-text);
    }

    .chatbot-input {
        background: var(--chatbot-primary);
        color: var(--chatbot-text);
        border-color: var(--chatbot-border);
    }

    .chatbot-send-btn {
        background: var(--chatbot-text);
        color: var(--chatbot-primary);
    }

    .chatbot-message--user .chatbot-message-content {
        background: #007bff;
    }

    .chatbot-suggestion-btn {
        background: var(--chatbot-primary);
        color: var(--chatbot-text);
        border-color: var(--chatbot-border);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .chatbot-window,
    .chatbot-toggle-btn,
    .chatbot-message,
    .chatbot-send-btn {
        transition: none;
        animation: none;
    }
}