/**
 * AIDB Chatbot - Styles
 */

.aidb-chatbot {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 520px;
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* Header */
.aidb-chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #1a1a1a;
    color: #fff;
    flex-shrink: 0;
}

.aidb-chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
}

.aidb-chatbot-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #444, #666);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.aidb-chatbot-header-actions {
    display: flex;
    gap: 4px;
}

.aidb-chatbot-header-actions button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.aidb-chatbot-header-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Messages area */
.aidb-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    position: relative;
}

.aidb-chatbot-messages-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aidb-chatbot-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: aidb-chatbot-fade-in 0.3s ease;
}

@keyframes aidb-chatbot-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aidb-chatbot-message-assistant {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
}

.aidb-chatbot-message-user {
    align-self: flex-end;
    background: #1a1a1a;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.aidb-chatbot-typing {
    padding-top: 8px;
}

.aidb-chatbot-dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.aidb-chatbot-dots span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: aidb-chatbot-bounce 1.4s infinite ease-in-out both;
}

.aidb-chatbot-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.aidb-chatbot-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

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

.aidb-chatbot-messages {
    position: relative;
}

/* Input area */
.aidb-chatbot-input-form {
    padding: 12px 16px;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    flex-shrink: 0;
}

.aidb-chatbot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f5f5f5;
    border-radius: 20px;
    padding: 6px 6px 6px 16px;
    border: 1px solid #e0e0e0;
    transition: border-color 0.2s;
}

.aidb-chatbot-input-wrapper:focus-within {
    border-color: #888;
}

.aidb-chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 100px;
    padding: 6px 0;
    font-family: inherit;
}

.aidb-chatbot-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #1a1a1a;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.aidb-chatbot-send-btn:hover:not(:disabled) {
    background: #333;
}

.aidb-chatbot-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Login required */
.aidb-chatbot-login-required {
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.aidb-chatbot-login-required a {
    color: #333;
    font-weight: 600;
}

/* Markdown in assistant messages */
.aidb-chatbot-message-assistant strong {
    font-weight: 700;
}

.aidb-chatbot-message-assistant code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Choice buttons */
.aidb-chatbot-message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.aidb-chatbot-message-wrapper:has(.aidb-chatbot-message-user) {
    align-self: flex-end;
}

.aidb-chatbot-message-wrapper:has(.aidb-chatbot-message-assistant) {
    align-self: flex-start;
}

.aidb-chatbot-message-wrapper .aidb-chatbot-message {
    max-width: 100%;
}

.aidb-chatbot-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    animation: aidb-chatbot-fade-in 0.3s ease;
}

.aidb-chatbot-choice-btn {
    display: inline-block;
    padding: 8px 16px;
    background: #fff;
    color: #1a1a1a;
    border: 1.5px solid #333;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.3;
    font-family: inherit;
}

.aidb-chatbot-choice-btn:hover {
    background: #1a1a1a;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.aidb-chatbot-choice-btn:active {
    transform: scale(0.97);
}

.aidb-chatbot-choice-btn.selected {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

.aidb-chatbot-choice-other {
    border-color: #ccc;
    color: #666;
    border-style: dashed;
}

.aidb-chatbot-choice-other:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #999;
    border-style: dashed;
    box-shadow: none;
    transform: none;
}

.aidb-chatbot-choices.disabled .aidb-chatbot-choice-btn {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.aidb-chatbot-choices.disabled .aidb-chatbot-choice-btn.selected {
    opacity: 1;
    background: #1a1a1a;
    color: #fff;
}

/* "Other" inline input */
.aidb-chatbot-choice-other-input {
    width: 100%;
    margin-top: 4px;
}

.aidb-chatbot-choice-other-field {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #ccc;
    border-radius: 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.aidb-chatbot-choice-other-field:focus {
    border-color: #888;
}

.aidb-chatbot-choices.disabled .aidb-chatbot-choice-other-field {
    opacity: 0.5;
    pointer-events: none;
}

/* Confirm (send) button for multi-select choices */
.aidb-chatbot-choice-confirm {
    width: 100%;
    margin-top: 4px;
    padding: 8px 16px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.aidb-chatbot-choice-confirm:hover {
    background: #333;
}

/* Profile updated notification */
.aidb-chatbot-notification {
    text-align: center;
    font-size: 12px;
    color: #555;
    padding: 6px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    margin: 8px 0;
    animation: aidb-chatbot-fade-in 0.3s ease;
}

/* Visitor preview: login CTA replacing input area */
.aidb-chatbot-preview-login {
    padding: 16px;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    flex-shrink: 0;
    text-align: center;
}

.aidb-chatbot-preview-login-btn {
    display: block;
    padding: 12px 24px;
    background: #1a1a1a;
    color: #fff;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.aidb-chatbot-preview-login-btn:hover {
    background: #333;
    color: #fff;
    text-decoration: none;
}

.aidb-chatbot-preview-login-sub {
    font-size: 11px;
    color: #999;
    margin: 8px 0 0;
}

/* Compact variant (for sidebars) */
.aidb-chatbot-compact {
    height: 400px;
    max-width: 100%;
    border-radius: 8px;
}

.aidb-chatbot-compact .aidb-chatbot-header {
    padding: 8px 12px;
}

.aidb-chatbot-compact .aidb-chatbot-messages {
    padding: 12px;
}

.aidb-chatbot-compact .aidb-chatbot-message {
    font-size: 13px;
    padding: 8px 12px;
}

.aidb-chatbot-compact .aidb-chatbot-input-form {
    padding: 8px 12px;
}

/* Responsive */
@media (max-width: 600px) {
    .aidb-chatbot {
        max-width: 100%;
        height: 460px;
        border-radius: 8px;
    }
}
