/**
 * Capalus Chatbot Widget Styles - Scoped
 * Compatible with Hyvä Theme and Tailwind CSS
 * All classes scoped to .chatbot-container to prevent conflicts
 *
 * @category  Capalus
 * @package   Capalus_Chatbot
 * @author    Capalus Team
 * @copyright Copyright (c) 2025 Capalus
 */

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

/* Chat Button */
.chatbot-container .chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6dbbeb 0%, #4067ae 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
}

.chatbot-container .chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chatbot-container .chat-button svg {
    width: 28px;
    height: 28px;
}

.chatbot-container .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Chat Window */
.chatbot-container .chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat Header */
.chatbot-container .chat-header {
    background: linear-gradient(135deg, #6dbbeb 0%, #4067ae 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chatbot-container .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: 14px;
    backdrop-filter: blur(10px);
}

.chatbot-container .chat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-container .chat-header-text p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-container .chat-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.chatbot-container .chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Tabs */
.chatbot-container .chat-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.chatbot-container .chat-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    position: relative;
    transition: all 0.2s;
}

.chatbot-container .chat-tab:hover {
    color: #667eea;
    background: #f3f4f6;
}

.chatbot-container .chat-tab.active {
    color: #667eea;
    background: white;
}

.chatbot-container .chat-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #667eea;
}

/* Quick Actions */
.chatbot-container .quick-actions {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

.chatbot-container .quick-action-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chatbot-container .quick-action-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}

/* Chat Body */
.chatbot-container .chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: white;
}

/* Chat Messages */
.chatbot-container .capalus-chat-messages {
    padding: 16px;
    padding-bottom: 200px; /* Add extra bottom padding to keep last message visible above footer */
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 100%;
}

.chatbot-container .capalus-chat-message {
    display: flex;
    gap: 12px;
    animation: chatbotFadeInUp 0.3s ease;
}

.chatbot-container .capalus-chat-message.user {
    flex-direction: row-reverse;
}

.chatbot-container .capalus-chat-message .capalus-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6dbbeb 0%, #4067ae 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.chatbot-container .capalus-chat-message.user .capalus-message-avatar {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.chatbot-container .capalus-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 70%;
}

.chatbot-container .capalus-chat-message.user .capalus-message-content {
    align-items: flex-end;
}

.chatbot-container .capalus-message-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    background: #f3f4f6;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chatbot-container .capalus-chat-message.user .capalus-message-bubble {
    background: linear-gradient(135deg, #6dbbeb 0%, #4067ae 100%);
    color: white;
}

.chatbot-container .capalus-message-time {
    font-size: 11px;
    color: #9ca3af;
    padding: 0 4px;
}

/* Typing Indicator */
.chatbot-container .typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 12px;
    width: fit-content;
}

.chatbot-container .typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: chatbotTyping 1.4s infinite;
}

.chatbot-container .typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-container .typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatbotTyping {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Ticket Form */
.chatbot-container .ticket-form {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
}

.chatbot-container .ticket-form .form-group {
    margin-bottom: 16px;
}

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

.chatbot-container .ticket-form .form-input,
.chatbot-container .ticket-form .form-select,
.chatbot-container .ticket-form .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}

.chatbot-container .ticket-form .form-input:focus,
.chatbot-container .ticket-form .form-select:focus,
.chatbot-container .ticket-form .form-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-container .ticket-form .form-textarea {
    resize: vertical;
    min-height: 100px;
}

.chatbot-container .submit-ticket-btn {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #6dbbeb 0%, #4067ae 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.chatbot-container .submit-ticket-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chatbot-container .submit-ticket-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Chat Footer */
.chatbot-container .chat-footer {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.chatbot-container .chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chatbot-container .chat-attach-btn {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
}

.chatbot-container .chat-attach-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.chatbot-container .chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    transition: all 0.2s;
}

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

.chatbot-container .chat-send-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6dbbeb 0%, #4067ae 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chatbot-container .chat-send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chatbot-container .chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-container .chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* Image Preview */
.chatbot-container .image-preview-container {
    margin-top: 12px;
    padding: 8px;
    background: #f9fafb;
    border-radius: 12px;
}

.chatbot-container .image-preview {
    position: relative;
    display: inline-block;
}

.chatbot-container .image-preview img {
    display: block;
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
}

.chatbot-container .image-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-container .image-preview-remove:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Animations */
@keyframes chatbotFadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar Styles */
.chatbot-container .chat-messages::-webkit-scrollbar,
.chatbot-container .ticket-form::-webkit-scrollbar,
.chatbot-container .chat-body::-webkit-scrollbar {
    width: 6px;
}

.chatbot-container .chat-messages::-webkit-scrollbar-track,
.chatbot-container .ticket-form::-webkit-scrollbar-track,
.chatbot-container .chat-body::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.chatbot-container .chat-messages::-webkit-scrollbar-thumb,
.chatbot-container .ticket-form::-webkit-scrollbar-thumb,
.chatbot-container .chat-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chatbot-container .chat-messages::-webkit-scrollbar-thumb:hover,
.chatbot-container .ticket-form::-webkit-scrollbar-thumb:hover,
.chatbot-container .chat-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Screen Reader Only */
.chatbot-container .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .chatbot-container .chat-button {
        position: fixed;
        bottom: 20px;
        right: 20px;
    }

    .chatbot-container .chat-window {
        width: 100%;
        max-height: 90vh;
        height: 650px;
        bottom: 10px;
        right: 10px;
        left: 10px;
        border-radius: 12px 12px 0 0;
        top: auto;
    }

    .chatbot-container .capalus-message-content {
        max-width: 80%;
    }

    .chatbot-container .quick-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .chatbot-container .quick-actions::-webkit-scrollbar {
        display: none;
    }

    /* Adjust body and form heights for mobile */
    .chatbot-container .chat-body {
        max-height: 480px;
        overflow-y: auto;
    }

    .chatbot-container .chat-messages {
        max-height: 400px;
        overflow-y: auto;
        padding-bottom: 120px; /* Smaller bottom padding on mobile */
    }

    .chatbot-container .capalus-chat-messages {
        max-height: 400px;
        overflow-y: auto;
        padding-bottom: 120px; /* Smaller bottom padding on mobile */
    }

    .chatbot-container .ticket-form {
        max-height: 520px;
        overflow-y: auto;
        padding: 20px;
    }

    /* Ensure chat footer is visible */
    .chatbot-container .chat-footer {
        min-height: 60px;
    }
}

@media (max-width: 480px) {
    .chatbot-container .chat-header-text h3 {
        font-size: 14px;
    }

    .chatbot-container .chat-header-text p {
        font-size: 11px;
    }

    .chatbot-container .chat-tab {
        font-size: 13px;
        padding: 10px 12px;
    }

    .chatbot-container .capalus-message-bubble {
        font-size: 13px;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    .chatbot-container .chat-window {
        background: #1f2937;
        color: #f9fafb;
    }

    .chatbot-container .chat-tabs {
        background: #111827;
        border-bottom-color: #374151;
    }

    .chatbot-container .chat-tab {
        color: #9ca3af;
    }

    .chatbot-container .chat-tab:hover {
        background: #374151;
    }

    .chatbot-container .chat-tab.active {
        background: #1f2937;
    }

    .chatbot-container .quick-actions {
        background: #111827;
        border-bottom-color: #374151;
    }

    .chatbot-container .quick-action-btn {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }

    .chatbot-container .chat-body,
    .chatbot-container .ticket-form,
    .chatbot-container .chat-footer {
        background: #1f2937;
    }

    .chatbot-container .message-bubble {
        background: #374151;
        color: #f9fafb;
    }

    .chatbot-container .ticket-form .form-input,
    .chatbot-container .ticket-form .form-select,
    .chatbot-container .ticket-form .form-textarea,
    .chatbot-container .chat-input {
        background: #111827;
        border-color: #374151;
        color: #f9fafb;
    }

    .chatbot-container .ticket-form .form-group label {
        color: #f9fafb;
    }

    .chatbot-container .chat-footer {
        border-top-color: #374151;
    }
}

/* Print Styles */
@media print {
    .chatbot-container {
        display: none !important;
    }
}
