/* =====================================================
   AI Property Chat Widget
   ===================================================== */

/* CSS Variables for theming - inherit from theme or use defaults */
:root {
    --llp-chat-primary: var(--lm365-primary, var(--lm-primary, var(--primary, #2271b1)));
    --llp-chat-primary-dark: var(--lm365-primary-dark, var(--lm-primary-dark, var(--primary-dark, #135e96)));
}

/* Floating Button - Circular style with large icon */
.llp-chat-widget-btn {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, var(--llp-chat-primary) 0%, var(--llp-chat-primary-dark) 100%) !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    z-index: 99998 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 32px !important;
    transition: all 0.3s ease !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Chat icon - larger to fill the button */
.llp-chat-widget-btn .chat-icon {
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.llp-chat-widget-btn .chat-icon svg {
    width: 32px !important;
    height: 32px !important;
    fill: #fff !important;
}

/* Left position variant */
.llp-chat-widget-btn.position-left {
    right: auto !important;
    left: 25px !important;
}

.llp-chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4) !important;
}

.llp-chat-widget-btn.pulse {
    animation: llp-pulse 2s infinite;
}

@keyframes llp-pulse {
    0% { box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 4px 25px rgba(0, 0, 0, 0.5); }
    100% { box-shadow: 0 4px 15px rgba(34, 113, 177, 0.4); }
}

.llp-chat-widget-btn .close-icon {
    display: none !important;
}

.llp-chat-widget-btn.active .chat-icon {
    display: none !important;
}

.llp-chat-widget-btn.active .close-icon {
    display: block !important;
}

/* Chat Container */
.llp-chat-container {
    position: fixed !important;
    bottom: 100px !important;
    right: 25px !important;
    width: 380px !important;
    max-width: calc(100vw - 40px) !important;
    height: 550px !important;
    max-height: calc(100vh - 140px) !important;
    background: #fff !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
    z-index: 99999 !important;
    display: none !important;
    flex-direction: column !important;
    overflow: hidden !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Left position variant */
.llp-chat-container.position-left {
    right: auto !important;
    left: 25px !important;
}

.llp-chat-container.active {
    display: flex !important;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .llp-chat-container {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .llp-chat-container.position-left {
        left: 0;
        right: 0;
    }
    
    .llp-chat-widget-btn {
        bottom: 15px;
        right: 15px;
    }
    
    .llp-chat-widget-btn.position-left {
        right: auto;
        left: 15px;
    }
    
    .llp-chat-container.active + .llp-chat-widget-btn {
        display: none;
    }
}

/* Chat Header */
.llp-chat-header {
    background: linear-gradient(135deg, var(--llp-chat-primary) 0%, var(--llp-chat-primary-dark) 100%);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.llp-chat-header-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.llp-chat-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff; /* White color for Property Assistant */
}

.llp-chat-header-info p {
    margin: 3px 0 0 0;
    font-size: 12px;
    opacity: 0.85;
}

.llp-chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 24px;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.llp-chat-close:hover {
    opacity: 1;
}

/* Lead Capture Form */
.llp-chat-lead-form {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.llp-chat-lead-form h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #333;
}

.llp-chat-lead-form > p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.llp-chat-form-group {
    margin-bottom: 15px;
}

.llp-chat-form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
    color: #444;
}

.llp-chat-form-group label .required {
    color: #dc3545;
}

.llp-chat-form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.llp-chat-form-group input:focus {
    outline: none;
    border-color: var(--llp-chat-primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.llp-chat-form-group input::placeholder {
    color: #aaa;
}

.llp-chat-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--llp-chat-primary) 0%, var(--llp-chat-primary-dark) 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.llp-chat-submit-btn:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
}

.llp-chat-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.llp-chat-form-note {
    margin-top: 15px;
    font-size: 11px;
    color: #888;
    text-align: center;
    line-height: 1.4;
}

/* Chat Messages */
.llp-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.llp-chat-messages.active {
    display: flex;
}

.llp-chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: llp-message-in 0.3s ease;
}

@keyframes llp-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.llp-chat-message.assistant {
    background: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.llp-chat-message.user {
    background: linear-gradient(135deg, var(--llp-chat-primary) 0%, var(--llp-chat-primary-dark) 100%);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.llp-chat-message.typing {
    background: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.llp-typing-indicator {
    display: flex;
    gap: 5px;
    padding: 5px 0;
}

.llp-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #bbb;
    border-radius: 50%;
    animation: llp-typing 1.4s infinite both;
}

.llp-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.llp-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes llp-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        background: #bbb;
    }
    30% {
        transform: translateY(-8px);
        background: var(--llp-chat-primary);
    }
}

/* Chat Input */
.llp-chat-input-wrapper {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #eee;
    display: none;
}

.llp-chat-input-wrapper.active {
    display: block;
}

.llp-chat-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.llp-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    line-height: 1.4;
    font-family: inherit;
}

.llp-chat-input:focus {
    outline: none;
    border-color: var(--llp-chat-primary);
}

.llp-chat-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--llp-chat-primary) 0%, var(--llp-chat-primary-dark) 100%);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.llp-chat-send-btn:hover {
    transform: scale(1.05);
}

.llp-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Error State */
.llp-chat-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    margin: 10px 20px;
    display: none;
}

.llp-chat-error.show {
    display: block;
}

/* Scrollbar Styling */
.llp-chat-messages::-webkit-scrollbar,
.llp-chat-lead-form::-webkit-scrollbar {
    width: 6px;
}

.llp-chat-messages::-webkit-scrollbar-track,
.llp-chat-lead-form::-webkit-scrollbar-track {
    background: transparent;
}

.llp-chat-messages::-webkit-scrollbar-thumb,
.llp-chat-lead-form::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.llp-chat-messages::-webkit-scrollbar-thumb:hover,
.llp-chat-lead-form::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Property Badge in Chat */
.llp-chat-property-badge {
    background: #e8f4fd;
    border: 1px solid #bee5eb;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 12px;
}

.llp-chat-property-badge strong {
    display: block;
    color: #0c5460;
    font-size: 13px;
    margin-bottom: 2px;
}

.llp-chat-property-badge span {
    color: #666;
}

/* Lead Capture Prompt (delayed) */
.llp-chat-lead-prompt {
    position: absolute;
    bottom: 70px;
    left: 10px;
    right: 10px;
    z-index: 10;
}

.llp-lead-prompt-content {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 1px solid #e0e0e0;
    position: relative;
}

.llp-lead-prompt-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 24px;
}

.llp-lead-prompt-close:hover {
    color: #333;
}

.llp-lead-prompt-content p {
    margin: 0 0 8px;
    font-size: 14px;
}

.llp-lead-prompt-content form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.llp-lead-prompt-content form input:focus {
    outline: none;
    border-color: var(--llp-chat-primary, #2271b1);
}

.llp-lead-prompt-content .llp-chat-submit-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: var(--llp-chat-primary, #2271b1);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.llp-lead-prompt-content .llp-chat-submit-btn:hover {
    background: var(--llp-chat-primary-dark, #135e96);
}

.llp-lead-skip {
    width: 100%;
    padding: 8px;
    border: none;
    background: none;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
}

.llp-lead-skip:hover {
    color: #333;
    text-decoration: underline;
}
