/* Chatbot Container */
#lexmarke-bot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

/* Toggle Button */
#lexmarke-bot-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #bb8c33;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 8px 25px rgba(187, 140, 51, 0.4);
    transition: all 0.3s ease;
}

#lexmarke-bot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(187, 140, 51, 0.5);
}

/* Chat Window - FIXED DIMENSIONS */
#lexmarke-bot-window {
    position: absolute;
    bottom: 55px;
    right: 0;
    width: 370px;
    height: 480px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none;
    border: 1px solid #e8edf2;
    /* Use table layout for reliable sizing */
    display: none;
    flex-direction: column;
}

/* Header - Fixed height */
#lexmarke-bot-header {
    background: linear-gradient(135deg, #1a2a3f 0%, #0f1a24 100%);
    padding: 14px 18px;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
    font-family: 'Trajan Pro', 'Trajan', 'Georgia', serif;
    height: 50px;
    flex-shrink: 0;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

#lexmarke-bot-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 22px;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

#lexmarke-bot-close:hover {
    color: #ffffff;
}

/* Messages Area - FIXED HEIGHT WITH SCROLL */
#lexmarke-bot-messages {
    height: 360px;
    overflow-y: scroll !important;
    overflow-x: hidden;
    padding: 16px 18px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* Force scrollbar to always show to prevent layout shift */
    scrollbar-width: thin;
}

/* Message Bubbles */
.bot-message {
    background: #ffffff;
    color: #1a2a3f;
    padding: 12px 16px;
    border-radius: 10px 10px 10px 4px;
    margin-bottom: 10px;
    max-width: 90%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e8edf2;
    font-size: 14px;
    line-height: 1.6;
    align-self: flex-start;
    word-wrap: break-word;
    white-space: normal;
    flex-shrink: 0;
}

.user-message {
    background: #bb8c33;
    color: #ffffff;
    padding: 12px 16px;
    border-radius: 10px 10px 4px 10px;
    margin-bottom: 10px;
    max-width: 90%;
    font-size: 14px;
    line-height: 1.6;
    align-self: flex-end;
    word-wrap: break-word;
    white-space: normal;
    flex-shrink: 0;
}

/* Welcome Message */
.bot-message.welcome {
    background: #ffffff;
    border-left: 4px solid #bb8c33;
    font-weight: 500;
    color: #1a2a3f;
}

/* Typing Indicator */
.typing-indicator {
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 10px 10px 10px 4px;
    border: 1px solid #e8edf2;
    max-width: 56px;
    margin-bottom: 10px;
    align-self: flex-start;
    flex-shrink: 0;
}

.typing-indicator span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #bb8c33;
    margin: 0 2px;
    animation: typing 1.4s infinite both;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area - Fixed height at bottom */
#lexmarke-bot-input-area {
    padding: 12px 18px;
    border-top: 1px solid #e8edf2;
    display: flex;
    gap: 8px;
    background: #ffffff;
    height: 60px;
    flex-shrink: 0;
    align-items: center;
}

#lexmarke-bot-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    transition: border-color 0.3s ease;
    min-width: 0;
}

#lexmarke-bot-input:focus {
    border-color: #bb8c33;
}

#lexmarke-bot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #bb8c33;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lexmarke-bot-send:hover {
    background: #a67a2a;
    transform: scale(1.05);
}

/* Scrollbar Styling */
#lexmarke-bot-messages::-webkit-scrollbar {
    width: 6px;
}

#lexmarke-bot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#lexmarke-bot-messages::-webkit-scrollbar-thumb {
    background: #bb8c33;
    border-radius: 10px;
}

#lexmarke-bot-messages::-webkit-scrollbar-thumb:hover {
    background: #a67a2a;
}

/* Firefox scrollbar */
#lexmarke-bot-messages {
    scrollbar-width: thin;
    scrollbar-color: #bb8c33 #f1f1f1;
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    #lexmarke-bot-window {
        width: 300px;
        height: 420px;
        border-radius: 14px;
    }
    
    #lexmarke-bot-messages {
        height: 310px;
        padding: 12px 14px;
    }
    
    #lexmarke-bot-toggle {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
    
    #lexmarke-bot-header {
        padding: 12px 16px;
        font-size: 14px;
        height: 44px;
    }
    
    .bot-message,
    .user-message {
        font-size: 13px;
        padding: 10px 14px;
        max-width: 92%;
    }
    
    #lexmarke-bot-input-area {
        padding: 10px 14px;
        height: 52px;
    }
    
    #lexmarke-bot-input {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    #lexmarke-bot-send {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }
}

/* User Info Form */
#lexmarke-bot-user-form {
    flex: 1;
    padding: 24px 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
}

#lexmarke-bot-user-form .bot-message {
    margin-bottom: 20px;
    max-width: 100%;
}

#lexmarke-bot-user-form-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#lexmarke-bot-user-form-fields .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#lexmarke-bot-user-form-fields label {
    font-size: 13px;
    font-weight: 600;
    color: #1a2a3f;
}

#lexmarke-bot-user-form-fields label .required {
    color: #e74c3c;
}

#lexmarke-bot-user-form-fields input {
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    transition: border-color 0.3s ease;
    outline: none;
}

#lexmarke-bot-user-form-fields input:focus {
    border-color: #bb8c33;
    box-shadow: 0 0 0 3px rgba(187, 140, 51, 0.1);
}

#lexmarke-bot-user-form-fields input.error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

#lexmarke-bot-start-chat {
    padding: 12px 24px;
    background: #bb8c33;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

#lexmarke-bot-start-chat:hover {
    background: #a67a2a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(187, 140, 51, 0.3);
}

#lexmarke-bot-start-chat:active {
    transform: translateY(0);
}

#lexmarke-bot-start-chat:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Error message styling */
.field-error {
    font-size: 12px;
    color: #e74c3c;
    display: none;
}

.field-error.visible {
    display: block;
}

/* Badge on toggle button */
#lexmarke-bot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#lexmarke-bot-toggle {
    position: relative;
}

/* Show/hide transitions */
#lexmarke-bot-user-form,
#lexmarke-bot-messages,
#lexmarke-bot-input-area {
    transition: all 0.3s ease;
}

/* Responsive */
@media (max-width: 480px) {
    #lexmarke-bot-user-form {
        padding: 20px 16px;
    }
    
    #lexmarke-bot-user-form-fields input {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    #lexmarke-bot-start-chat {
        font-size: 14px;
        padding: 10px 20px;
    }
}

/* Chat Footer */
#lexmarke-bot-footer {
    padding: 10px 18px;
    background: #f8f9fa;
    border-top: 1px solid #e8edf2;
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lexmarke-bot-footer a {
    color: #bb8c33;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

#lexmarke-bot-footer a:hover {
    color: #a67a2a;
    text-decoration: underline;
}

/* Adjust chat window height to accommodate footer */
#lexmarke-bot-window {
    position: absolute;
    bottom: 55px;
    right: 0;
    width: 370px;
    height: 500px;
    /* Increased height to accommodate footer */
    max-height: 500px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: none;
    flex-direction: column;
    border: 1px solid #e8edf2;
}

/* Adjust messages height to accommodate footer */
#lexmarke-bot-messages {
    height: 335px;
    /* Reduced to fit footer */
    overflow-y: scroll !important;
    overflow-x: hidden;
    padding: 16px 18px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    scrollbar-width: thin;
}

/* User form should also adjust */
#lexmarke-bot-user-form {
    flex: 1;
    padding: 24px 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    min-height: 300px;
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    #lexmarke-bot-window {
        width: 300px;
        height: 440px;
        /* Adjusted for mobile */
        max-height: 440px;
        border-radius: 14px;
    }
    
    #lexmarke-bot-messages {
        height: 285px;
        /* Adjusted for mobile */
        padding: 12px 14px;
    }
    
    #lexmarke-bot-footer {
        font-size: 10px;
        padding: 8px 14px;
        min-height: 32px;
    }
    
    #lexmarke-bot-user-form {
        padding: 20px 16px;
        min-height: 250px;
    }
}