/* ============================================
   Messenger Chatbot Style
   WhatsApp-inspired messaging UI with clean flow
   Focus: Natural message rhythm, bubble grouping, modern interaction patterns
   ============================================ */

/* ===== CSS Variables for Messenger Design ===== */
/* Color defaults can be overridden via inline styles from shortcode */
:root {
    --messenger-bg-primary: #f0f2f5;
    --messenger-bg-secondary: #ffffff;
    --messenger-bg-chat: #e5ddd5;
    --messenger-bg-input: #ffffff;
    
    --messenger-text-primary: #303030;
    --messenger-text-secondary: #667781;
    --messenger-text-light: #ffffff;
    
    --messenger-bubble-user: #dcf8c6;
    --messenger-bubble-ai: #ffffff;
    --messenger-bubble-border: rgba(0, 0, 0, 0.05);
    
    --messenger-border: #e9edef;
    --messenger-border-light: #f5f6f6;
    
    --messenger-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
    --messenger-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    
    --messenger-radius-sm: 4px;
    --messenger-radius: 7.5px;
    --messenger-radius-lg: 12px;
    --messenger-radius-xl: 18px;
    --messenger-radius-full: 9999px;
    
    --messenger-transition: all 0.15s ease-out;
    
    /* Chatbot Settings Variables - Can be overridden by PHP inline styles */
    --chatbot-font-size: 14.2px;
    --chatbot-top-avatar-width: 50px;
    --chatbot-top-avatar-height: 50px;
    --chatbot-conv-avatar-width: 37px;
    --chatbot-conv-avatar-height: 37px;
    --chatbot-bubble-width: auto;
    --chatbot-bubble-max-width: 65%;
    --chatbot-bubble-ai-alignment: flex-start;
    --chatbot-bubble-user-alignment: flex-end;
    --chatbot-bubble-ai-order: -1;
    --chatbot-bubble-user-order: 1;
    --chatbot-message-gap: 2px;
    --chatbot-message-group-gap: 12px;
}

/* ===== Base Container ===== */
.aiomatic-chat-holder {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Main Form Container ===== */
/* Background colors set via inline styles from shortcode - defaults provided */
.openai-ai-form,
.openai-ai-image-form {
    max-width: 800px;
    margin: 0 auto;
    background: var(--messenger-bg-secondary);
    border-radius: var(--messenger-radius-xl);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--messenger-border);
    overflow: hidden;
    transition: var(--messenger-transition);
}

/* ===== Header ===== */
.openai-card-header {
    background: var(--messenger-bg-secondary);
    padding: 12px 16px;
    border-bottom: 1px solid var(--messenger-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.openai-d-flex {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.openai-chat-avatar {
    width: var(--chatbot-top-avatar-width, 50px);
    height: var(--chatbot-top-avatar-height, 50px);
    border-radius: var(--messenger-radius-full);
    object-fit: cover;
    border: none;
    box-shadow: none;
    transition: var(--messenger-transition);
}

.openai-persona-name {
    font-size: calc(var(--chatbot-font-size, 14.2px) + 2px);
    font-weight: 500;
    color: var(--messenger-text-primary);
    line-height: 1.4;
    margin: 0 0 2px 0;
}

.openai-persona-role {
    font-size: 12.5px;
    color: var(--messenger-text-secondary);
    line-height: 1.3;
    margin: 0;
    font-weight: 400;
}

/* ===== Action Buttons / Menu ===== */
.openai-text-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    position: relative;
    flex-direction: row-reverse;
}

/* Menu icon (three dots) */
.openai-text-right::before {
    content: '⋯';
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px;
    height: 36px;
    border-radius: var(--messenger-radius-full);
    background: transparent;
    border: none;
    color: var(--messenger-text-secondary);
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
    transition: var(--messenger-transition);
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.openai-text-right:hover::before,
.openai-text-right:focus-within::before {
    background: var(--messenger-bg-primary);
    color: var(--messenger-text-primary);
}

/* Dropdown bridge */
.openai-text-right::after {
    content: '';
    position: absolute;
    top: 100%;
    right: -6px;
    width: 50px;
    height: 200px;
    z-index: 998;
    background: transparent;
    pointer-events: none;
}

.openai-text-right:hover::after,
.openai-text-right:focus-within::after {
    pointer-events: auto;
}

/* Template buttons in dropdown */
.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) {
    position: absolute;
    top: calc(100% + 0px);
    right: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    background: var(--messenger-bg-secondary) !important;
    border: 1px solid var(--messenger-border) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    width: 36px !important;
    height: 36px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: var(--messenger-radius-full) !important;
    pointer-events: none;
    margin: 0 !important;
}

/* Stack buttons vertically - position each button below the previous one */
/* First button stays at top: calc(100% + 0px) */
/* Each subsequent button: 36px height + 4px gap = 40px spacing per button */
.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-of-type(2) {
    top: calc(100% + 40px) !important; /* 36px button height + 4px gap */
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-of-type(3) {
    top: calc(100% + 80px) !important; /* 2 buttons × 40px */
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-of-type(4) {
    top: calc(100% + 120px) !important; /* 3 buttons × 40px */
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-of-type(5) {
    top: calc(100% + 160px) !important; /* 4 buttons × 40px */
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-of-type(6) {
    top: calc(100% + 200px) !important; /* 5 buttons × 40px */
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-of-type(7) {
    top: calc(100% + 240px) !important; /* 6 buttons × 40px */
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-of-type(8) {
    top: calc(100% + 280px) !important; /* 7 buttons × 40px */
}

.openai-text-right:hover > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]),
.openai-text-right:focus-within > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):hover,
.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):focus {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
}

.template-button {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--messenger-radius-full);
    background: transparent;
    border: none;
    color: var(--messenger-text-secondary);
    cursor: pointer;
    transition: var(--messenger-transition);
    text-decoration: none;
}

.template-button:hover {
    background: var(--messenger-bg-primary);
    color: var(--messenger-text-primary);
}

/* Icon styling inside template buttons */
.template-button i,
.template-button svg,
.template-button img {
    font-size: 18px;
    display: inline-block;
    line-height: 1;
    vertical-align: middle;
    color: inherit;
    fill: currentColor;
    width: 18px;
    height: 18px;
    opacity: 1;
    visibility: visible;
}

.template-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Ensure icons in dropdown are visible when dropdown is shown */
.openai-text-right:hover > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) i,
.openai-text-right:hover > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) svg,
.openai-text-right:hover > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) img,
.openai-text-right:focus-within > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) i,
.openai-text-right:focus-within > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) svg,
.openai-text-right:focus-within > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) img,
.template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) i,
.template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) svg,
.template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) img {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Override any inherited opacity/visibility from parent button when button is visible */
.openai-text-right:hover > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]),
.openai-text-right:focus-within > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) {
    opacity: 1;
    visibility: visible;
}

.openai-text-right:hover > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) > *,
.openai-text-right:focus-within > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) > * {
    opacity: 1 !important;
    visibility: visible !important;
}

/* ===== Chat History Container ===== */
/* Background color set via inline styles from shortcode */
.aiomatic_chat_history {
    background: var(--messenger-bg-chat);
    border: none !important;
    border-radius: 0;
    padding: 16px 8px !important;
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    scroll-behavior: smooth;
    position: relative;
}

/* Custom scrollbar - subtle */
.aiomatic_chat_history::-webkit-scrollbar {
    width: 6px;
}

.aiomatic_chat_history::-webkit-scrollbar-track {
    background: transparent;
}

.aiomatic_chat_history::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--messenger-radius-full);
    transition: var(--messenger-transition);
}

.aiomatic_chat_history::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ===== Chat Container ===== */
.ai-chat {
    display: flex;
    flex-direction: column;
    gap: var(--chatbot-message-group-gap, 12px);
    padding: 0;
}

/* ===== Message Wrapper ===== */
/* Handles message grouping and alignment */
.ai-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 0;
    width: 100%;
    transition: var(--messenger-transition);
}

/* AI messages align left with avatar */
.ai-wrapper:has(.ai-other) {
    justify-content: var(--chatbot-bubble-ai-alignment, flex-start);
}

/* User messages align right */
.ai-wrapper:has(.ai-mine) {
    justify-content: var(--chatbot-bubble-user-alignment, flex-end);
}

/* Group consecutive messages from same sender - tighter spacing */
.ai-wrapper + .ai-wrapper:has(.ai-other) {
    margin-top: calc(-1 * var(--chatbot-message-group-gap, 12px) + var(--chatbot-message-gap, 2px));
}

.ai-wrapper + .ai-wrapper:has(.ai-mine) {
    margin-top: calc(-1 * var(--chatbot-message-group-gap, 12px) + var(--chatbot-message-gap, 2px));
}

/* Reset spacing when sender changes - smaller gap between different senders */
.ai-wrapper:has(.ai-other) + .ai-wrapper:has(.ai-mine),
.ai-wrapper:has(.ai-mine) + .ai-wrapper:has(.ai-other) {
    margin-top: 8px;
}

/* ===== Message Bubbles ===== */
.ai-bubble {
    /* Width controlled via CSS variables - defaults to auto with max-width */
    width: var(--chatbot-bubble-width, auto) !important;
    max-width: var(--chatbot-bubble-max-width, 65%);
    min-width: 0;
    word-wrap: break-word;
    word-break: break-word;
    padding: 6px 7px 8px 9px;
    line-height: 1.4;
    font-size: var(--chatbot-font-size, 14.2px);
    position: relative;
    transition: var(--messenger-transition);
    cursor: pointer;
    font-weight: 400;
    flex: 0 1 auto;
    box-shadow: var(--messenger-shadow-sm);
}

/* Bubble corner radius pattern: larger on side away from avatar, smaller on side near avatar */
/* AI messages (left side) - larger top-right and bottom-right */
.ai-bubble.ai-other {
    /* Colors set via inline styles - defaults provided */
    background-color: var(--messenger-bubble-ai);
    color: var(--messenger-text-primary);
    border: none;
    border-top-left-radius: var(--messenger-radius-sm);
    border-top-right-radius: var(--messenger-radius-lg);
    border-bottom-left-radius: var(--messenger-radius-sm);
    border-bottom-right-radius: var(--messenger-radius-lg);
}

/* User messages (right side) - larger top-left and bottom-left */
.ai-bubble.ai-mine {
    /* Colors set via inline styles - defaults provided */
    background-color: var(--messenger-bubble-user);
    color: var(--messenger-text-primary);
    border: none;
    border-top-left-radius: var(--messenger-radius-lg);
    border-top-right-radius: var(--messenger-radius-sm);
    border-bottom-left-radius: var(--messenger-radius-lg);
    border-bottom-right-radius: var(--messenger-radius-sm);
}

/* Hover states */
.ai-bubble:hover {
    box-shadow: var(--messenger-shadow);
}

/* Single message (not grouped) gets rounded corners on all sides */
.ai-wrapper:not(:has(+ .ai-wrapper:has(.ai-other))) .ai-bubble.ai-other {
    border-bottom-left-radius: var(--messenger-radius-lg);
}

.ai-wrapper:not(:has(+ .ai-wrapper:has(.ai-mine))) .ai-bubble.ai-mine {
    border-bottom-right-radius: var(--messenger-radius-lg);
}

/* First message in group gets full top radius */
.ai-wrapper:not(:has(+ .ai-wrapper:has(.ai-other))) .ai-bubble.ai-other,
.ai-wrapper:has(+ .ai-wrapper:has(.ai-mine)) .ai-bubble.ai-other {
    border-top-left-radius: var(--messenger-radius-lg);
}

.ai-wrapper:not(:has(+ .ai-wrapper:has(.ai-mine))) .ai-bubble.ai-mine,
.ai-wrapper:has(+ .ai-wrapper:has(.ai-other)) .ai-bubble.ai-mine {
    border-top-right-radius: var(--messenger-radius-lg);
}

/* ===== Avatar Styling ===== */
.ai-avatar {
    width: var(--chatbot-conv-avatar-width, 37px);
    height: var(--chatbot-conv-avatar-height, 37px);
    min-width: var(--chatbot-conv-avatar-width, 37px);
    border-radius: var(--messenger-radius-full);
    background-size: cover;
    background-position: center;
    background-color: var(--messenger-bg-primary);
    border: none;
    box-shadow: none;
    flex-shrink: 0;
    margin-top: 2px;
    opacity: 1;
    transition: opacity 0.15s ease;
    align-self: flex-start;
}

/* User avatar styling - visible on right side */
.ai-avatar.ai-mine {
    display: block;
    opacity: 1;
    order: var(--chatbot-bubble-user-order, 1);
}

.ai-avatar.ai-other {
    order: var(--chatbot-bubble-ai-order, -1);
}

/* ===== Input Field ===== */
.aiomatic_chat_input,
.aiomatic-ai-input {
    width: 100% !important;
    max-width: 100% !important;
    padding: 9px 12px !important;
    font-size: var(--chatbot-font-size, 14.2px) !important;
    line-height: 1.4 !important;
    border: none !important;
    border-radius: var(--messenger-radius-xl) !important;
    /* Background and colors set via inline styles */
    background: var(--messenger-bg-input) !important;
    color: var(--messenger-text-primary) !important;
    transition: var(--messenger-transition) !important;
    resize: vertical;
    min-height: 24px;
    max-height: 100px;
    box-shadow: none !important;
    font-family: inherit;
}

.aiomatic_chat_input:focus,
.aiomatic-ai-input:focus {
    outline: none !important;
    box-shadow: none !important;
    /* Background respects inline styles */
}

.aiomatic_chat_input::placeholder,
.aiomatic-ai-input::placeholder {
    /* Placeholder color can be set via inline styles */
    color: var(--messenger-text-secondary);
    opacity: 1;
}

.chat-form-control {
    border-radius: var(--messenger-radius-xl) !important;
    border: none !important;
    /* Colors set via inline styles */
    background: var(--messenger-bg-input) !important;
    transition: var(--messenger-transition) !important;
    box-shadow: none !important;
}

.chat-form-control:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ===== Input Container ===== */
.aiomatic-ai-input-container {
    position: relative;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 10px 16px;
    background: var(--messenger-bg-secondary);
    border-top: 1px solid var(--messenger-border);
}

/* ===== Submit Button ===== */
/* Colors set via inline styles - defaults provided */
.aichatsubmitbut,
button.aichatsubmitbut,
.aichatsubmitbut.btn,
.aichatsubmitbut.btn-primary,
button.aichatsubmitbut.btn,
button.aichatsubmitbut.btn-primary,
.openai-chat-speech-button,
#aiimagechatsubmitbut,
.aiimagechatsubmitbut,
button.aiimagechatsubmitbut {
    position: relative !important;
    padding: 9px 14px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    font-family: inherit !important;
    border-radius: var(--messenger-radius-full) !important;
    border: none !important;
    /* Colors set via inline styles */
    background-color: var(--messenger-bubble-user) !important;
    color: var(--messenger-text-primary) !important;
    cursor: pointer !important;
    transition: var(--messenger-transition) !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    min-height: 36px !important;
    min-width: 36px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    flex-shrink: 0;
}

.aichatsubmitbut:hover,
button.aichatsubmitbut:hover,
.openai-chat-speech-button:hover,
#aiimagechatsubmitbut:hover,
.aiimagechatsubmitbut:hover,
button.aiimagechatsubmitbut:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.aichatsubmitbut:active,
button.aichatsubmitbut:active,
.openai-chat-speech-button:active,
#aiimagechatsubmitbut:active,
.aiimagechatsubmitbut:active,
button.aiimagechatsubmitbut:active {
    transform: scale(0.95);
}

.aichatsubmitbut:focus,
button.aichatsubmitbut:focus,
.openai-chat-speech-button:focus,
#aiimagechatsubmitbut:focus,
.aiimagechatsubmitbut:focus,
button.aiimagechatsubmitbut:focus {
    outline: 2px solid rgba(0, 0, 0, 0.1);
    outline-offset: 2px;
}

.aichatsubmitbut:disabled,
button.aichatsubmitbut:disabled,
.openai-chat-speech-button:disabled,
#aiimagechatsubmitbut:disabled,
.aiimagechatsubmitbut:disabled,
button.aiimagechatsubmitbut:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Icon styling inside submit buttons */
.aichatsubmitbut i,
.aichatsubmitbut svg,
.aichatsubmitbut img,
.openai-chat-speech-button i,
.openai-chat-speech-button svg,
.openai-chat-speech-button img,
#aiimagechatsubmitbut i,
#aiimagechatsubmitbut svg,
#aiimagechatsubmitbut img,
.aiimagechatsubmitbut i,
.aiimagechatsubmitbut svg,
.aiimagechatsubmitbut img,
button.aichatsubmitbut i,
button.aichatsubmitbut svg,
button.aichatsubmitbut img,
button.aiimagechatsubmitbut i,
button.aiimagechatsubmitbut svg,
button.aiimagechatsubmitbut img {
    display: inline-block !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    color: inherit !important;
    fill: currentColor !important;
    opacity: 1 !important;
    visibility: visible !important;
    width: auto !important;
    height: auto !important;
    max-width: 18px !important;
    max-height: 18px !important;
    margin: 0 !important;
}

.aichatsubmitbut svg,
.openai-chat-speech-button svg,
#aiimagechatsubmitbut svg,
.aiimagechatsubmitbut svg,
button.aichatsubmitbut svg,
button.aiimagechatsubmitbut svg {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
}

.aichatsubmitbut img,
.openai-chat-speech-button img,
#aiimagechatsubmitbut img,
.aiimagechatsubmitbut img,
button.aichatsubmitbut img,
button.aiimagechatsubmitbut img {
    width: auto !important;
    height: 18px !important;
    max-height: 18px !important;
}

/* ===== Loading Animation ===== */
.aiomatic-jumping-dots {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    align-items: center !important;
    justify-content: center !important;
    margin-left: 6px !important;
    vertical-align: middle !important;
    line-height: 1 !important;
    height: 12px !important;
}

.aiomatic-jumping-dots span {
    width: 6px !important;
    height: 6px !important;
    min-width: 6px !important;
    min-height: 6px !important;
    border-radius: var(--messenger-radius-full) !important;
    display: inline-block !important;
    animation: messenger-jump 1.4s infinite ease-in-out !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    text-indent: -9999px !important;
    overflow: hidden !important;
    position: relative !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    text-shadow: none !important;
}

/* Prevent any pseudo-elements from duplicating the dot */
.aiomatic-jumping-dots span::before,
.aiomatic-jumping-dots span::after {
    display: none !important;
    content: none !important;
}

.aiomatic-jumping-dots .aiomatic-dot-1 {
    animation-delay: -0.32s !important;
}

.aiomatic-jumping-dots .aiomatic-dot-2 {
    animation-delay: -0.16s !important;
}

.aiomatic-jumping-dots .aiomatic-dot-3 {
    animation-delay: 0s !important;
}

@keyframes messenger-jump {
    0%, 80%, 100% {
        transform: translateY(0) scale(0.9);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-6px) scale(1.1);
        opacity: 1;
    }
}

/* ===== Overlay ===== */
.aiomatic-chatbot-overlay {
    background: rgba(240, 242, 245, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.aiomatic-overlay-content {
    background: var(--messenger-bg-secondary);
    border-radius: var(--messenger-radius-xl);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--messenger-border);
    padding: 24px;
    max-width: 400px;
}

.aiomatic-start-chatting-button {
    background: var(--messenger-bubble-user) !important;
    color: var(--messenger-text-primary) !important;
    border: none !important;
    border-radius: var(--messenger-radius-xl) !important;
    padding: 10px 20px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: var(--messenger-transition) !important;
    box-shadow: var(--messenger-shadow) !important;
}

.aiomatic-start-chatting-button:hover:not(:disabled) {
    opacity: 0.9;
    transform: scale(1.02);
}

.aiomatic-start-chatting-button:disabled {
    background: var(--messenger-bg-primary) !important;
    color: var(--messenger-text-secondary) !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

/* ===== Utility Classes ===== */
.cr_fullw {
    width: 100%;
}

.cr_none {
    display: none;
}

.aiomatic-hide {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .openai-ai-form,
    .openai-ai-image-form {
        border-radius: 0;
        margin: 0;
    }
    
    .openai-card-header {
        padding: 10px 14px;
    }
    
    .aiomatic_chat_history {
        padding: 12px 6px !important;
        max-height: 500px;
    }
    
    .ai-bubble {
        max-width: 75%;
        padding: 5px 6px 7px 8px;
        font-size: calc(var(--chatbot-font-size, 14.2px) - 0.5px);
    }
    
    .aiomatic-ai-input-container {
        padding: 8px 12px;
    }
    
    .aichatsubmitbut,
    .openai-chat-speech-button,
    #aiimagechatsubmitbut {
        min-width: 40px;
        min-height: 40px;
        padding: 10px !important;
    }
}

@media (max-width: 480px) {
    .ai-bubble {
        max-width: 85%;
        padding: 4px 5px 6px 7px;
    }
    
    .openai-chat-avatar {
        width: var(--chatbot-top-avatar-width, 42px);
        height: var(--chatbot-top-avatar-height, 42px);
    }
    
    .ai-avatar {
        width: var(--chatbot-conv-avatar-width, 32px);
        height: var(--chatbot-conv-avatar-height, 32px);
        min-width: var(--chatbot-conv-avatar-width, 32px);
    }
    
    :root {
        --chatbot-bubble-max-width: 75%;
        --chatbot-message-group-gap: 10px;
    }
}

.aiomatic-window {
  position: fixed;
  right: 0px;
  padding-right: 20px;
  padding-left: 20px;
  bottom: 30px;
  width: var(--aiomatic-width);
  z-index: 9999;
}
.aiomatic-window .aiomatic-header {
  display: none;
  justify-content: flex-end;
  align-items: center;
}
.aiomatic-window .aiomatic-header .aiomatic-buttons {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-resize-button {
  justify-content: center;
  height: 32px;
  width: 33px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--aiomatic-backgroundSecondaryColor);
  border-radius: var(--aiomatic-borderRadius);
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-resize-button:before {
  transition: all 0.2s ease-out;
  content: ' ';
  cursor: pointer;
  position: absolute;
  height: 13px;
  width: 13px;
  opacity: 0.75;
  border: 2px solid var(--aiomatic-headerButtonsColor);
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-resize-button:hover:before {
  width: 16px;
  height: 16px;
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-close-button {
  margin-left: 5px;
  justify-content: center;
  height: 32px;
  width: 33px;
  cursor: pointer;
  background-color: var(--aiomatic-backgroundSecondaryColor);
  border-radius: var(--aiomatic-borderRadius);
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-close-button:before {
  transition: all 0.2s ease-out;
  transform: translate(16px, 5px) rotate(45deg);
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-close-button:after {
  transition: all 0.2s ease-out;
  transform: translate(16px, 5px) rotate(-45deg);
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-close-button:before, .aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-close-button:after {
  content: ' ';
  cursor: pointer;
  position: absolute;
  height: 22px;
  width: 2px;
  background-color: var(--aiomatic-headerButtonsColor);
  opacity: 0.75;
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-close-button:hover:before {
  opacity: 1;
  transform: translate(16px, 5px) rotate(135deg);
}
.aiomatic-window .aiomatic-header .aiomatic-buttons .aiomatic-close-button:hover:after {
  opacity: 1;
  transform: translate(16px, 5px) rotate(45deg);
}
.aiomatic-window .aiomatic-content {
  display: none;
  opacity: 0;
  max-height: var(--aiomatic-maxHeight);
}
.aiomatic-window.aiomatic-bottom-left {
  bottom: 30px;
  right: inherit;
  left: 0px;
  padding-left: 30px;
  padding-right: 30px;
}
.aiomatic-window.aiomatic-bottom-left .aiomatic-open-button {
  right: inherit;
  left: 0;
}
.aiomatic-window.aiomatic-top-right {
  top: 30px;
  bottom: inherit;
  right: 0px;
  padding-right: 30px;
  padding-left: 30px;
}
.aiomatic-window.aiomatic-top-right .aiomatic-open-button {
  top: 0;
  bottom: inherit;
}
.aiomatic-window.aiomatic-top-left {
  top: 30px;
  bottom: inherit;
  right: inherit;
  left: 0px;
  padding-left: 30px;
  padding-right: 30px;
}
.aiomatic-window.aiomatic-top-left .aiomatic-open-button {
  top: 0;
  bottom: inherit;
  right: inherit;
  left: 0;
}
.aiomatic_chat_history
{
    border-radius: 10px;
}
.aiomatic-close-button
{
    cursor: pointer;
}
/* ===== Print Styles ===== */
@media print {
    .aiomatic-window,
    .aiomatic-open-button,
    .template-button {
        display: none !important;
    }
}