/* Brysons Chatbot Styles */
/* Main chatbot widget container */
#brysons-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chat toggle button */
#brysons-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#brysons-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

#brysons-chat-toggle .chat-icon,
#brysons-chat-toggle .close-icon {
    font-size: 24px;
    color: white;
    transition: all 0.3s ease;
    position: absolute;
}

#brysons-chat-toggle .close-icon {
    opacity: 0;
    transform: rotate(180deg);
}

#brysons-chat-toggle.active .chat-icon {
    opacity: 0;
    transform: rotate(-180deg);
}

#brysons-chat-toggle.active .close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Chat container */
#brysons-chat-container {
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    position: absolute;
    bottom: 80px;
    right: 0;
    transition: all 0.3s ease;
    transform-origin: bottom right;
    overflow: hidden;
}

#brysons-chat-container.chat-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(20px);
}

/* Chat header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
}

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

.ai-avatar {
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.header-text {
    flex: 1;
    min-width: 0; /* Prevents text overflow */
}

.header-text h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-text p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.3;
}

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

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* Message bubbles */
.bot-message,
.user-message {
    display: flex;
    margin-bottom: 12px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    justify-content: flex-end;
}

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

.bot-message .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    max-width: 60px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Input container */
.chat-input-container {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 15px;
}

/* Contact links in messages */
.contact-link {
    display: inline-block;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white !important;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    margin: 0 4px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.contact-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    text-decoration: none;
}

/* Input area */
.input-area {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 25px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

#chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#send-button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

#send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #brysons-chatbot-widget {
        bottom: 20px;
        right: 20px;
        /* Removed left positioning to keep it on the right */
    }
    
    #brysons-chat-container {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100dvh; /* Use dynamic viewport height for better keyboard handling */
        z-index: 999999; /* Higher z-index to go above topbars */
        border-radius: 0; /* Remove border radius for full screen */
        display: flex;
        flex-direction: column;
    }
    
    /* Mobile header adjustments */
    .chat-header {
        padding: 15px 20px;
        position: relative;
        flex-shrink: 0; /* Prevent header from shrinking */
    }
    
    .header-content {
        gap: 8px;
    }
    
    .ai-avatar {
        width: 32px;
        height: 32px;
    }
    
    .header-text h3 {
        font-size: 16px;
    }
    
    .header-text p {
        font-size: 13px;
    }
    
    /* Mobile messages area */
    .chat-messages {
        flex: 1;
        min-height: 0; /* Allow messages to shrink when keyboard appears */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    /* Mobile input container */
    .chat-input-container {
        flex-shrink: 0; /* Keep input always visible */
        padding: 10px 20px 20px 20px;
        background: white;
        border-top: 1px solid #e9ecef;
        /* Ensure input stays above keyboard */
        position: relative;
        z-index: 1;
    }
    
    /* Mobile input field */
    #chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 16px;
    }
    
    /* Mobile close button in header */
    .chat-header::after {
        content: '✕';
        position: absolute;
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
        color: white;
        font-size: 18px;
        cursor: pointer;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        transition: all 0.2s ease;
    }
    
    .chat-header::after:hover {
        background: rgba(255, 255, 255, 0.3);
    }
}

@media (max-width: 360px) {
    .header-text h3 {
        font-size: 14px;
    }
    
    .header-text p {
        font-size: 12px;
    }
    
    .ai-avatar {
        width: 28px;
        height: 28px;
    }
}

/* Error and success states */
.message-error {
    background: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f5c6cb;
}

.message-success {
    background: #d4edda !important;
    color: #155724 !important;
    border: 1px solid #c3e6cb;
}

/* Loading state for send button */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}