/* OV Helper Chatbot Styles */
.ov-chatbot {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ov-chatbot.bottom-right {
    bottom: 20px;
    right: 20px;
}

.ov-chatbot.bottom-left {
    bottom: 20px;
    left: 20px;
}

/* ✨ MAGICAL Chat Button with Ovee's Face ✨ */
.ov-chatbot-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    animation: ovee-float 6s ease-in-out infinite;
    padding: 6px;
}

.ov-chatbot-button-avatar {
    width: 52px;
    height: 52px;
    background: url('/images/ovee-avatar.png') center/cover;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.ov-chatbot-button:hover .ov-chatbot-button-avatar {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.ov-chatbot-button:hover {
    transform: scale(1.15) translateY(-4px);
    box-shadow: 0 12px 48px rgba(59, 130, 246, 0.6);
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.ov-chatbot-button::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, #3b82f6, #8b5cf6, #06b6d4, #3b82f6);
    border-radius: 50%;
    z-index: -1;
    animation: ovee-border-spin 3s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ov-chatbot-button:hover::before {
    opacity: 1;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ov-chatbot-button-icon {
    font-size: 24px;
    color: white;
    transition: transform 0.3s ease;
}

.ov-chatbot-button.open .ov-chatbot-button-icon {
    transform: rotate(45deg);
}

/* ✨ MAGICAL Chat Window ✨ */
.ov-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: linear-gradient(145deg, #1f2937 0%, #111827 100%);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(59, 130, 246, 0.2), 0 0 0 1px rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.ov-chatbot-window.open {
    display: flex;
}

/* ✨ MAGICAL Chat Header ✨ */
.ov-chatbot-header {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.ov-chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: ovee-header-shine 3s ease-in-out infinite;
}

@keyframes ovee-header-shine {
    0% { left: -100%; }
    50% { left: 100%; }
    100% { left: 100%; }
}

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

.ov-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

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

/* Messages Container */
.ov-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #111827;
}

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

.ov-chatbot-messages::-webkit-scrollbar-track {
    background: #374151;
    border-radius: 3px;
}

.ov-chatbot-messages::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 3px;
}

.ov-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Message Bubbles */
.ov-chatbot-message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
}

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

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

.ov-chatbot-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.ov-chatbot-message.user .ov-chatbot-message-content {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border-bottom-right-radius: 6px;
}

.ov-chatbot-message.bot .ov-chatbot-message-content {
    background: #374151;
    color: #f3f4f6;
    border-bottom-left-radius: 6px;
}

/* 💜 Beautiful Ovee Photo Avatar 💜 */
.ov-chatbot-message.bot::before {
    content: '';
    width: 32px;
    height: 32px;
    margin-right: 8px;
    margin-top: 2px;
    background: url('/images/ovee-avatar.png') center/cover;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    animation: ovee-glow 3s ease-in-out infinite;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

@keyframes ovee-glow {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
        transform: scale(1.05);
    }
}

/* Typing Indicator */
.ov-chatbot-typing {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #374151;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    max-width: 80%;
    margin-bottom: 16px;
}

.ov-chatbot-typing::before {
    content: '';
    width: 24px;
    height: 24px;
    margin-right: 8px;
    background: url('/images/ovee-avatar.png') center/cover;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ov-chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.ov-chatbot-typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.ov-chatbot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ov-chatbot-typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Input Area */
.ov-chatbot-input {
    padding: 16px 20px;
    background: #1f2937;
    border-top: 1px solid #374151;
    display: flex;
    gap: 12px;
    align-items: center;
}

.ov-chatbot-input input {
    flex: 1;
    background: #374151;
    border: 1px solid #4b5563;
    border-radius: 20px;
    padding: 10px 16px;
    color: #f3f4f6;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.ov-chatbot-input input:focus {
    border-color: #ef4444;
}

.ov-chatbot-input input::placeholder {
    color: #9ca3af;
}

.ov-chatbot-send {
    background: linear-gradient(135deg, #ef4444, #f59e0b);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.ov-chatbot-send:hover {
    transform: scale(1.05);
}

.ov-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ov-chatbot-send-icon {
    color: white;
    font-size: 16px;
}

/* Welcome Message */
.ov-chatbot-welcome {
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
    padding: 20px;
    border-bottom: 1px solid #374151;
}

/* Quick Actions */
.ov-chatbot-quick-actions {
    padding: 16px 20px;
    background: #1f2937;
    border-top: 1px solid #374151;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ov-chatbot-quick-action {
    background: #374151;
    border: 1px solid #4b5563;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    color: #d1d5db;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ov-chatbot-quick-action:hover {
    background: #4b5563;
    border-color: #ef4444;
    color: #f3f4f6;
}

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

    .ov-chatbot.bottom-left {
        bottom: 15px;
        left: 15px;
    }

    .ov-chatbot-button {
        width: 56px;
        height: 56px;
        box-shadow: 0 4px 16px rgba(239, 68, 68, 0.25);
    }

    .ov-chatbot-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 140px);
        bottom: 75px;
        right: 15px;
        left: 15px;
        max-height: 600px;
        border-radius: 12px;
    }

    .ov-chatbot.bottom-left .ov-chatbot-window {
        left: 15px;
        right: 15px;
    }

    .ov-chatbot-header {
        padding: 14px 16px;
    }

    .ov-chatbot-header h3 {
        font-size: 15px;
    }

    .ov-chatbot-messages {
        padding: 16px;
    }

    .ov-chatbot-message-content {
        font-size: 15px;
        line-height: 1.5;
        max-width: 85%;
    }

    .ov-chatbot-input {
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .ov-chatbot-send {
        width: 44px;
        height: 44px;
        min-width: 44px; /* Ensure touch target size */
    }

    .ov-chatbot-close {
        width: 32px;
        height: 32px;
        min-width: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .ov-chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        bottom: 70px;
        right: 10px;
        left: 10px;
        border-radius: 8px;
    }

    .ov-chatbot.bottom-left .ov-chatbot-window {
        left: 10px;
        right: 10px;
    }

    .ov-chatbot-header {
        padding: 12px 14px;
    }

    .ov-chatbot-messages {
        padding: 12px;
    }

    .ov-chatbot-input {
        padding: 12px 14px;
    }
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    /* Prevent zoom on input focus for iOS */
    .ov-chatbot-input {
        font-size: 16px !important;
        transform: translateZ(0); /* Force hardware acceleration */
    }

    /* Better touch targets */
    .ov-chatbot-button,
    .ov-chatbot-send,
    .ov-chatbot-close {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    /* Smooth scrolling for messages */
    .ov-chatbot-messages {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Mobile keyboard handling */
    .ov-chatbot.mobile-open .ov-chatbot-window {
        position: fixed;
        top: 10px;
        bottom: 10px;
        height: auto;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        .ov-chatbot-window {
            /* Account for iOS Safari's dynamic viewport */
            height: calc(100vh - 140px);
            height: calc(100dvh - 140px); /* Use dynamic viewport height if supported */
        }

        .ov-chatbot.mobile-open .ov-chatbot-window {
            height: calc(100vh - 20px);
            height: calc(100dvh - 20px);
        }
    }
}

/* Mobile body class improvements */
body.ov-chatbot-mobile {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body.ov-chatbot-mobile.ov-chat-open {
    position: fixed;
    width: 100%;
    overflow: hidden;
}

/* Additional mobile fixes */
@media (max-width: 768px) {
    .ov-chatbot-window {
        /* Prevent content from going behind mobile browser UI */
        max-height: calc(100vh - 100px);
        max-height: calc(100dvh - 100px);
    }

    /* Better button spacing on mobile */
    .ov-chatbot-button {
        margin: 0;
        flex-shrink: 0;
    }

    /* Improve text readability on mobile */
    .ov-chatbot-message-content {
        word-break: break-word;
        hyphens: auto;
    }

    /* Better scrollbar on mobile */
    .ov-chatbot-messages::-webkit-scrollbar {
        width: 3px;
    }

    .ov-chatbot-messages::-webkit-scrollbar-thumb {
        background: rgba(156, 163, 175, 0.5);
    }
}

/* Notification Badge */
.ov-chatbot-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Chatbot Action Buttons */
.ov-chatbot-button {
    display: inline-block;
    padding: 8px 16px;
    margin: 4px 4px 4px 0;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.ov-chatbot-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ov-chatbot-button-primary {
    background: linear-gradient(135deg, #3B82F6, #1D4ED8);
    color: white;
}

.ov-chatbot-button-primary:hover {
    background: linear-gradient(135deg, #2563EB, #1E40AF);
}

.ov-chatbot-button-secondary {
    background: #374151;
    color: #F3F4F6;
}

.ov-chatbot-button-secondary:hover {
    background: #4B5563;
}

.ov-chatbot-button-outline {
    background: transparent;
    color: #3B82F6;
    border: 1px solid #3B82F6;
}

.ov-chatbot-button-outline:hover {
    background: #3B82F6;
    color: white;
}
