/* Chatbot Styles */
#chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 100px; /* Shift right to avoid back-to-top button */
    z-index: 9998; /* Lower than back-to-top to avoid overlap */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Floating Toggle Button */
.chatbot-toggle {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(220, 38, 38, 0.5);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle svg {
    width: 32px;
    height: 32px;
    color: white;
    transition: all 0.3s ease;
}

.chatbot-toggle .chatbot-icon {
    display: block;
}

.chatbot-toggle .close-icon {
    display: none;
}

.chatbot-toggle.active .chatbot-icon {
    display: none;
}

.chatbot-toggle.active .close-icon {
    display: block;
}

/* Badge */
.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
    border: 3px solid white;
}

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

/* Chat Window */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-height: 600px; /* Enforce max height */
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden; /* Critical: prevent window from growing */
}

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

/* Header */
.chatbot-header {
    padding: 20px;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    border-radius: 24px 24px 0 0;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0; /* Prevent header from shrinking */
}

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

.chatbot-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-avatar svg {
    width: 28px;
    height: 28px;
    color: white;
}

.chatbot-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.chatbot-status {
    font-size: 13px;
    margin: 4px 0 0 0;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chatbot-close-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    min-height: 0; /* Important for flex scrolling */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 8px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #fca5a5 0%, #f87171 100%);
    border-radius: 4px;
    border: 2px solid #f3f4f6;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
}

/* Messages */
.chatbot-message {
    display: flex;
    gap: 10px;
    animation: slideUp 0.3s ease;
}

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

.bot-message {
    align-items: flex-start;
}

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

.bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid #fecaca;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
}

.bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bot-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
}

.bot-message .message-bubble {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble p {
    margin: 0;
    font-size: 14px;
}

/* Quick Actions - Simple Always-Visible Version */
.quick-actions-container-simple {
    margin: 16px 0;
    margin-bottom: 20px; /* Extra bottom margin for visibility */
    animation: slideUp 0.4s ease-out;
    background: white;
    border-radius: 16px;
    overflow: visible; /* Changed from hidden to visible */
    border: 2px solid #fca5a5;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.1);
    position: relative;
    z-index: 10; /* Higher z-index to ensure visibility */
    display: block; /* Explicit display */
    visibility: visible; /* Explicit visibility */
}

.quick-actions-header-simple {
    padding: 12px 16px;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border-bottom: 2px solid #991b1b;
    display: block;
    visibility: visible;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
}

.quick-actions-header-simple .quick-actions-title {
    font-size: 14px;
    font-weight: 700;
    color: white;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.quick-actions-simple {
    display: flex !important; /* Force display */
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    scroll-behavior: smooth;
    visibility: visible !important; /* Force visibility */
    opacity: 1 !important; /* Force opacity */
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
}

.quick-actions-simple::-webkit-scrollbar {
    width: 5px;
}

.quick-actions-simple::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.quick-actions-simple::-webkit-scrollbar-thumb {
    background: #fca5a5;
    border-radius: 3px;
}

.quick-actions-simple::-webkit-scrollbar-thumb:hover {
    background: #dc2626;
}

.quick-action-btn {
    padding: 14px 18px;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
    border: 2.5px solid #fca5a5;
    border-radius: 14px;
    color: #dc2626;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.08);
    position: relative;
    overflow: hidden;
}

.quick-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(220, 38, 38, 0.1), transparent);
    transition: left 0.5s ease;
}

.quick-action-btn:hover::before {
    left: 100%;
}

.quick-action-btn:hover {
    border-color: #dc2626;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    transform: translateX(6px) scale(1.02);
    box-shadow: 0 6px 12px rgba(220, 38, 38, 0.2);
    color: #991b1b;
}

.quick-action-btn:active {
    transform: translateX(6px) scale(0.98);
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.15);
}

/* Input Area */
.chatbot-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 24px 24px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0; /* Prevent input area from shrinking */
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.chatbot-input:focus {
    border-color: #dc2626;
    background: #fef2f2;
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

.chatbot-send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Rating Widget */
.rating-widget {
    margin: 16px 0;
    padding: 20px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    animation: slideUp 0.4s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.rating-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
    text-align: center;
}

.rating-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: all 0.2s ease;
    opacity: 0.4;
}

.star-btn:hover {
    opacity: 1;
    transform: scale(1.2) rotate(5deg);
}

.star-btn svg {
    width: 28px;
    height: 28px;
    stroke: #f59e0b;
    fill: transparent;
    transition: all 0.2s ease;
}

.star-btn:hover svg {
    fill: #f59e0b;
    stroke: #f59e0b;
}

.ai-badge {
    display: inline-block;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    margin-top: 8px;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #chatbot-widget {
        bottom: 80px; /* Stack above back-to-top button on mobile */
        right: 16px;
    }
    
    .star-btn svg {
        width: 24px;
        height: 24px;
    }

    .chatbot-toggle {
        width: 56px;
        height: 56px;
    }

    .chatbot-toggle svg {
        width: 28px;
        height: 28px;
    }

    .chatbot-window {
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .chatbot-window.active {
        bottom: 0;
    }

    .chatbot-header {
        border-radius: 0;
    }

    .chatbot-input-area {
        border-radius: 0;
    }
}

/* Typing Indicator */
.typing-bubble {
    background: white !important;
    padding: 16px 20px !important;
}

.typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

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

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

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

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
