/* Black Diamond AI Chat Assistant Styles - Enhanced for Lead Qualification */

#bd-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: 'Poppins', sans-serif;
}

/* Chat Toggle Button */
.chat-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(212, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.chat-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 40px rgba(212, 0, 0, 0.4);
    border-color: rgba(212, 0, 0, 0.6);
}

.chat-toggle.active {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border-color: rgba(255, 255, 255, 0.3);
}

.chat-icon {
    color: white;
    transition: transform 0.3s ease;
}

.chat-toggle:hover .chat-icon {
    transform: scale(1.1);
}

/* Pulse Animation */
.chat-pulse {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid rgba(212, 0, 0, 0.6);
    animation: pulse 2s infinite;
    pointer-events: none;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Notification Badge */
.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #dc2626, #f87171);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    animation: bounce 2s infinite;
    border: 2px solid white;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.9);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.open {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #000000 0%, #dc2626 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-radius: 20px 20px 0 0;
}

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

.avatar-bg {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.chat-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-title span {
    font-size: 12px;
    opacity: 0.8;
}

.chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.user-message {
    align-items: flex-end;
}

.ai-message {
    align-items: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message .message-content {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border-bottom-right-radius: 6px;
}

.ai-message .message-content {
    background: white !important;
    color: #000000 !important;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Additional specificity for AI chat text */
#bd-chat-widget .ai-message .message-content {
    color: #000000 !important;
    background: white !important;
}

#bd-chat-widget .chat-message.ai-message .message-content {
    color: #000000 !important;
    background: white !important;
}

/* Override global text color inheritance for AI messages only */
#bd-chat-widget .ai-message,
#bd-chat-widget .ai-message *,
#bd-chat-widget .chat-message.ai-message,
#bd-chat-widget .chat-message.ai-message * {
    color: #000000 !important;
}

/* Specific override for AI message content only */
#bd-chat-widget .ai-message .message-content {
    color: #000000 !important;
}

/* Override for AI message content with maximum specificity */
body #bd-chat-widget .chat-messages .chat-message.ai-message .message-content {
    color: #000000 !important;
    background: white !important;
}

/* Ultimate text color override - place at end of file for maximum priority */
html body #bd-chat-widget .ai-message .message-content,
html body #bd-chat-widget .chat-message.ai-message .message-content,
html body #bd-chat-widget .chat-messages .ai-message .message-content,
html body #bd-chat-widget .chat-messages .chat-message.ai-message .message-content {
    color: #000000 !important;
    background: #ffffff !important;
    text-shadow: none !important;
    -webkit-text-fill-color: #000000 !important;
}

.message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    margin-left: 16px;
    margin-right: 16px;
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
    margin-bottom: 20px;
}

.quick-reply-btn {
    background: white;
    border: 2px solid #dc2626;
    color: #dc2626;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
}

.quick-reply-btn:hover {
    background: #dc2626;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* Chat Input Container */
.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    color: #000000 !important;
    background: #ffffff !important;
    -webkit-text-fill-color: #000000 !important;
    -webkit-appearance: none;
    appearance: none;
    text-shadow: none !important;
}

.chat-input:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    outline: none;
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
}

.chat-input:focus-visible {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
}

/* Additional input text color enforcement */
.chat-input::placeholder {
    color: #9ca3af !important;
    opacity: 0.7;
}

.chat-input::-webkit-input-placeholder {
    color: #9ca3af !important;
    opacity: 0.7;
}

.chat-input::-moz-placeholder {
    color: #9ca3af !important;
    opacity: 0.7;
}

.chat-input:-ms-input-placeholder {
    color: #9ca3af !important;
    opacity: 0.7;
}

.chat-send-btn {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.chat-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.4);
}

.chat-send-btn:active {
    transform: translateY(0);
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
    #bd-chat-widget {
        bottom: 20px;
        right: 20px;
        z-index: 99999 !important;
        position: fixed !important;
    }
    
    .chat-toggle {
        width: 60px;
        height: 60px;
        z-index: 99999 !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
    
    .chat-window {
        position: absolute !important;
        bottom: 80px !important;
        right: 20px !important;
        left: auto !important;
        top: auto !important;
        width: calc(100vw - 60px) !important;
        height: 70vh !important;
        max-width: 380px !important;
        max-height: 500px !important;
        z-index: 99998 !important;
        border-radius: 20px;
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    }
    
    .chat-header {
        padding: 18px 20px;
        background: linear-gradient(135deg, #000000 0%, #dc2626 100%);
        border-radius: 20px 20px 0 0;
    }
    
    .chat-messages {
        padding: 20px;
        flex: 1;
        overflow-y: auto;
        background: #f8f9fa;
    }
    
    .chat-input-container {
        padding: 20px;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        border-radius: 0 0 20px 20px;
    }
    
    .chat-input {
        color: #000000 !important;
        background: #ffffff !important;
        -webkit-text-fill-color: #000000 !important;
        font-size: 16px;
        border: 2px solid #e5e7eb;
        border-radius: 25px;
        padding: 15px 20px;
        -webkit-appearance: none;
        appearance: none;
        -webkit-user-select: text;
        user-select: text;
        touch-action: manipulation;
        width: 100%;
        box-sizing: border-box;
    }
    
    .chat-input:focus {
        color: #000000 !important;
        -webkit-text-fill-color: #000000 !important;
        background: #ffffff !important;
        border-color: #dc2626;
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
        transform: none;
        outline: none;
    }
    
    .chat-input-wrapper {
        display: flex;
        gap: 12px;
        align-items: center;
        width: 100%;
    }
    
    .quick-replies {
        gap: 8px;
        margin: 12px 0;
    }
    
    .quick-reply-btn {
        padding: 10px 16px;
        font-size: 14px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 22px;
        white-space: nowrap;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 15px;
        line-height: 1.5;
        padding: 14px 18px;
        border-radius: 20px;
    }
    
    /* Force black text on mobile */
    #bd-chat-widget .ai-message .message-content,
    #bd-chat-widget .chat-message.ai-message .message-content {
        color: #000000 !important;
        background: #ffffff !important;
        text-shadow: none !important;
        border: 1px solid #e5e7eb;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* Mobile input text color enforcement */
    #bd-chat-widget .chat-input {
        color: #000000 !important;
        background: #ffffff !important;
        -webkit-text-fill-color: #000000 !important;
    }
    
    /* Button accessibility improvements */
    .chat-send-btn {
        min-height: 48px;
        min-width: 48px;
        width: 48px;
        height: 48px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        flex-shrink: 0;
    }
    
    .chat-close {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .chat-avatar {
        width: 36px;
        height: 36px;
    }
    
    .chat-title h4 {
        font-size: 16px;
        margin: 0;
    }
    
    .chat-title span {
        font-size: 13px;
        opacity: 0.9;
    }
}

@media (max-width: 480px) {
    .chat-window {
        bottom: 80px !important;
        right: 15px !important;
        left: auto !important;
        top: auto !important;
        width: calc(100vw - 50px) !important;
        height: 65vh !important;
        max-width: 350px !important;
        max-height: 450px !important;
        border-radius: 18px;
    }
    
    .chat-toggle {
        width: 56px;
        height: 56px;
        bottom: 15px;
        right: 15px;
    }
    
    .chat-header {
        padding: 16px 18px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .chat-input-container {
        padding: 16px;
    }
    
    .chat-input {
        font-size: 16px;
        padding: 14px 18px;
    }
    
    .message-content {
        max-width: 88%;
        font-size: 14px;
        padding: 12px 16px;
        line-height: 1.4;
    }
    
    .quick-reply-btn {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 40px;
    }
    
    .chat-send-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 360px) {
    .chat-window {
        bottom: 75px !important;
        right: 10px !important;
        left: auto !important;
        top: auto !important;
        width: calc(100vw - 40px) !important;
        height: 60vh !important;
        max-width: 320px !important;
        max-height: 400px !important;
        border-radius: 16px;
    }
    
    .chat-toggle {
        width: 52px;
        height: 52px;
        bottom: 12px;
        right: 12px;
    }
    
    .chat-header {
        padding: 14px 16px;
    }
    
    .chat-messages {
        padding: 14px;
    }
    
    .chat-input-container {
        padding: 14px;
    }
    
    .chat-input {
        font-size: 16px;
        padding: 12px 16px;
    }
    
    .message-content {
        max-width: 90%;
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .quick-reply-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-height: 36px;
    }
    
    .chat-send-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .chat-avatar {
        width: 32px;
        height: 32px;
    }
    
    .chat-title h4 {
        font-size: 15px;
    }
    
    .chat-title span {
        font-size: 12px;
    }
}

/* Landscape Mode */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 768px) {
    .chat-window {
        bottom: 60px !important;
        right: 20px !important;
        left: auto !important;
        top: auto !important;
        width: calc(100vw - 80px) !important;
        height: 80vh !important;
        max-width: 450px !important;
        max-height: 350px !important;
    }
    
    .chat-toggle {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .chat-messages {
        padding: 12px 16px;
    }
    
    .chat-input-container {
        padding: 12px 16px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chat-window {
        border-width: 0.5px;
    }
    
    .chat-input {
        border-width: 1px;
    }
}

/* Desktop Chat Bot - Ensure it's visible on larger screens */
@media (min-width: 769px) {
    #bd-chat-widget {
        position: fixed !important;
        bottom: 20px !important;
        right: 20px !important;
        z-index: 10000 !important;
    }

    .chat-toggle {
        position: relative !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 60px !important;
        height: 60px !important;
    }

    .chat-window {
        position: absolute !important;
        bottom: 80px !important;
        right: 0 !important;
        left: auto !important;
        top: auto !important;
        width: 380px !important;
        height: 600px !important;
        max-width: 380px !important;
        max-height: 600px !important;
        transform: none !important;
        transition: opacity 0.3s ease, visibility 0.3s ease !important;
    }

    .chat-window:not(.open) {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: none !important;
    }

    .chat-window.open {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: all !important;
        transform: none !important;
    }
}

/* Focus and Accessibility */
.chat-input:focus,
.chat-send-btn:focus,
.quick-reply-btn:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* Smooth scrolling for messages */
.chat-messages {
    scroll-behavior: smooth;
}

/* Custom scrollbar for chat messages */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(220, 38, 38, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(220, 38, 38, 0.5);
}

/* FINAL OVERRIDE - Must be last rule in file for maximum CSS specificity */
html body div#bd-chat-widget div.chat-messages div.chat-message.ai-message div.message-content,
html body div#bd-chat-widget div.chat-window div.chat-messages div.chat-message.ai-message div.message-content {
    color: #000000 !important;
    background: #ffffff !important;
    text-shadow: none !important;
    -webkit-text-fill-color: #000000 !important;
    font-weight: normal !important;
}

/* ULTIMATE INPUT TEXT COLOR OVERRIDE - Highest specificity for input text */
html body div#bd-chat-widget div.chat-input-container div.chat-input-wrapper input#chat-input.chat-input,
html body div#bd-chat-widget div.chat-window div.chat-input-container div.chat-input-wrapper input#chat-input.chat-input,
html body div#bd-chat-widget input.chat-input,
html body div#bd-chat-widget input#chat-input {
    color: #000000 !important;
    background: #ffffff !important;
    -webkit-text-fill-color: #000000 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    text-shadow: none !important;
    caret-color: #000000 !important;
}

/* Force input text color on all states */
html body div#bd-chat-widget input.chat-input:focus,
html body div#bd-chat-widget input#chat-input:focus,
html body div#bd-chat-widget input.chat-input:active,
html body div#bd-chat-widget input#chat-input:active,
html body div#bd-chat-widget input.chat-input:hover,
html body div#bd-chat-widget input#chat-input:hover {
    color: #000000 !important;
    background: #ffffff !important;
    -webkit-text-fill-color: #000000 !important;
    caret-color: #000000 !important;
}