/* 
 * Chatbot Widget CSS
 * Modern purple gradient design with mobile responsiveness
 */

/* Chat Button - Floating action button */
#chatbot-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    z-index: 9998;
    outline: none;
}

#chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#chatbot-button:active {
    transform: scale(0.95);
}

#chatbot-button.hidden {
    display: none;
}

/* Badge for unread messages (optional future feature) */
#chatbot-button .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Chat Window Container */
#chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

#chatbot-window.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
#chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

#chatbot-header-icon {
    font-size: 24px;
}

#chatbot-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

#chatbot-header-text p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

#chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s;
}

#chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages Area */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* Message Bubbles */
.chatbot-message {
    display: flex;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

/* User Messages */
.chatbot-message.user {
    justify-content: flex-end;
}

.chatbot-message.user .chatbot-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Bot Messages */
.chatbot-message.bot {
    justify-content: flex-start;
}

.chatbot-message.bot .chatbot-message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

/* Similarity Score */
.chatbot-similarity {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 75px;
}

.chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typing 1.4s infinite;
}

.chatbot-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Error Messages */
.chatbot-message.error .chatbot-message-content {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

/* Chat Input Area */
#chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    color: #333;
    background: white;
}

#chatbot-input:focus {
    border-color: #667eea;
}

#chatbot-input::placeholder {
    color: #999;
}

#chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

#chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#chatbot-send:active {
    transform: scale(0.95);
}

#chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Welcome Popup Notification */
#chatbot-popup {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    max-width: 280px;
    z-index: 9997;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chatbot-popup:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5);
}

#chatbot-popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    transition: background 0.2s;
    flex-shrink: 0;
}

#chatbot-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Popup Animations */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDownFade {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* Tablet Responsiveness (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    #chatbot-window {
        width: 360px;
        height: 550px;
        max-height: calc(100vh - 100px);
    }

    #chatbot-popup {
        max-width: 260px;
        right: 16px;
        bottom: 80px;
    }
}

/* Mobile Responsiveness (up to 768px) */
@media (max-width: 768px) {
    #chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        animation: slideUpMobile 0.3s ease-out;
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    #chatbot-button {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
        font-size: 22px;
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
    }

    #chatbot-popup {
        bottom: 80px;
        right: 16px;
        left: 16px;
        max-width: calc(100% - 32px);
        padding: 14px 16px;
    }

    #chatbot-popup div[style*="font-size: 24px"] {
        font-size: 20px !important;
    }

    .chatbot-message-content {
        max-width: 85%;
        font-size: 14px;
    }

    #chatbot-messages {
        padding: 16px 12px;
    }

    #chatbot-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Adjust for mobile keyboard */
    #chatbot-input-area {
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
}

/* Small Mobile Devices (up to 480px) */
@media (max-width: 480px) {
    #chatbot-header {
        padding: 14px 16px;
    }

    #chatbot-header-icon {
        font-size: 20px;
    }

    #chatbot-header-text h3 {
        font-size: 15px;
    }

    #chatbot-header-text p {
        font-size: 11px;
    }

    #chatbot-input-area {
        padding: 10px 12px;
        gap: 8px;
    }

    #chatbot-input {
        padding: 10px 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    #chatbot-send {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .chatbot-message-content {
        padding: 10px 12px;
        font-size: 14px;
        max-width: 90%;
    }

    #chatbot-button {
        width: 52px;
        height: 52px;
        font-size: 20px;
        bottom: 12px;
        right: 12px;
    }

    #chatbot-popup {
        bottom: 70px;
        right: 12px;
        left: 12px;
        padding: 12px 14px;
    }

    .chatbot-similarity {
        font-size: 10px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #chatbot-window {
        height: 100vh;
    }

    #chatbot-header {
        padding: 12px 16px;
    }

    #chatbot-messages {
        padding: 12px;
    }

    #chatbot-input-area {
        padding: 8px 12px;
    }

    #chatbot-popup {
        display: none; /* Hide popup in landscape to save space */
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #chatbot-button {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.45);
    }

    #chatbot-window {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    }
}

/* Dark mode support (if system prefers dark) */
@media (prefers-color-scheme: dark) {
    /* Already designed for dark backgrounds, no changes needed */
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #chatbot-window,
    #chatbot-popup,
    .chatbot-message {
        animation: none !important;
        transition: none !important;
    }

    #chatbot-button:hover {
        transform: none;
    }

    .chatbot-typing-dot {
        animation: none !important;
    }
}

/* Accessibility */
#chatbot-button:focus,
#chatbot-send:focus,
#chatbot-close:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print styles - hide chatbot */
@media print {
    #chatbot-button,
    #chatbot-window {
        display: none !important;
    }
}
