/**
 * AI Chatbot Styling for East Wake Hauling & Junk Removal
 * Professional, mobile-responsive design
 */

/* Chatbot Container */
#chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
.chat-toggle-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0d6efd, #0056b3);
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(13, 110, 253, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(13, 110, 253, 0.5);
}

.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: var(--bs-dark);
    border: 2px solid var(--bs-primary);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all 0.3s ease;
    pointer-events: none;
    max-height: calc(100vh - 120px);
}

.chatbot-open .chat-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.chatbot-closed .chat-window {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
}

/* Chat Header */
.chat-header {
    padding: 15px 20px;
    background: var(--bs-primary);
    color: white;
    border-radius: 13px 13px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-logo {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    margin-right: 10px;
    background: white;
    padding: 2px;
}

.chat-header h6 {
    margin: 0;
    font-weight: 600;
}

.chat-header small {
    opacity: 0.9;
}

.chat-header .btn-close {
    filter: invert(1);
    opacity: 0.8;
}

.chat-header .btn-close:hover {
    opacity: 1;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--bs-dark);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--bs-gray-800);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bs-primary);
    border-radius: 3px;
}

/* Message Styles */
.chat-message {
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
    animation: fadeInUp 0.3s ease;
}

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

.bot-message {
    justify-content: flex-start;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar {
    background: var(--bs-secondary);
    color: white;
    margin-left: 8px;
    font-size: 14px;
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.bot-message .message-content {
    margin-left: 8px;
    align-items: flex-start;
}

.user-message .message-content {
    margin-right: 8px;
    align-items: flex-end;
}

.message-text {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.bot-message .message-text {
    background: var(--bs-gray-800);
    color: var(--bs-light);
    border-bottom-left-radius: 4px;
}

.user-message .message-text {
    background: var(--bs-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.7;
    color: var(--bs-gray-400);
}

.welcome-message .message-text {
    background: linear-gradient(135deg, var(--bs-success), var(--bs-info));
    color: white;
    border: none;
    font-weight: 500;
}

/* Quick Actions */
.quick-actions {
    padding: 15px 20px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--bs-dark);
    border-top: 1px solid var(--bs-gray-700);
}

.quick-action-btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 1px solid var(--bs-primary);
    color: var(--bs-primary);
}

.quick-action-btn:hover {
    background: var(--bs-primary);
    color: white;
    transform: translateY(-1px);
}

/* Input Area */
.chat-input-area {
    padding: 15px 20px;
    background: var(--bs-dark);
    border-top: 1px solid var(--bs-gray-700);
    border-radius: 0 0 13px 13px;
}

.chat-input-area .form-control {
    background: var(--bs-gray-800);
    border: 1px solid var(--bs-gray-600);
    color: var(--bs-light);
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
}

.chat-input-area .form-control:focus {
    background: var(--bs-gray-800);
    border-color: var(--bs-primary);
    color: var(--bs-light);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.chat-input-area .btn {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 14px;
}

.chat-input-area .btn:disabled {
    opacity: 0.5;
}

/* Typing Indicator */
.typing-indicator {
    padding: 10px 20px;
    background: var(--bs-dark);
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--bs-gray-700);
    color: var(--bs-gray-400);
    font-size: 12px;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--bs-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Quote Result */
.quote-result {
    margin-top: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.quote-result .alert-success {
    border-left: 4px solid var(--bs-success);
    background: rgba(25, 135, 84, 0.1);
    border-color: var(--bs-success);
}

.quote-result h4 {
    font-weight: 700;
    margin: 10px 0;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #chatbot-container {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-window {
        width: calc(100vw - 30px);
        max-width: 350px;
        right: -15px;
    }
    
    .chat-toggle-btn {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    .quick-actions {
        padding: 10px 15px 0;
    }
    
    .quick-action-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    .chat-window {
        height: 450px;
        width: calc(100vw - 20px);
        right: -10px;
        bottom: 70px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .chat-header {
        padding: 12px 15px;
    }
    
    .chat-messages {
        padding: 15px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chat-toggle-btn {
        border: 2px solid white;
    }
    
    .chat-window {
        border: 3px solid var(--bs-primary);
    }
    
    .message-text {
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .chat-toggle-btn,
    .chat-window,
    .chat-message,
    .quick-action-btn {
        transition: none;
    }
    
    .chat-notification {
        animation: none;
    }
    
    .typing-dots span {
        animation: none;
    }
}

/* Improved mobile chatbot experience */
@media (max-width: 768px) {
    .chat-window {
        height: calc(100vh - 120px) !important;
        max-height: 500px !important;
    }
}

@media (max-width: 480px) {
    .chat-window {
        height: calc(100vh - 100px) !important;
        max-height: 450px !important;
        bottom: 70px !important;
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .chat-window {
        background: #1a1a1a;
        border-color: var(--bs-primary);
    }
    
    .bot-message .message-text {
        background: #2d2d2d;
        color: #e0e0e0;
    }
}