/* Chatbot Widget Styles */
#chatbot-widget {
    position: fixed;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* CSS Custom Properties for dynamic values */
    --primary-color: #dc3545;
    --secondary-color: #007bff;
}

/* Chat Button */
#chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    position: fixed;
    z-index: 10001;
}

/* Position the chat button based on widget position */
#chatbot-widget.bottom-right #chatbot-button {
    bottom: 20px;
    right: 20px;
}

#chatbot-widget.bottom-left #chatbot-button {
    bottom: 20px;
    left: 20px;
}

#chatbot-widget.top-right #chatbot-button {
    top: 20px;
    right: 20px;
}

#chatbot-widget.top-left #chatbot-button {
    top: 20px;
    left: 20px;
}

#chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

#chatbot-button svg {
    width: 24px;
    height: 24px;
}

/* Chat Window */
#chatbot-window {
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
}

/* Position the chat window based on widget position */
#chatbot-widget.bottom-right #chatbot-window {
    bottom: 90px;
    right: 20px;
    width: 350px;
    max-height: none;
}

#chatbot-widget.bottom-left #chatbot-window {
    bottom: 90px;
    left: 20px;
    width: 350px;
    max-height: none;
}

#chatbot-widget.top-right #chatbot-window {
    top: 90px;
    right: 20px;
    width: 350px;
    max-height: none;
}

#chatbot-widget.top-left #chatbot-window {
    top: 90px;
    left: 20px;
    width: 350px;
    max-height: none;
}

/* Chat Header */
#chatbot-window > div:first-child {
    background: var(--primary-color);
    color: white;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 16px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-header-buttons button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-header-buttons button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.sound-toggle-btn {
    font-size: 14px !important;
}

.close-chat-btn {
    font-size: 18px !important;
}

/* Messages Container */
#chatbot-window > div:nth-child(2) {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 350px;
    min-height: 200px;
}

/* Individual Messages */
#chatbot-window > div:nth-child(2) > div {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
}

#chatbot-window > div:nth-child(2) > div:last-child {
    margin-bottom: 0;
}

/* User Messages */
#chatbot-window > div:nth-child(2) > div[style*="background: #007bff"] {
    background: var(--secondary-color) !important;
    color: white;
    margin-left: auto;
    text-align: right;
}

/* Assistant Messages */
#chatbot-window > div:nth-child(2) > div[style*="background: #f8f9fa"] {
    background: #f8f9fa !important;
    color: #333;
    margin-right: auto;
    text-align: left;
}

/* Chat Input Area */
#chatbot-window > div:last-child {
    padding: 16px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Input Field */
#chatbot-window input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    min-height: 44px; /* Touch-friendly height */
}

#chatbot-window input[type="text"]:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Send Button */
#chatbot-window button:last-child {
    padding: 12px 20px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    min-height: 44px; /* Touch-friendly height */
    white-space: nowrap;
}

#chatbot-window button:last-child:hover {
    background: #0056b3;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    /* Chat Button - Smaller on mobile */
    #chatbot-button {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }
    
    #chatbot-button svg {
        width: 22px;
        height: 22px;
    }
    
    /* Chat Window - Full width on mobile */
    #chatbot-window {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
        bottom: 0;
    }
    
    /* Chat Header - Mobile optimized */
    #chatbot-window > div:first-child {
        padding: 20px;
        font-size: 18px;
        border-radius: 16px 16px 0 0;
    }
    
    /* Messages Container - Mobile optimized */
    #chatbot-window > div:nth-child(2) {
        padding: 16px;
        max-height: 50vh;
        min-height: 150px;
    }
    
    /* Individual Messages - Mobile optimized */
    #chatbot-window > div:nth-child(2) > div {
        margin-bottom: 12px;
        padding: 10px 14px;
        max-width: 85%;
        font-size: 15px;
        line-height: 1.4;
    }
    
    /* Chat Input Area - Mobile optimized */
    #chatbot-window > div:last-child {
        padding: 16px;
        gap: 12px;
    }
    
    /* Input Field - Mobile optimized */
    #chatbot-window input[type="text"] {
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 48px;
    }
    
    /* Send Button - Mobile optimized */
    #chatbot-window button:last-child {
        padding: 14px 20px;
        font-size: 16px;
        min-height: 48px;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    /* Chat Button - Even smaller on very small screens */
    #chatbot-button {
        width: 52px;
        height: 52px;
        bottom: 12px;
        right: 12px;
    }
    
    /* Chat Window - Optimized for very small screens */
    #chatbot-window {
        max-height: 85vh;
    }
    
    /* Messages Container - Smaller padding on very small screens */
    #chatbot-window > div:nth-child(2) {
        padding: 12px;
        max-height: 45vh;
    }
    
    /* Individual Messages - Smaller padding on very small screens */
    #chatbot-window > div:nth-child(2) > div {
        padding: 8px 12px;
        font-size: 14px;
        max-width: 90%;
    }
    
    /* Chat Input Area - Smaller padding on very small screens */
    #chatbot-window > div:last-child {
        padding: 12px;
        gap: 8px;
    }
    
    /* Input Field - Smaller on very small screens */
    #chatbot-window input[type="text"] {
        padding: 12px 14px;
        min-height: 44px;
    }
    
    /* Send Button - Smaller on very small screens */
    #chatbot-window button:last-child {
        padding: 12px 16px;
        min-height: 44px;
    }
}

/* Landscape Mobile Orientation */
@media (max-width: 768px) and (orientation: landscape) {
    #chatbot-window {
        max-height: 70vh;
        bottom: 0;
    }
    
    #chatbot-window > div:nth-child(2) {
        max-height: 40vh;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #chatbot-button {
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    
    #chatbot-window {
        box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    #chatbot-button:hover {
        transform: none;
    }
    
    #chatbot-window button:hover {
        background: inherit;
    }
    
    /* Increase touch targets */
    #chatbot-window button {
        min-width: 44px;
        min-height: 44px;
    }
    
    #chatbot-window input[type="text"] {
        min-height: 44px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    #chatbot-window {
        background: #1a1a1a;
        color: #ffffff;
    }
    
    #chatbot-window > div:nth-child(2) > div[style*="background: #f8f9fa"] {
        background: #2d2d2d !important;
        color: #ffffff;
    }
    
    #chatbot-window input[type="text"] {
        background: #2d2d2d;
        color: #ffffff;
        border-color: #444;
    }
    
    #chatbot-window > div:last-child {
        border-top-color: #444;
    }
} 

/* User Registration Modal */
.chatbot-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10002;
    backdrop-filter: blur(4px);
}

.chatbot-modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.chatbot-modal-content h3 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 24px;
    font-weight: 600;
}

.chatbot-modal-content p {
    margin: 0 0 25px 0;
    color: #666;
    font-size: 16px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

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

.form-actions {
    margin-top: 30px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* User Registration Form (Inside Chat Window) */
.chatbot-registration-form {
    padding: 20px;
    text-align: center;
    max-width: 100%;
}

.registration-header h3 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 20px;
    font-weight: 600;
}

.registration-header p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
}

.chatbot-registration-form .form-group {
    margin-bottom: 16px;
    text-align: left;
}

.chatbot-registration-form .form-group label {
    display: block;
    margin-bottom: 6px;
    color: #333;
    font-weight: 500;
    font-size: 13px;
}

.chatbot-registration-form .form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.chatbot-registration-form .form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chatbot-registration-form .form-actions {
    margin-top: 20px;
}

.chatbot-registration-form .btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
}

.chatbot-registration-form .btn-primary:hover {
    background: var(--primary-dark);
}

/* Chat Messages */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
}

.chatbot-message {
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.4;
    animation: messageSlideIn 0.3s ease-out;
}

.user-message {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
    text-align: right;
}

.assistant-message {
    background: #f8f9fa;
    color: #333;
    margin-right: auto;
    text-align: left;
}

.message-timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    opacity: 0.8;
}

.user-message .message-timestamp {
    margin-right: 8px;
}

.assistant-message .message-timestamp {
    margin-left: 8px;
}

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

/* Loading Indicator */
.loading-indicator {
    opacity: 0.7;
    font-style: italic;
    color: #666;
}

/* Typing Indicator */
.typing-indicator {
    opacity: 0.7;
}

.typing-dots {
    display: inline-block;
}

.typing-dots span {
    animation: typingDot 1.4s infinite ease-in-out;
    display: inline-block;
    margin: 0 2px;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Chat Input */ 

/* ================================
   Widget spacing overrides (≈60%)
   ================================ */
/* Header, messages area, input area */
#chatbot-window > div:first-child { padding: 10px 12px; }
#chatbot-window > div:nth-child(2) { padding: 10px; gap: 6px; }
#chatbot-window > div:last-child { padding: 10px 12px; gap: 6px; }

/* Message bubbles */
#chatbot-window > div:nth-child(2) > div { margin-bottom: 8px; padding: 8px 10px; }
#chatbot-window > div:nth-child(2) > div:last-child { margin-bottom: 0; }

/* Input controls */
#chatbot-window input[type="text"] { padding: 8px 10px; min-height: 38px; }
#chatbot-window button:last-child { padding: 10px 12px; min-height: 38px; margin:10px;}

/* Button position offsets */
#chatbot-widget.bottom-right #chatbot-button { bottom: 12px; right: 12px; }
#chatbot-widget.bottom-left  #chatbot-button { bottom: 12px; left: 12px; }
#chatbot-widget.top-right    #chatbot-button { top: 12px; right: 12px; }
#chatbot-widget.top-left     #chatbot-button { top: 12px; left: 12px; }

/* Resize handle */
.chatbot-resize-handle {
    width: 12px;
    height: 12px;
    position: absolute;
    right: 4px;
    bottom: 4px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.2) 50%);
    border-radius: 2px;
}

