/* ============================================
   Modern Chatbot Redesign 2026
   Complete visual overhaul with modern design principles
   ============================================ */

/* ===== CSS Variables for Modern Design 2026 ===== */
:root {
    --modern-primary: #5b6ef7;
    --modern-primary-dark: #4c5ef6;
    --modern-primary-light: #6b7ef8;
    --modern-primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --modern-primary-gradient-hover: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    
    --modern-secondary: #8b5cf6;
    --modern-accent: #06b6d4;
    --modern-success: #10b981;
    --modern-warning: #f59e0b;
    --modern-error: #ef4444;
    
    --modern-bg-primary: #ffffff;
    --modern-bg-secondary: #f8fafc;
    --modern-bg-tertiary: #f1f5f9;
    --modern-bg-chat: #fafbfc;
    --modern-bg-dark: #0f172a;
    --modern-bg-dark-secondary: #1e293b;
    
    --modern-text-primary: #1a202c;
    --modern-text-secondary: #4a5568;
    --modern-text-tertiary: #718096;
    --modern-text-light: #ffffff;
    
    --modern-border: #e5e7eb;
    --modern-border-light: #f3f4f6;
    --modern-border-dark: #d1d5db;
    --modern-border-hover: #9ca3af;
    
    --modern-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --modern-shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --modern-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --modern-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --modern-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    --modern-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --modern-shadow-2xl: 0 30px 60px -12px rgba(0, 0, 0, 0.2);
    
    --modern-radius-sm: 10px;
    --modern-radius: 14px;
    --modern-radius-md: 18px;
    --modern-radius-lg: 22px;
    --modern-radius-xl: 28px;
    --modern-radius-2xl: 32px;
    --modern-radius-full: 9999px;
    
    --modern-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --modern-transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --modern-transition-bounce: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Chatbot Settings Variables - Can be overridden by PHP inline styles */
    --chatbot-font-size: 15px;
    --chatbot-top-avatar-width: 50px;
    --chatbot-top-avatar-height: 50px;
    --chatbot-conv-avatar-width: 38px;
    --chatbot-conv-avatar-height: 38px;
    --chatbot-bubble-width: 100%;
    --chatbot-bubble-ai-alignment: flex-start;
    --chatbot-bubble-user-alignment: flex-end;
    --chatbot-bubble-ai-order: -1;
    --chatbot-bubble-user-order: 1;
}

/* ===== Base Container Redesign ===== */
.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 ===== */
.openai-ai-form,
.openai-ai-image-form {
    max-width: 800px;
    margin: 0 auto;
    /* Background color will be set via inline styles from shortcode parameters */
    background: var(--modern-bg-primary);
    border-radius: var(--modern-radius-2xl);
    box-shadow: var(--modern-shadow-2xl);
    border: 1px solid var(--modern-border-light);
    overflow: hidden;
    transition: var(--modern-transition-slow);
    position: relative;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.openai-ai-form:hover,
.openai-ai-image-form:hover {
    box-shadow: var(--modern-shadow-xl);
    border-color: var(--modern-border);
}

/* ===== Header Redesign ===== */
.openai-card-header {
    background: var(--modern-bg-primary);
    padding: 22px 28px;
    border-bottom: 1px solid var(--modern-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.02);
}

.openai-card-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--modern-border) 20%, 
        var(--modern-border) 80%, 
        transparent 100%);
}

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

.openai-chat-avatar {
    width: var(--chatbot-top-avatar-width, 50px);
    height: var(--chatbot-top-avatar-height, 50px);
    border-radius: var(--modern-radius-full);
    object-fit: cover;
    border: 2.5px solid var(--modern-border-light);
    box-shadow: var(--modern-shadow-sm);
    transition: var(--modern-transition);
    background: var(--modern-bg-secondary);
}

.openai-chat-avatar:hover {
    transform: scale(1.03);
    box-shadow: var(--modern-shadow);
    border-color: var(--modern-border);
}

.openai-widget-user-name {
    flex: 1;
}

.openai-persona-name {
    font-size: calc(var(--chatbot-font-size, 15px) + 2px);
    font-weight: 600;
    color: var(--modern-text-primary);
    line-height: 1.5;
    margin: 0 0 2px 0;
    letter-spacing: -0.01em;
}

.openai-persona-role {
    font-size: 13px;
    color: var(--modern-text-tertiary);
    line-height: 1.4;
    margin: 0;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.openai-text-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    position: relative;
    flex-direction: row-reverse;
}

/* ===== Dropdown Menu Container ===== */
/* Create menu icon (three dots) using pseudo-element */
.openai-text-right::before {
    content: '⋯';
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px;
    height: 38px;
    border-radius: var(--modern-radius);
    background: var(--modern-bg-secondary);
    border: 1px solid var(--modern-border-light);
    color: var(--modern-text-secondary);
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    line-height: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotate(0deg);
    transform-origin: 50% 50%;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
    text-align: center;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    letter-spacing: 0;
    word-spacing: 0;
    vertical-align: middle;
    align-self: center;
}

.openai-text-right:hover::before,
.openai-text-right:focus-within::before {
    background: var(--modern-bg-primary);
    border-color: var(--modern-border);
    color: var(--modern-text-primary);
    box-shadow: var(--modern-shadow-sm);
    transform: rotate(90deg) translateZ(0);
    backface-visibility: hidden;
}

/* Create invisible bridge area to prevent gap - extends hover area */
.openai-text-right::after {
    content: '';
    position: absolute;
    top: 100%;
    right: -6px;
    width: 50px;
    height: 200px;
    z-index: 998;
    background: transparent;
    pointer-events: none;
}

/* Activate bridge when hovered - this maintains hover state when moving to buttons */
.openai-text-right:hover::after,
.openai-text-right:focus-within::after {
    pointer-events: auto;
    cursor: default;
}

/* Hide all template buttons by default, show in dropdown on hover/focus */
/* Respect inline display styles and aiomatic-hide class */
.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.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    background: var(--modern-bg-primary) !important;
    border: 1px solid var(--modern-border) !important;
    box-shadow: var(--modern-shadow-lg) !important;
    width: 38px !important;
    height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: var(--modern-radius) !important;
    text-decoration: none !important;
    pointer-events: none;
    margin: 0 !important;
}

/* Don't control icon visibility - let aiomatic-hide class handle it */

/* Respect inline display: none and aiomatic-hide class */
.openai-text-right > .template-button.aiomatic-hide,
.openai-text-right > .template-button[style*="display: none"],
.openai-text-right > .template-button[style*="display:none"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Show buttons in dropdown on hover/focus - but respect inline hide styles */
.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;
}

/* Critical: Keep dropdown open when hovering over any button - fixes gap issue */
.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;
    pointer-events: auto !important;
}

/* When any button is hovered, keep all sibling buttons visible (but respect hide) */
.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):hover ~ .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;
}

/* Key fix: Keep parent hovered when child is hovered - maintains dropdown (but respect hide) */
.openai-text-right:has(.template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):hover) > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]),
.openai-text-right:has(.template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):focus) > .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;
}

/* Stagger the animation for each visible button - dynamic positioning */
/* JavaScript sets --button-index and top position for gap-free positioning */
/* Fallback CSS for when JavaScript hasn't run yet */

/* Base: All visible buttons - JavaScript will override top position */
.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]) {
    /* JavaScript sets top position dynamically */
    transition-delay: calc(var(--button-index, 0) * 0.05s + 0.05s);
}

/* Fallback positioning for when JavaScript hasn't run (uses nth-child) */
.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):first-child {
    transition-delay: 0.05s;
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-child(2) {
    transition-delay: 0.1s;
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-child(3) {
    transition-delay: 0.15s;
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-child(4) {
    transition-delay: 0.2s;
}

.openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):nth-child(5) {
    transition-delay: 0.25s;
}

/* Keep buttons interactive in dropdown (but respect hide) */
.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 {
    background: var(--modern-bg-tertiary) !important;
    border-color: var(--modern-border-dark) !important;
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--modern-shadow-xl) !important;
    outline: none;
}

/* Mobile/Touch device support */
@media (hover: none) and (pointer: coarse) {
    /* Make buttons focusable for touch */
    .openai-text-right > .template-button {
        tabindex: 0;
    }
    
    /* Show dropdown when menu icon is tapped (but respect hide) */
    .openai-text-right:active > .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;
    }
    
    /* Keep dropdown open when any button is focused/tapped (but respect hide) */
    .openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):focus,
    .openai-text-right > .template-button:not(.aiomatic-hide):not([style*="display: none"]):not([style*="display:none"]):active {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) scale(1) !important;
        pointer-events: auto !important;
    }
    
    /* Ensure parent stays active when child is focused */
    .openai-text-right:focus-within {
        /* Keep dropdown open */
    }
}

/* Ensure buttons are accessible with tap highlight */
.openai-text-right > .template-button {
    -webkit-tap-highlight-color: rgba(91, 110, 247, 0.2);
    tap-highlight-color: rgba(91, 110, 247, 0.2);
}

/* Make the container focusable for keyboard navigation */
.openai-text-right {
    outline: none;
}

.openai-text-right:focus-within {
    /* Dropdown stays open when focused */
}

/* ===== Action Buttons Redesign ===== */
.template-button {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--modern-radius);
    background: var(--modern-bg-secondary);
    border: 1px solid var(--modern-border-light);
    color: var(--modern-text-secondary);
    cursor: pointer;
    transition: var(--modern-transition);
    text-decoration: none;
    position: relative;
}

.template-button:hover {
    background: var(--modern-bg-tertiary);
    border-color: var(--modern-border);
    color: var(--modern-text-primary);
    transform: translateY(-1px);
    box-shadow: var(--modern-shadow);
}

.template-button:active {
    transform: translateY(0);
    box-shadow: none;
}

.template-button i {
    font-size: 17px;
    display: inline-block;
    line-height: 1;
    vertical-align: middle;
    color: inherit;
}


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

/* Custom Scrollbar */
.aiomatic_chat_history::-webkit-scrollbar {
    width: 8px;
}

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

.aiomatic_chat_history::-webkit-scrollbar-thumb {
    background: var(--modern-border-dark);
    border-radius: var(--modern-radius-full);
    transition: var(--modern-transition);
}

.aiomatic_chat_history::-webkit-scrollbar-thumb:hover {
    background: var(--modern-text-tertiary);
}

/* ===== Buttons Dropdown ===== */
.openai-buttons-dropdown {
    font-family: auto;
}

/* ===== Chat Bubbles Modern Redesign ===== */
.ai-chat {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 0;
}

.ai-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 0;
    width: 100%;
}

/* AI Message Wrapper - respects bubble alignment */
.ai-wrapper:has(.ai-other) {
    justify-content: var(--chatbot-bubble-ai-alignment, flex-start);
}

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

.ai-bubble {
    width: var(--chatbot-bubble-width, 100%) !important;
    max-width: 100%;
    word-wrap: break-word;
    word-break: break-word;
    padding: 16px 20px;
    border-radius: var(--modern-radius-md);
    line-height: 1.7;
    font-size: var(--chatbot-font-size, 15px);
    position: relative;
    transition: var(--modern-transition);
    cursor: pointer;
    box-shadow: var(--modern-shadow-xs);
    font-weight: 400;
    flex: 1;
    min-width: 0;
}

.ai-bubble:hover {
    transform: translateY(-1px);
    box-shadow: var(--modern-shadow-sm);
}

/* User Messages (Right Side) */
.ai-mine {
    /* Colors will be set via inline styles from shortcode parameters with !important */
    /* Default fallback colors - will be overridden by PHP-generated inline styles */
    background-color: var(--modern-primary);
    color: var(--modern-text-light);
}

.ai-bubble.ai-mine {
    margin-left: 0;
    border-bottom-right-radius: var(--modern-radius-md);
    border-bottom-left-radius: var(--modern-radius-md);
    box-shadow: var(--modern-shadow);
    font-weight: 400;
}

.ai-bubble.ai-mine:hover {
    box-shadow: var(--modern-shadow-md);
}

/* AI Messages (Left Side) */
.ai-other {
    /* Colors will be set via inline styles from shortcode parameters with !important */
    /* Default fallback colors - will be overridden by PHP-generated inline styles */
    background-color: var(--modern-bg-primary);
    color: var(--modern-text-primary);
}

.ai-bubble.ai-other {
    border: 1px solid var(--modern-border-light);
    margin-right: 0;
    border-bottom-left-radius: var(--modern-radius-md);
    border-bottom-right-radius: var(--modern-radius-md);
    box-shadow: var(--modern-shadow-xs);
}

.ai-bubble.ai-other:hover {
    border-color: var(--modern-border);
    box-shadow: var(--modern-shadow-sm);
}

/* Avatar Styling */
.ai-avatar {
    width: var(--chatbot-conv-avatar-width, 38px);
    height: var(--chatbot-conv-avatar-height, 38px);
    min-width: var(--chatbot-conv-avatar-width, 38px);
    border-radius: var(--modern-radius-full);
    background-size: cover;
    background-position: center;
    background-color: var(--modern-bg-tertiary);
    border: 2px solid var(--modern-border-light);
    box-shadow: var(--modern-shadow-xs);
    flex-shrink: 0;
    margin-top: 2px;
}

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

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

/* ===== Input Field Modern Redesign ===== */
.aiomatic_chat_input,
.aiomatic-ai-input {
    width: 100% !important;
    max-width: 100% !important;
    padding: 14px 18px !important;
    font-size: var(--chatbot-font-size, 15px) !important;
    line-height: 1.6 !important;
    border: 1.5px solid var(--modern-border);
    border-radius: var(--modern-radius-lg) !important;
    /* Colors will be set via inline styles from shortcode parameters */
    background: var(--modern-bg-primary);
    color: var(--modern-text-primary);
    transition: var(--modern-transition) !important;
    resize: vertical;
    min-height: 52px;
    box-shadow: var(--modern-shadow-xs);
    font-family: inherit;
}

.aiomatic_chat_input:focus,
.aiomatic-ai-input:focus {
    outline: none !important;
    border-color: var(--modern-primary);
    box-shadow: 0 0 0 3px rgba(91, 110, 247, 0.08), var(--modern-shadow-sm);
    /* Background color respects inline styles */
}

.aiomatic_chat_input::placeholder,
.aiomatic-ai-input::placeholder {
    /* Placeholder color will be set via inline styles if provided */
    color: var(--modern-text-tertiary);
    opacity: 1;
}

.chat-form-control {
    border-radius: var(--modern-radius-lg) !important;
    border: 1.5px solid var(--modern-border);
    /* Colors will be set via inline styles from shortcode parameters */
    background: var(--modern-bg-primary);
    transition: var(--modern-transition) !important;
    box-shadow: var(--modern-shadow-xs);
}

.chat-form-control:focus {
    border-color: var(--modern-primary);
    box-shadow: 0 0 0 3px rgba(91, 110, 247, 0.08), var(--modern-shadow-sm);
}

/* ===== Modern Submit Button Redesign 2026 - Professional ===== */
.aiomatic-design-modern .aichatsubmitbut,
.aiomatic-design-modern button.aichatsubmitbut,
.aiomatic-design-modern .aichatsubmitbut.btn,
.aiomatic-design-modern .aichatsubmitbut.btn-primary,
.aiomatic-design-modern button.aichatsubmitbut.btn,
.aiomatic-design-modern button.aichatsubmitbut.btn-primary,
.aiomatic-design-modern .openai-chat-speech-button,
.aiomatic-design-modern #aiimagechatsubmitbut,
.aiomatic-design-modern .aiimagechatsubmitbut,
.aiomatic-design-modern button.aiimagechatsubmitbut,
.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: 16px 32px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    border-radius: var(--modern-radius-lg) !important;
    border: none !important;
    /* Colors will be set via inline styles from shortcode parameters with !important */
    /* Default fallback colors - will be overridden by PHP-generated inline styles */
    background-color: var(--modern-primary) !important;
    color: var(--modern-text-light) !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 4px 14px rgba(91, 110, 247, 0.3), 
                0 2px 4px rgba(0, 0, 0, 0.06),
                inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    text-transform: none !important;
    letter-spacing: 0.01em !important;
    min-height: 52px !important;
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    isolation: isolate !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(10px) !important;
}

/* Modern button with subtle shine effect */
.aiomatic-design-modern .aichatsubmitbut::before,
.aiomatic-design-modern button.aichatsubmitbut::before,
.aiomatic-design-modern .openai-chat-speech-button::before,
.aiomatic-design-modern #aiimagechatsubmitbut::before,
.aiomatic-design-modern .aiimagechatsubmitbut::before,
.aiomatic-design-modern button.aiimagechatsubmitbut::before,
.aichatsubmitbut::before,
button.aichatsubmitbut::before,
.openai-chat-speech-button::before,
#aiimagechatsubmitbut::before,
.aiimagechatsubmitbut::before,
button.aiimagechatsubmitbut::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent);
    transition: left 0.5s ease;
    z-index: 1;
    pointer-events: none;
}

.aiomatic-design-modern .aichatsubmitbut:hover::before,
.aiomatic-design-modern button.aichatsubmitbut:hover::before,
.aiomatic-design-modern .openai-chat-speech-button:hover::before,
.aiomatic-design-modern #aiimagechatsubmitbut:hover::before,
.aiomatic-design-modern .aiimagechatsubmitbut:hover::before,
.aiomatic-design-modern button.aiimagechatsubmitbut:hover::before,
.aichatsubmitbut:hover::before,
button.aichatsubmitbut:hover::before,
.openai-chat-speech-button:hover::before,
#aiimagechatsubmitbut:hover::before,
.aiimagechatsubmitbut:hover::before,
button.aiimagechatsubmitbut:hover::before {
    left: 100%;
}

.aiomatic-design-modern .aichatsubmitbut > *,
.aiomatic-design-modern button.aichatsubmitbut > *,
.aiomatic-design-modern .openai-chat-speech-button > *,
.aiomatic-design-modern #aiimagechatsubmitbut > *,
.aiomatic-design-modern .aiimagechatsubmitbut > *,
.aiomatic-design-modern button.aiimagechatsubmitbut > *,
.aichatsubmitbut > *,
button.aichatsubmitbut > *,
.openai-chat-speech-button > *,
#aiimagechatsubmitbut > *,
.aiimagechatsubmitbut > *,
button.aiimagechatsubmitbut > * {
    position: relative;
    z-index: 2;
}

.aiomatic-design-modern .aichatsubmitbut:hover,
.aiomatic-design-modern button.aichatsubmitbut:hover,
.aiomatic-design-modern .openai-chat-speech-button:hover,
.aiomatic-design-modern #aiimagechatsubmitbut:hover,
.aiomatic-design-modern .aiimagechatsubmitbut:hover,
.aiomatic-design-modern button.aiimagechatsubmitbut:hover,
.aichatsubmitbut:hover,
button.aichatsubmitbut:hover,
.openai-chat-speech-button:hover,
#aiimagechatsubmitbut:hover,
.aiimagechatsubmitbut:hover,
button.aiimagechatsubmitbut:hover {
    transform: translateY(-2px) scale(1.01) !important;
    box-shadow: 0 8px 24px rgba(91, 110, 247, 0.4), 
                0 4px 8px rgba(0, 0, 0, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    filter: brightness(1.05);
}

.aiomatic-design-modern .aichatsubmitbut:active,
.aiomatic-design-modern button.aichatsubmitbut:active,
.aiomatic-design-modern .openai-chat-speech-button:active,
.aiomatic-design-modern #aiimagechatsubmitbut:active,
.aiomatic-design-modern .aiimagechatsubmitbut:active,
.aiomatic-design-modern button.aiimagechatsubmitbut:active,
.aichatsubmitbut:active,
button.aichatsubmitbut:active,
.openai-chat-speech-button:active,
#aiimagechatsubmitbut:active,
.aiimagechatsubmitbut:active,
button.aiimagechatsubmitbut:active {
    transform: translateY(0) scale(0.99) !important;
    box-shadow: 0 2px 8px rgba(91, 110, 247, 0.25), 
                0 1px 2px rgba(0, 0, 0, 0.04),
                inset 0 1px 2px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
    filter: brightness(0.95);
}

.aiomatic-design-modern .aichatsubmitbut:focus,
.aiomatic-design-modern button.aichatsubmitbut:focus,
.aiomatic-design-modern .openai-chat-speech-button:focus,
.aiomatic-design-modern #aiimagechatsubmitbut:focus,
.aiomatic-design-modern .aiimagechatsubmitbut:focus,
.aiomatic-design-modern button.aiimagechatsubmitbut:focus,
.aichatsubmitbut:focus,
button.aichatsubmitbut:focus,
.openai-chat-speech-button:focus,
#aiimagechatsubmitbut:focus,
.aiimagechatsubmitbut:focus,
button.aiimagechatsubmitbut:focus {
    outline: none !important;
    box-shadow: 0 0 0 4px rgba(91, 110, 247, 0.25), 
                0 8px 24px rgba(91, 110, 247, 0.35),
                0 4px 8px rgba(0, 0, 0, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    filter: brightness(1.05);
}

/* Disabled state */
.aiomatic-design-modern .aichatsubmitbut:disabled,
.aiomatic-design-modern button.aichatsubmitbut:disabled,
.aiomatic-design-modern .openai-chat-speech-button:disabled,
.aiomatic-design-modern #aiimagechatsubmitbut:disabled,
.aiomatic-design-modern .aiimagechatsubmitbut:disabled,
.aiomatic-design-modern button.aiimagechatsubmitbut:disabled,
.aichatsubmitbut:disabled,
button.aichatsubmitbut:disabled,
.openai-chat-speech-button:disabled,
#aiimagechatsubmitbut:disabled,
.aiimagechatsubmitbut:disabled,
button.aiimagechatsubmitbut:disabled {
    opacity: 0.55;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
    filter: grayscale(0.3);
    pointer-events: none;
}

.aiomatic-design-modern .aichatsubmitbut:disabled:hover,
.aiomatic-design-modern button.aichatsubmitbut:disabled:hover,
.aiomatic-design-modern .openai-chat-speech-button:disabled:hover,
.aiomatic-design-modern #aiimagechatsubmitbut:disabled:hover,
.aiomatic-design-modern .aiimagechatsubmitbut:disabled:hover,
.aiomatic-design-modern button.aiimagechatsubmitbut:disabled:hover,
.aichatsubmitbut:disabled:hover,
button.aichatsubmitbut:disabled:hover,
.openai-chat-speech-button:disabled:hover,
#aiimagechatsubmitbut:disabled:hover,
.aiimagechatsubmitbut:disabled:hover,
button.aiimagechatsubmitbut:disabled:hover {
    transform: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
    filter: grayscale(0.3);
}

/* ===== Form Group Spacing ===== */
.form-group {
    margin-bottom: 20px;
}

.code-form-top-pad {
    padding-top: 24px;
}

/* ===== Input Container ===== */
.aiomatic-ai-input-container {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 22px 28px;
    background: var(--modern-bg-primary);
    border-top: 1px solid var(--modern-border-light);
    box-shadow: 0 -1px 0 0 rgba(0, 0, 0, 0.02);
}

.aiomatic-close-button
{
  font-size: 20px;
  cursor: pointer;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.code-form-top-pad{padding-top: 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-open-button
{
  cursor: pointer;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
/* ===== Custom Header/Footer ===== */
.openai-custom-header,
.openai-custom-footer {
    padding: 20px 28px;
    background: var(--modern-bg-primary);
    border-bottom: 1px solid var(--modern-border-light);
}

.openai-custom-footer {
    border-bottom: none;
    border-top: 1px solid var(--modern-border-light);
}

/* ===== Compliance Text ===== */
.aiomatic-text-center {
    text-align: center;
    padding: 18px 28px;
    font-size: 12px;
    color: var(--modern-text-tertiary);
    background: var(--modern-bg-primary);
    border-top: 1px solid var(--modern-border-light);
    letter-spacing: 0.02em;
}

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

.aiomatic-jumping-dots span {
    width: 7px !important;
    height: 7px !important;
    min-width: 7px !important;
    min-height: 7px !important;
    border-radius: var(--modern-radius-full) !important;
    background: rgba(255, 255, 255, 0.9) !important;
    display: inline-block !important;
    animation: 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;
}

/* Hide the period character and use the element as a dot */
.aiomatic-jumping-dots span::before {
    content: '' !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: var(--modern-radius-full) !important;
    background: rgba(255, 255, 255, 0.9) !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 jump {
    0%, 80%, 100% {
        transform: translateY(0) scale(0.85);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-8px) scale(1.1);
        opacity: 1;
    }
}

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

.aiomatic-overlay-content {
    background: var(--modern-bg-primary);
    border-radius: var(--modern-radius-xl);
    box-shadow: var(--modern-shadow-xl);
    border: 1px solid var(--modern-border);
    padding: 32px;
    max-width: 500px;
}

.aiomatic-start-chatting-button {
    background: var(--modern-primary-gradient) !important;
    color: var(--modern-text-light) !important;
    border: none !important;
    border-radius: var(--modern-radius-lg) !important;
    padding: 13px 26px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: var(--modern-transition) !important;
    box-shadow: var(--modern-shadow) !important;
}

.aiomatic-start-chatting-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--modern-shadow-md) !important;
    background: var(--modern-primary-gradient-hover) !important;
}

.aiomatic-start-chatting-button:disabled {
    background: var(--modern-bg-tertiary) !important;
    color: var(--modern-text-tertiary) !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .openai-ai-form,
    .openai-ai-image-form {
        border-radius: var(--modern-radius-lg);
        margin: 0 16px;
    }
    
    .openai-card-header {
        padding: 16px 20px;
    }
    
    .aiomatic_chat_history {
        padding: 20px 16px;
        max-height: 500px;
    }
    
    .ai-bubble {
        width: var(--chatbot-bubble-width, 100%) !important;
        max-width: 100%;
        padding: 14px 18px;
        font-size: calc(var(--chatbot-font-size, 15px) - 1px);
    }
    
    .aiomatic-ai-input-container {
        padding: 16px 20px;
        flex-direction: column;
        gap: 12px;
    }
    
    .openai-chat-speech-button,
    #aiimagechatsubmitbut {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .ai-bubble {
        width: 100%;
        max-width: 100%;
        padding: 12px 16px;
    }
    
    .openai-chat-avatar {
        width: var(--chatbot-top-avatar-width, 40px);
        height: var(--chatbot-top-avatar-height, 40px);
    }
    
    .ai-avatar {
        width: var(--chatbot-conv-avatar-width, 32px);
        height: var(--chatbot-conv-avatar-height, 32px);
        min-width: var(--chatbot-conv-avatar-width, 32px);
    }
}

/* ===== 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;
}

/* Ensure hidden buttons in dropdown stay hidden */
.openai-text-right > .template-button.aiomatic-hide {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
}

/* ===== Smooth Transitions for All Interactive Elements ===== */
.aiomatic-chat-holder * {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* ===== Focus States ===== */
*:focus-visible {
    outline: 2px solid var(--modern-primary);
    outline-offset: 2px;
}

/* ===== Print Styles ===== */
@media print {
    .aiomatic-window,
    .aiomatic-open-button,
    .template-button {
        display: none !important;
    }
}
