/* Custom Chatbox Widget - WhatsApp Style */

.chatbox-container {
    position: fixed;
    bottom: 30px;
    right: 110px; /* Next to WhatsApp button */
    z-index: 999;
    font-family: 'Poppins', sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.chatbox-container.visible {
    opacity: 1;
    visibility: visible;
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5), 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    animation: whatsappFloat 3s ease-in-out infinite;
    backdrop-filter: blur(10px);
}

.chat-toggle-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));
    animation: whatsappPulse 2s ease-in-out infinite;
    z-index: -1;
}

.chat-toggle-btn i {
    font-size: 28px;
    color: white;
    transition: transform 0.3s ease;
}

.chat-toggle-btn:hover {
    transform: translateY(-10px) scale(1.12);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6), 0 8px 20px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #7c8ef7 0%, #8b5fc4 100%);
}

.chat-toggle-btn:hover i {
    transform: scale(1.15) rotate(5deg);
}

.chat-toggle-btn.active i {
    transform: rotate(90deg);
}

/* Notification Badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    animation: badgePulse 1.5s ease-in-out infinite;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 560px;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9ff 100%);
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(102, 126, 234, 0.25), 0 10px 30px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(102, 126, 234, 0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
}

.chat-window.active {
    display: flex;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    position: relative;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

/* Language Toggle */
.language-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 4px;
    gap: 4px;
    margin-left: auto;
    margin-right: 8px;
}

.lang-btn {
    padding: 4px 12px;
    border: none;
    border-radius: 16px;
    background: transparent;
    color: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.lang-btn.active {
    background: white;
    color: #667eea;
}

.lang-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
}

.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

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

.chat-avatar i {
    color: #667eea;
}

.chat-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-info p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chat-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
}

.chat-close:hover {
    transform: scale(1.1);
}

/* Chat Body */
.chat-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: linear-gradient(to bottom, #f8f9ff 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Messages */
.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: messageSlideIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-message.user .message-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 14px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3), 0 2px 6px rgba(0, 0, 0, 0.1);
    border: none;
}

.chat-message.user .message-text {
    color: white;
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    color: #2d3748;
    font-weight: 400;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: block;
}

.chat-message.user .message-time {
    color: rgba(255, 255, 255, 0.8);
}

/* Service Options */
.service-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.service-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    border: 2px solid #667eea;
    color: #667eea;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    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 8px rgba(102, 126, 234, 0.1);
}

.service-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateX(6px) scale(1.02);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    border-color: #764ba2;
}

.service-btn i {
    font-size: 14px;
}

/* WhatsApp Link Button */
.whatsapp-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    margin-top: 8px;
    cursor: pointer;
}

.whatsapp-link-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
    background: linear-gradient(135deg, #2FE074 0%, #15A77D 100%);
}

.whatsapp-link-btn i {
    font-size: 16px;
}

.whatsapp-link-btn:active {
    transform: translateY(-1px) scale(1.02);
}

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

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 13px 18px;
    border: 2px solid #e5e5e5;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
}

.chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15), 0 2px 8px rgba(102, 126, 234, 0.1);
    background: #ffffff;
}

.chat-send-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.15) rotate(15deg);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    background: linear-gradient(135deg, #7c8ef7, #8b5fc4);
}

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

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typingBounce 1.4s infinite;
}

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

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

/* Animations */
@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* WhatsApp-style animations for mobile */
@keyframes whatsappFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes whatsappPulse {
    0%, 100% {
        opacity: 0;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbox-container {
        right: 90px; /* Left side of WhatsApp button */
        bottom: 24px; /* Same level as WhatsApp */
    }

    .chat-toggle-btn {
        width: 56px;
        height: 56px;
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
        animation: whatsappFloat 3s ease-in-out infinite; /* Same as WhatsApp */
    }

    .chat-toggle-btn::before {
        animation: whatsappPulse 2s ease-in-out infinite; /* Same as WhatsApp */
    }

    .chat-toggle-btn i {
        font-size: 26px;
    }

    .chat-window {
        position: fixed;
        width: 90vw;
        height: 70vh;
        max-width: 400px;
        max-height: 600px;
        bottom: 90px;
        right: 20px;
        left: auto;
        top: auto;
        border-radius: 16px;
        transform: none;
        z-index: 1000;
    }

    .chat-window.active {
        transform: none;
    }

    .chat-header {
        padding: 16px 18px;
        padding-top: max(16px, env(safe-area-inset-top, 16px));
    }

    .chat-avatar {
        width: 40px;
        height: 40px;
    }

    .chat-info h3 {
        font-size: 15px;
    }

    .chat-info p {
        font-size: 11px;
    }

    .language-toggle {
        padding: 3px;
        gap: 3px;
    }

    .lang-btn {
        padding: 5px 10px;
        font-size: 10px;
    }

    .chat-body {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    }

    .message-bubble {
        max-width: 85%;
        padding: 10px 14px;
    }

    .message-text {
        font-size: 14px;
        line-height: 1.5;
    }

    .service-btn {
        padding: 11px 16px;
        font-size: 13px;
    }

    .whatsapp-link-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .chat-footer {
        padding: 14px 16px;
        padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    }

    .chat-input {
        padding: 12px 16px;
        font-size: 15px;
    }

    .chat-send-btn {
        width: 44px;
        height: 44px;
        font-size: 17px;
    }
}

@media (max-width: 480px) {
    .chatbox-container {
        right: 82px; /* Left side of WhatsApp (16px + 54px + 12px gap) */
        bottom: 20px; /* Same level as WhatsApp */
    }

    .chat-toggle-btn {
        width: 54px;
        height: 54px;
        animation: whatsappFloat 3s ease-in-out infinite;
    }

    .chat-toggle-btn::before {
        animation: whatsappPulse 2s ease-in-out infinite;
    }

    .chat-toggle-btn i {
        font-size: 24px;
    }

    .chat-header {
        padding: 14px 16px;
    }

    .chat-avatar {
        width: 36px;
        height: 36px;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }

    .chat-info h3 {
        font-size: 14px;
    }

    .chat-info p {
        font-size: 10px;
    }

    .language-toggle {
        margin-right: 4px;
    }

    .lang-btn {
        padding: 4px 9px;
        font-size: 10px;
    }

    .chat-window {
        width: 85vw;
        height: 65vh;
        max-width: 360px;
        max-height: 550px;
        bottom: 85px;
        right: 16px;
        border-radius: 14px;
    }

    .chat-body {
        padding: 14px;
        gap: 12px;
    }

    .message-bubble {
        max-width: 82%;
        padding: 10px 13px;
    }

    .message-text {
        font-size: 13.5px;
    }

    .service-btn {
        padding: 10px 14px;
        font-size: 12.5px;
        gap: 8px;
    }

    .whatsapp-link-btn {
        padding: 9px 13px;
        font-size: 12.5px;
        gap: 6px;
    }

    .whatsapp-link-btn i {
        font-size: 15px;
    }

    .chat-footer {
        padding: 12px 14px;
    }

    .chat-input {
        padding: 11px 15px;
        font-size: 14px;
    }

    .chat-send-btn {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

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

/* Extra small devices */
@media (max-width: 360px) {
    .chatbox-container {
        right: 78px; /* Left side of WhatsApp */
        bottom: 20px;
    }

    .chat-toggle-btn {
        width: 52px;
        height: 52px;
        animation: whatsappFloat 3s ease-in-out infinite;
    }

    .chat-toggle-btn::before {
        animation: whatsappPulse 2s ease-in-out infinite;
    }

    .chat-toggle-btn i {
        font-size: 22px;
    }

    .chat-window {
        width: 82vw;
        height: 62vh;
        max-width: 340px;
        max-height: 520px;
    }

    .message-text {
        font-size: 13px;
    }

    .service-btn {
        padding: 9px 12px;
        font-size: 12px;
    }
}

/* Scrollbar Styling */
.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}
