/* Chatbot Widget Styles - Floating Popup Version */
#chatbot-widget {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 998;
    font-family: 'Inter', sans-serif;
}

/* Toggle Button - Bottom Left with Glowing Waves */
#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    left: 1.5rem;
    z-index: 999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: slideInLeft 0.5s ease;
}

/* Glowing wave animation for chatbot button */
#chatbot-toggle::before,
#chatbot-toggle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #d4af37;
    opacity: 0;
    animation: wave-pulse-gold 2s infinite ease-out;
}

#chatbot-toggle::after {
    animation-delay: 1s;
}

@keyframes wave-pulse-gold {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.8);
        opacity: 0;
    }
}

#chatbot-toggle:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.6);
}

#chatbot-toggle:active {
    transform: scale(0.95);
}

#chatbot-toggle svg {
    position: relative;
    z-index: 1;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

.welcome-tooltip {
    position: fixed;
    bottom: 100px;
    left: 1.5rem;
    background: white;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    max-width: 250px;
    z-index: 998;
    animation: tooltipSlideIn 0.4s ease;
}

@keyframes tooltipSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tooltipSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

.tooltip-close {
    position: absolute;
    top: 4px;
    right: 4px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 4px;
}

.tooltip-close:hover {
    color: #333;
}

.welcome-tooltip-text {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    margin-bottom: 4px;
}

.welcome-tooltip-subtext {
    font-size: 12px;
    color: #666;
}

#chatbot-container {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 1.5rem;
    width: 400px;
    max-width: calc(100vw - 3rem);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    animation: popupSlideIn 0.3s ease;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#chatbot-header {
    background: #222;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chatbot-title {
    font-weight: 600;
    font-size: 16px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

#chatbot-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
}

#chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.message-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.message-container.user {
    align-items: flex-end;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 2px;
}

.message.user {
    background: #d4af37;
    color: white;
    border-bottom-right-radius: 2px;
}

.message-time {
    font-size: 10px;
    color: #999;
    padding: 0 4px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 14px;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 1;
    }

    30% {
        transform: translateY(-10px);
        opacity: 0.7;
    }
}

.message.bot a {
    color: #d4af37;
    text-decoration: underline;
}

.message.bot a:hover {
    color: #b8941f;
}

#chatbot-input-area {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    background: white;
}

#chatbot-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    color: #333;
    background-color: #fff;
}

#chatbot-send {
    background: #222;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#chatbot-send:hover {
    background: #444;
}

#chatbot-lang-switch {
    font-size: 12px;
    margin-right: 10px;
    cursor: pointer;
    color: #ccc;
    transition: color 0.2s;
}

#chatbot-lang-switch:hover {
    color: white;
}

/* Quick Reply Buttons */
.quick-reply-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quick-reply-btn {
    background: white;
    border: 1.5px solid #d4af37;
    color: #222;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.25s ease;
    animation: buttonFadeIn 0.4s ease;
    animation-fill-mode: both;
    white-space: nowrap;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

@keyframes buttonFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.quick-reply-btn:hover {
    background: #d4af37;
    color: white;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 8px rgba(212, 175, 55, 0.3);
}

.quick-reply-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    #chatbot-toggle {
        width: 50px;
        height: 50px;
        bottom: 15px;
        left: 1rem;
    }

    #chatbot-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        left: 0;
        right: 0;
        top: 0;
        border-radius: 0;
        max-width: none;
        max-height: none;
        display: none;
        /* Toggled by JS */
        flex-direction: column;
        z-index: 2000;
        /* Ensure it's on top of everything including the toggle button */
    }

    .welcome-tooltip {
        left: 1rem;
        bottom: 85px;
        z-index: 1999;
    }

    #chatbot-header {
        padding: 15px;
        flex-shrink: 0;
    }

    #chatbot-title {
        font-size: 16px;
    }

    #chatbot-status {
        display: inline-flex !important;
        /* Keep status visible if space permits, or hide if needed. User didn't ask to hide it. */
    }

    #chatbot-messages {
        padding: 15px;
        font-size: 14px;
        flex: 1;
        /* Take remaining space */
        overflow-y: auto;
    }

    .message {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 14px;
    }

    #chatbot-input-area {
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        /* Handle iPhone home bar */
        background: white;
        flex-shrink: 0;
        /* Prevent shrinking when keyboard opens if possible, but usually viewport shrinks */
    }

    #chatbot-input {
        padding: 10px 12px;
        font-size: 16px;
        /* Prevent zoom on iOS input focus */
    }

    #chatbot-send {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}