/**
 * AC Context Aware Chatbase - Chatbot Styles
 * 
 * Minimalist AI chat interface styling
 * 
 * @package AC_Context_Aware_Chatbase
 * @version 1.0.0
 */

/* Color Variables */
:root {
    --accent: #ff8800;
    --charcoal: #1a1a1a;
    --surface: #fbfbfb;
    --neutral-50: #fafafa;
    --neutral-100: #f5f5f5;
    --neutral-200: #e5e5e5;
    --neutral-300: #d4d4d4;
    --neutral-400: #a3a3a3;
    --neutral-500: #737373;
    --neutral-600: #525252;
    --neutral-700: #404040;
}

/* Custom scrollbar - hidden for minimalism */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Pattern Background */
.bg-pattern {
    background-color: #ffffff;
    background-image: radial-gradient(#e5e5e5 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Typing animation dots */
.typing-dot {
    animation: typingDot 1.4s infinite ease-in-out both;
    width: 6px;
    height: 6px;
    background: #ff8800;
    border-radius: 50%;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Chatbot Overlay */
.chatbot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    display: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(2px);
}

.chatbot-overlay.enabled {
    display: block !important;
}

.chatbot-overlay.enabled.active {
    opacity: 1;
    visibility: visible;
}

/* Chatbot Button */
#custom-chatbot-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--charcoal);
    color: white;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    display: none !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    z-index: 9999;
}

#custom-chatbot-button.enabled {
    display: flex !important;
}

#custom-chatbot-button:hover {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 20px 50px -12px rgba(255, 136, 0, 0.2);
}

#custom-chatbot-button.active {
    background: var(--accent);
}

#custom-chatbot-button svg {
    width: 24px;
    height: 24px;
}

/* Rainbow Glow Animation */
@keyframes rainbowGlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Chatbot Window Wrapper for Glow Effect */
#custom-chatbot-window-wrapper {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    z-index: 9999;
    display: none !important;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

#custom-chatbot-window-wrapper.enabled.active {
    opacity: 0.3;
}

#custom-chatbot-window-wrapper::before {
    content: '';
    position: absolute;
    top: -7.25px;
    left: -7.25px;
    right: -7.25px;
    bottom: -7.25px;
    border-radius: 17px;
    background: linear-gradient(
        45deg,
        #ff0080,
        #ff8c00,
        #ffd700,
        #32cd32,
        #00bfff,
        #4169e1,
        #8a2be2,
        #ff0080
    );
    background-size: 400% 400%;
    animation: rainbowGlow 15s ease infinite;
    z-index: -1;
    opacity: 0.3;
    filter: blur(12px);
}

#custom-chatbot-window-wrapper.enabled {
    display: block !important;
}

#custom-chatbot-window-wrapper.enabled.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Chatbot Window */
#custom-chatbot-window {
    width: 100%;
    height: 100%;
    background: #ffffff;
    border: 1px solid var(--neutral-200);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

#custom-chatbot-window.enabled {
    display: none !important;
}

#custom-chatbot-window.enabled.active {
    display: flex !important;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Chatbot Header */
.chatbot-header {
    background: #ffffff;
    border-bottom: 1px solid var(--neutral-100);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 20;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.chatbot-avatar-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--charcoal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-weight: 500;
    font-size: 12px;
    letter-spacing: -0.5px;
}

.chatbot-header-info {
    display: flex;
    flex-direction: column;
}

.chatbot-title {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.2px;
    color: #ff8800;
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-inline-title {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.2px;
    color: #ff8800;
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-status {
    font-size: 10px;
    color: var(--accent);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.chatbot-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff8800;
    animation: pulse 2s infinite;
    box-shadow: 0 0 4px rgba(255, 136, 0, 0.5);
    flex-shrink: 0;
    display: inline-block;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chatbot-header-btn,
.chatbot-close-btn {
    background: #F80 !important;
    border: none !important;
    color: white !important;
    cursor: pointer;
    padding: 0 !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: background 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    box-sizing: border-box !important;
}

.chatbot-header-btn:hover {
    background: rgba(255, 136, 0, 0.1);
    color: #ff8800;
}

.chatbot-close-btn:hover {
    background: #e67700 !important;
}

.chatbot-header-btn svg {
    width: 18px;
    height: 18px;
}

.chatbot-close-btn svg {
    width: 16px !important;
    height: 16px !important;
    color: white !important;
    stroke: white !important;
    stroke-width: 3 !important;
    fill: none !important;
}

/* Chatbot Messages */
#chatbot-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: #ffffff;
    min-height: 0;
    scroll-behavior: smooth;
}

#chatbot-messages.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#chatbot-messages.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.chatbot-message {
    margin-bottom: 32px;
    display: flex;
    align-items: flex-start;
    max-width: 672px;
    animation: none !important;
    transition: none !important;
    flex-shrink: 0; /* Prevent messages from shrinking */
}

/* Exception: typing indicator should not have bottom margin */
.chatbot-message.typing-indicator {
    margin-bottom: 0 !important;
}

.chatbot-message.assistant-message:first-child {
    margin-bottom: 48px;
}

.chatbot-message.user-message {
    flex-direction: row-reverse;
    margin-left: auto;
}

/* Message Avatar - Hidden */
.message-avatar {
    display: none !important;
}

/* Message Content */
.message-content {
    width: fit-content;
    max-width: 100%;
    background: var(--surface);
    border: 1px solid var(--neutral-100);
    padding: 14px 20px;
    border-radius: 16px;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    animation: none !important;
    transition: none !important;
}

.chatbot-message.assistant-message .message-content {
    background: transparent;
    border: 2px solid #ff8800;
    color: #000000;
}

.chatbot-message.user-message .message-content {
    background: transparent;
    color: #000000;
    border: 2px solid var(--charcoal);
    border-top-right-radius: 4px;
    border-top-left-radius: 16px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.message-agent-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--charcoal);
    display: none; /* Hidden in new design */
}

.message-text {
    line-height: 1.5;
    word-wrap: break-word;
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    font-size: 14px;
    font-weight: 400;
    color: var(--neutral-700);
    letter-spacing: -0.1px;
}

.chatbot-message.assistant-message .message-text {
    color: #000000;
}

.chatbot-message.user-message .message-text {
    color: #000000;
    font-weight: 400;
    letter-spacing: -0.1px;
}

.message-text a {
    color: inherit;
    text-decoration: underline;
}

.chatbot-message.assistant-message .message-text a {
    color: #ff8800;
    text-decoration: underline;
}

.chatbot-message.user-message .message-text a {
    color: var(--charcoal);
    text-decoration: underline;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    max-width: 672px;
    margin-right: 60px; /* Prevent covering submit button */
    position: relative; /* Ensure it doesn't affect layout flow */
    flex-shrink: 0; /* Prevent shrinking */
    margin-bottom: 0 !important; /* No bottom margin that could push form */
    height: auto !important; /* Prevent height changes */
    min-height: 0 !important; /* No minimum height */
}

.typing-indicator .message-avatar {
    border: none;
    background: transparent;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #ff8800;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

/* Chatbot Form */
.chatbot-form {
    flex-shrink: 0;
    border-top: 1px solid var(--neutral-100);
    padding: 16px 24px 24px;
    background: #ffffff;
    z-index: 20;
    position: relative;
}

/* Chatbot Input Container */
.chatbot-input-container {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
    display: flex;
    align-items: flex-end;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.chatbot-input-container:focus-within {
    border-color: #ff8800;
    background: white;
    box-shadow: 0 4px 12px rgba(255, 136, 0, 0.15);
}

.chatbot-input-container.typing-active {
    opacity: 0.6;
    pointer-events: none;
}

/* Input Attach Button */
.chatbot-input-attach {
    padding: 12px;
    margin: 2px 0 2px 4px;
    background: none;
    border: none;
    color: var(--neutral-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.chatbot-input-attach:hover {
    color: var(--charcoal);
}

.chatbot-input-attach svg {
    width: 20px;
    height: 20px;
}

/* Chatbot Input */
#chatbot-input {
    flex: 1;
    padding: 16px 0 16px 16px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--charcoal);
    outline: none;
    resize: none;
    min-height: 56px;
    max-height: 128px;
    font-family: inherit;
    line-height: 1.5;
    letter-spacing: -0.1px;
}

#chatbot-input::placeholder {
    color: var(--neutral-400);
}

/* Input Action Buttons */
.chatbot-input-actions {
    padding: 8px;
    display: flex;
    gap: 4px;
    align-items: center;
    margin: 2px 4px 2px 0;
}

.chatbot-input-mic {
    padding: 8px;
    background: none;
    border: none;
    color: var(--neutral-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.chatbot-input-mic:hover {
    background: var(--neutral-100);
    color: var(--charcoal);
}

.chatbot-input-mic svg {
    width: 20px;
    height: 20px;
}

#chatbot-submit {
    width: 36px;
    height: 36px;
    background: #ff8800;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(255, 136, 0, 0.3);
    padding: 0;
    margin: 0;
    min-width: 36px;
    min-height: 36px;
}

#chatbot-submit:hover:not(:disabled) {
    background: #e67700;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255, 136, 0, 0.4);
}

#chatbot-submit:active:not(:disabled) {
    transform: scale(0.95);
}

#chatbot-submit:disabled {
    background: var(--neutral-300);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#chatbot-submit svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
    fill: white;
    stroke: white;
}

#chatbot-submit:hover:not(:disabled) svg {
    transform: translate(1px, -1px);
}

/* Input Footer Disclaimer */
.chatbot-input-disclaimer {
    text-align: center;
    margin-top: 12px;
}

.chatbot-input-disclaimer p {
    font-size: 10px;
    color: var(--neutral-400);
    letter-spacing: 0.2px;
    margin: 0;
}

/* Suggested Questions */
.chatbot-suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 24px;
    padding: 0;
}

.chatbot-suggested-question {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--neutral-500);
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    display: inline-block;
    /* transform removed - no transforms on suggested questions */
}

.chatbot-suggested-question:hover:not(.disabled),
.chatbot-suggested-question.animate-hover:not(.disabled) {
    border-color: #ff8800;
    color: #ff8800;
    box-shadow: 0 4px 8px rgba(255, 136, 0, 0.2);
    background: rgba(255, 136, 0, 0.05);
    /* transform removed - no hover transforms */
}

.chatbot-suggested-question.disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* Rainbow Glow for Inline Chatbot */
.chatbot-inline-container {
    position: relative;
    border: 1px solid var(--neutral-200);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.1);
    display: flex !important;
    flex-direction: column !important;
    margin: 20px 0;
    max-height: 100%;
    height: auto;
    z-index: 1;
    overflow: hidden; /* Prevent form from moving */
    align-items: stretch !important; /* Ensure children respect container width */
}

.chatbot-inline-container::before {
    content: '';
    position: absolute;
    top: -7.25px;
    left: -7.25px;
    right: -7.25px;
    bottom: -7.25px;
    border-radius: 17px;
    background: linear-gradient(
        45deg,
        #ff0080,
        #ff8c00,
        #ffd700,
        #32cd32,
        #00bfff,
        #4169e1,
        #8a2be2,
        #ff0080
    );
    background-size: 400% 400%;
    animation: rainbowGlow 15s ease infinite;
    z-index: -1;
    opacity: 0.6;
    filter: blur(12px);
    pointer-events: none;
}

.chatbot-inline-header,
.chatbot-inline-messages,
.chatbot-inline-form {
    position: relative;
    z-index: 1;
}

.chatbot-inline-header {
    border-radius: 10px 10px 0 0;
    overflow: hidden;
}

.chatbot-inline-messages {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex: 0 1 auto !important; /* Don't grow, only shrink if needed */
    flex-grow: 0 !important; /* Prevent growing - CRITICAL */
    flex-shrink: 1 !important; /* Allow shrinking */
    flex-basis: auto !important;
    min-height: 0 !important; /* Allow flex shrinking */
    padding-bottom: 0 !important; /* No extra padding that could affect form */
    margin-bottom: 0 !important; /* No margin that could push form */
    box-sizing: border-box !important;
    /* Height and max-height are set inline via PHP - those take precedence */
}

.chatbot-inline-form {
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.chatbot-inline-header {
    background: #ffffff;
    border-bottom: 1px solid var(--neutral-100);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-inline-title {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.2px;
    color: #ff8800;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-inline-header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chatbot-inline-download-chat,
.chatbot-inline-new-chat {
    background: none;
    border: none;
    color: var(--neutral-400);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.chatbot-inline-new-chat {
    padding: 8px 12px;
    white-space: nowrap;
}

.chatbot-inline-download-chat:hover,
.chatbot-inline-new-chat:hover {
    background: rgba(255, 136, 0, 0.1);
    color: #ff8800;
}

.chatbot-inline-download-chat svg {
    width: 18px;
    height: 18px;
}

.chatbot-inline-messages {
    flex: 1 1 auto;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #ffffff;
    min-height: 0;
    display: flex !important;
    flex-direction: column !important;
    position: relative;
}

.chatbot-inline-messages.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.chatbot-inline-messages.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Ensure correct order for inline messages */
.chatbot-inline-messages > .chatbot-message.assistant-message:first-child {
    order: 1 !important;
}

.chatbot-inline-messages > .chatbot-suggested-questions {
    order: 2 !important;
}

.chatbot-inline-messages > p.suggested-questions-intro {
    order: 3 !important;
}

.chatbot-inline-messages .chatbot-message.user-message,
.chatbot-inline-messages .chatbot-message.assistant-message:not(:first-child) {
    order: 4 !important;
}

.chatbot-inline-form {
    flex: 0 0 auto !important; /* Fixed size, no grow, no shrink */
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    flex-basis: auto !important;
    /* border-top: 1px solid var(--neutral-100); */
    padding: 16px 24px 24px;
    background: #ffffff;
    position: relative !important; /* Needed for absolute positioning of submit button */
    z-index: 10; /* Ensure form stays above messages */
    order: 999; /* Ensure form is always last in flex order */
    margin-top: 0 !important; /* No margin that could be affected by messages */
    margin-bottom: 0 !important; /* No bottom margin */
    transform: translateZ(0); /* Force hardware acceleration to prevent movement */
    will-change: auto; /* Prevent layout shifts */
    box-sizing: border-box !important;
}

.chatbot-inline-input-container {
    position: relative; /* Normal flow */
    background: var(--surface);
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
    display: flex;
    align-items: flex-end;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    flex-shrink: 0; /* Prevent container from shrinking */
    padding-right: 60px; /* Add right padding for absolutely positioned submit button */
    margin-right: 0; /* No margin */
}

.chatbot-inline-input-container:focus-within {
    border-color: #ff8800;
    background: white;
    box-shadow: 0 4px 12px rgba(255, 136, 0, 0.15);
}

.chatbot-inline-input {
    flex: 1;
    width: 100%;
    padding: 16px 16px; /* Normal padding, container handles right spacing */
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--charcoal);
    outline: none;
    resize: none;
    min-height: 56px;
    max-height: 128px;
    font-family: inherit;
    line-height: 1.5;
    letter-spacing: -0.1px;
}

.chatbot-inline-input::placeholder {
    color: var(--neutral-400);
}

.chatbot-inline-submit {
    position: absolute !important; /* Absolutely positioned relative to form container */
    right: 24px !important; /* Position from right edge of form (matches form padding) */
    top: 50% !important; /* Center vertically */
    transform: translateY(-50%) translateZ(0) !important; /* Center and force hardware acceleration */
    width: 36px !important;
    height: 36px !important;
    background: #ff8800 !important;
    color: white !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 12px !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 136, 0, 0.3) !important;
    min-width: 36px !important;
    min-height: 36px !important;
    z-index: 10 !important; /* Ensure button is above input */
    will-change: auto; /* Prevent layout shifts */
}

/* Wrapper for button and input container */
.chatbot-inline-form-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* Desktop: Position button centered vertically over input container */
@media (min-width: 769px) {
    .chatbot-inline-form {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .chatbot-inline-form .chatbot-disclosure {
        width: 100% !important;
        margin-bottom: 12px !important;
    }
    
    .chatbot-inline-form-wrapper {
        position: relative !important; /* Positioning context for button */
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        width: 100% !important;
    }
    
    .chatbot-inline-form .chatbot-inline-input-container {
        flex: 1 !important; /* Take remaining space */
        padding-right: 60px !important; /* Make room for absolutely positioned button */
        margin-right: 0 !important;
    }
    
    .chatbot-inline-form .chatbot-inline-submit {
        position: absolute !important; /* Absolutely positioned over input container */
        right: 24px !important; /* Position from right edge of form */
        top: 50% !important; /* Center vertically */
        transform: translateY(-50%) translateZ(0) !important; /* Center and force hardware acceleration */
        bottom: auto !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
    }
}

/* Mobile: Button absolutely positioned and centered vertically */
@media (max-width: 768px) {
    .chatbot-inline-form-wrapper {
        position: relative;
    }
    
    .chatbot-inline-form .chatbot-inline-submit {
        position: absolute !important;
        right: 24px !important;
        top: 50% !important; /* Center vertically */
        transform: translateY(-50%) translateZ(0) !important; /* Center and force hardware acceleration */
        bottom: auto !important;
    }
    
    .chatbot-inline-form .chatbot-inline-input-container {
        padding-right: 60px !important; /* Make room for button */
    }
}

.chatbot-inline-submit:hover:not(:disabled) {
    background: #e67700 !important;
    transform: translateY(-50%) translateY(-1px) translateZ(0) !important; /* Maintain center while moving up slightly */
    box-shadow: 0 6px 16px rgba(255, 136, 0, 0.4) !important;
}

.chatbot-inline-submit:active:not(:disabled) {
    transform: translateY(-50%) scale(0.95) translateZ(0) !important; /* Maintain center while scaling down */
}

.chatbot-inline-submit:disabled {
    background: var(--neutral-300) !important;
    cursor: not-allowed;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.chatbot-inline-submit svg {
    width: 20px !important;
    height: 20px !important;
    fill: white !important;
    color: white !important;
    stroke: white !important;
    transition: transform 0.3s ease;
}

.chatbot-inline-submit:hover:not(:disabled) svg {
    transform: translate(1px, -1px);
}

/* Inline chatbot message styling */
.chatbot-inline-container .chatbot-message.assistant-message .message-avatar {
    border: 1px solid var(--neutral-100);
    background: var(--surface);
    color: var(--charcoal);
}

.chatbot-inline-container .chatbot-message.assistant-message:first-child {
    margin-bottom: 48px;
}

.chatbot-inline-container .chatbot-message.user-message .message-avatar {
    background: var(--charcoal);
    color: white;
    border: none;
}

.chatbot-inline-container .chatbot-message.assistant-message .message-content {
    background: transparent;
    border: 2px solid #ff8800;
    color: #000000;
}

.chatbot-inline-container .chatbot-message.assistant-message .message-text {
    color: #000000;
}

.chatbot-inline-container .chatbot-message.user-message .message-content {
    background: transparent;
    color: #000000;
    border: 2px solid var(--charcoal);
    border-top-right-radius: 4px;
    border-top-left-radius: 16px;
}

.chatbot-inline-container .chatbot-message.user-message .message-text {
    color: #000000;
}

.chatbot-inline-container .typing-dots span {
    background: #ff8800;
}

.chatbot-inline-container .typing-indicator {
    margin-right: 60px; /* Prevent covering submit button */
    position: relative; /* Ensure it doesn't affect layout flow */
    flex-shrink: 0; /* Prevent shrinking */
    margin-bottom: 0 !important; /* No bottom margin */
    height: auto !important; /* Prevent height changes */
    min-height: 0 !important; /* No minimum height */
}

.chatbot-inline-container .chatbot-message.typing-indicator {
    margin-bottom: 0 !important; /* No margin on typing message - THIS IS KEY */
    margin-top: 0 !important; /* No top margin */
    padding-bottom: 0 !important; /* No padding that could affect layout */
    padding-top: 0 !important; /* No top padding */
    min-height: 0 !important; /* No minimum height */
    height: auto !important; /* Auto height only */
    line-height: 1 !important; /* Minimal line height */
    flex-shrink: 0 !important; /* Don't shrink */
    flex-grow: 0 !important; /* Don't grow */
}

.chatbot-inline-container .chatbot-message.typing-indicator .message-content {
    margin: 0 !important; /* No margin on content */
    padding: 0 !important; /* No padding on content */
}

/* Override default message margin for typing indicator in inline container */
.chatbot-inline-messages .chatbot-message.typing-indicator {
    margin-bottom: 0 !important; /* Critical: Remove default 32px margin */
    margin-top: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
}

.chatbot-inline-form {
    position: relative; /* Keep form in normal flow */
}

/* Submit button is now absolutely positioned - see main .chatbot-inline-submit rule above */

.chatbot-inline-container .chatbot-suggested-questions {
    margin-bottom: 24px;
}

/* Follow-up Prompts */
.chatbot-follow-up-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 16px;
    padding: 0;
}

.chatbot-follow-up-prompt {
    padding: 6px 12px;
    background: rgba(255, 136, 0, 0.1);
    border: 1px solid rgba(255, 136, 0, 0.3);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #ff8800;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    display: inline-block;
}

.chatbot-follow-up-prompt:hover {
    background: rgba(255, 136, 0, 0.15);
    border-color: #ff8800;
    color: #e67700;
    box-shadow: 0 4px 8px rgba(255, 136, 0, 0.2);
    transform: translateY(-1px);
}

/* Escalation Buttons */
.chatbot-escalation-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--neutral-200);
    background: var(--neutral-50);
    border-radius: 0 0 10px 10px;
}

.chatbot-escalation-button {
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--charcoal);
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    display: inline-block;
    flex: 1;
    min-width: 140px;
    text-align: center;
}

.chatbot-escalation-button:hover {
    background: #ff8800;
    border-color: #ff8800;
    color: white;
    box-shadow: 0 4px 8px rgba(255, 136, 0, 0.2);
    transform: translateY(-1px);
}

/* Disclosure Text */
.chatbot-disclosure {
    padding: 12px 24px 8px;
    background: #ffffff;
    border-top: 1px solid var(--neutral-100);
}

.chatbot-disclosure-text {
    font-size: 11px;
    color: var(--neutral-600);
    line-height: 1.5;
    margin: 0;
    text-align: center;
    letter-spacing: 0.1px;
    font-weight: 400;
}

/* Role Selection Modal */
.chatbot-role-selection-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none; /* Hidden by default */
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none; /* Prevent interaction when hidden */
}

.chatbot-role-selection-modal.active {
    display: flex !important; /* Show when active */
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important; /* Allow interaction when active */
}

/* Ensure modal is hidden when not active - with high specificity */
.chatbot-role-selection-modal:not(.active) {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: none !important; /* Disable transitions when hiding */
}

/* Disable transitions when hiding to ensure immediate hide */
.chatbot-role-selection-modal.hiding {
    transition: none !important;
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.chatbot-role-selection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.chatbot-role-selection-content {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    padding: 32px 24px;
    max-width: 400px;
    width: 90%;
    z-index: 10001;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.25);
    margin-bottom: 0;
}

.chatbot-role-selection-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    background: #F80;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    z-index: 10002;
    transition: background 0.2s ease;
    box-sizing: border-box;
}

.chatbot-role-selection-close:hover {
    background: #e67700;
}

.chatbot-role-selection-close svg {
    color: white;
    stroke: white;
    fill: none;
    width: 16px;
    height: 16px;
    stroke-width: 3;
}

.chatbot-role-selection-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--charcoal);
    margin: 0 0 8px 0;
    text-align: center;
}

.chatbot-role-selection-subtitle {
    font-size: 13px;
    color: var(--neutral-500);
    text-align: center;
    margin: 0 0 24px 0;
}

.chatbot-role-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatbot-role-option {
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--charcoal);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.chatbot-role-option:hover {
    background: rgba(255, 136, 0, 0.1);
    border-color: #ff8800;
    color: #ff8800;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(255, 136, 0, 0.1);
}

.chatbot-role-option.chatbot-role-skip {
    background: transparent;
    border: 1px solid var(--neutral-300);
    color: var(--neutral-500);
    font-weight: 400;
}

.chatbot-role-option.chatbot-role-skip:hover {
    background: var(--neutral-100);
    border-color: var(--neutral-400);
    color: var(--neutral-600);
}

/* Responsive Design */
@media (max-width: 768px) {
    #custom-chatbot-window-wrapper {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    #custom-chatbot-window-wrapper::before {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }
    
    #custom-chatbot-window {
        border-radius: 0;
    }
    
    .chatbot-inline-container {
        border-radius: 10px;
    }
    
    .chatbot-inline-header {
        border-radius: 10px 10px 0 0;
    }
    
    .chatbot-inline-form {
        border-radius: 0 0 10px 10px;
    }
    
    #custom-chatbot-button {
        bottom: 20px;
        right: 20px;
    }
    
    .chatbot-inline-container {
        margin: 10px 0;
        border-radius: 16px;
    }
    
    .chatbot-inline-messages {
        padding: 16px;
    }
    
    .chatbot-suggested-questions {
        padding: 0;
        gap: 6px;
    }
    
    .chatbot-escalation-buttons {
        padding: 12px 16px;
        gap: 6px;
    }
    
    .chatbot-escalation-button {
        font-size: 12px;
        padding: 8px 12px;
        min-width: 120px;
    }
    
    .chatbot-disclosure {
        padding: 10px 16px 6px;
    }
    
    .chatbot-disclosure-text {
        font-size: 10px;
    }
    
    .chatbot-role-selection-content {
        padding: 24px 20px;
        max-width: 90%;
    }
    
    .chatbot-role-selection-content h3 {
        font-size: 16px;
    }
    
    .chatbot-role-selection-subtitle {
        font-size: 12px;
        margin-bottom: 20px;
    }
    
    .chatbot-follow-up-prompts {
        gap: 6px;
    }
    
    .chatbot-follow-up-prompt {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* Legacy support */
#chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-width: 90vw;
    height: 600px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#chatbot-container.open {
    display: flex;
}

#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    z-index: 9998;
}

#chatbot-toggle:hover {
    background: #0056b3;
    transform: scale(1.05);
}

#chatbot-toggle.hidden {
    display: none;
}

.chatbot-inline-container::before {
    opacity: .3;
}

/* Demo Form Field Styles */
.chatbot-form-field-container {
    margin: 12px 0;
    max-width: 672px;
}

.chatbot-form-field-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 136, 0, 0.05);
    border: 1px solid rgba(255, 136, 0, 0.2);
    border-radius: 12px;
    align-items: center;
}

.chatbot-form-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(255, 136, 0, 0.3);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--charcoal);
    background: #ffffff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-form-input:focus {
    border-color: #ff8800;
    box-shadow: 0 0 0 3px rgba(255, 136, 0, 0.15);
}

.chatbot-form-input.error {
    border-color: #dc3545;
    animation: shake 0.3s ease;
}

.chatbot-form-input::placeholder {
    color: var(--neutral-400);
}

.chatbot-form-submit-field {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    background: #ff8800;
    color: white;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 136, 0, 0.3);
    padding: 0;
}

.chatbot-form-submit-field:hover {
    background: #e67700;
    transform: scale(1.05);
}

.chatbot-form-submit-field:active {
    transform: scale(0.95);
}

.chatbot-form-submit-field svg {
    width: 18px;
    height: 18px;
    stroke: white;
}

.chatbot-form-skip-hint {
    font-size: 11px;
    color: var(--neutral-400);
    margin: 6px 0 0 16px;
    font-style: italic;
}

.chatbot-form-error {
    font-size: 12px;
    color: #dc3545;
    margin: 6px 0 0 16px;
    font-weight: 500;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

/* Mobile styles for demo form */
@media (max-width: 768px) {
    .chatbot-form-field-input {
        padding: 10px 12px;
    }

    .chatbot-form-input {
        padding: 8px 12px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .chatbot-form-submit-field {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
}