/* Modern Floating Chatbot - Dex Pro Max */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Rubik:wght@400;500;600&display=swap');

:root {
    --dex-primary: #ff6f00;
    --dex-primary-dark: #e65100;
    --dex-primary-gradient: linear-gradient(135deg, #ff6f00 0%, #ff8f3c 100%);
    --dex-bg-light: #ffffff;
    --dex-bg-bubble-bot: #f1f5f9;
    --dex-text-dark: #1e293b;
    --dex-text-light: #64748b;
    --dex-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --dex-radius-window: 20px;
    --dex-radius-bubble: 12px;
    --dex-font: 'Montserrat', sans-serif;
}

/* Chatbot Toggle Button */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    background: transparent;
    border: none;
    border-radius: 50%;
    /* Circular for icon */
    box-shadow: none;
    /* No shadow */
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chatbot-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 10px 30px rgba(255, 111, 0, 0.4);
}

.chatbot-toggle svg {
    width: 60px;
    /* Larger icon to replace the button container */
    height: 60px;
    fill: #ff6f00;
    /* Pure Orange */
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    /* Add shadow to icon itself */
}

.chatbot-toggle.active {
    transform: rotate(90deg);
    background: transparent;
}

.chatbot-toggle.active svg {
    fill: #ff6f00;
}

/* Chatbot Choice Menu */
.chatbot-choices {
    position: fixed;
    bottom: 110px;
    /* Above main toggle */
    right: 38px;
    /* Centered relative to 64px toggle */
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 9998;
    pointer-events: none;
    /* Click through when hidden */
}

.chatbot-choices.active {
    pointer-events: auto;
}

.choice-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chatbot-choices.active .choice-btn {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Staggered Animation */
.chatbot-choices.active .choice-btn:nth-child(1) {
    transition-delay: 0.1s;
}

/* Messenger (Top) */
.chatbot-choices.active .choice-btn:nth-child(2) {
    transition-delay: 0.05s;
}

/* Dex (Bottom) */

/* Button Specifics */
.choice-btn.link-messenger svg {
    fill: #0084FF;
    width: 24px;
    height: 24px;
}

.choice-btn.link-dex .choice-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: url('../images/rx/dex-avatar.jpg') no-repeat center center/cover;
    border: 2px solid white;
}

/* Tooltips */
.choice-tooltip {
    position: absolute;
    right: 60px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s;
    pointer-events: none;
}

.choice-btn:hover .choice-tooltip {
    opacity: 1;
    transform: translateX(0);
}

.choice-btn:hover {
    transform: scale(1.1);
}


/* Chatbot Window */
.chatbot-window {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 400px;
    height: 600px;
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--dex-radius-window);
    box-shadow: var(--dex-shadow);
    border: 1px solid rgba(255, 255, 255, 0.5);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--dex-font);
}

.chatbot-window.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chatbot Header */
.chatbot-header {
    background: var(--dex-primary-gradient);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

/* Subtle pattern overlay */
.chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1h2v2H1V1zm4 0h2v2H5V1zm4 0h2v2H9V1z' fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
    opacity: 0.3;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 1;
}

.chatbot-avatar {
    width: 54px;
    height: 54px;
    background: url('../images/rx/dex-avatar.jpg') no-repeat center center/cover;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 2px solid white;
}

.chatbot-title {
    display: flex;
    flex-direction: column;
    color: white;
}

.chatbot-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.chatbot-status {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(74, 222, 128, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 1;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Chat Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 3px;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease-out;
    max-width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-items: flex-end;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message.bot .message-avatar {
    background: url('../images/rx/dex-avatar.jpg') no-repeat center center/cover;
    border: 1px solid #e2e8f0;
}

.message.user .message-avatar {
    background: #e2e8f0;
    color: var(--dex-text-light);
}

.message-bubble {
    max-width: 80%;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.6;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.message.bot .message-bubble {
    background: var(--dex-bg-bubble-bot);
    color: var(--dex-text-dark);
    border-radius: var(--dex-radius-bubble) var(--dex-radius-bubble) var(--dex-radius-bubble) 4px;
}

.message.usr .message-bubble {
    background: var(--dex-primary);
    color: white;
    border-radius: var(--dex-radius-bubble) var(--dex-radius-bubble) 4px var(--dex-radius-bubble);
}

/* Fix for user bubble correct class usage check */
.message.user .message-bubble {
    background: linear-gradient(135deg, #ff6f00 0%, #ff8f3c 100%);
    color: white;
    border-radius: var(--dex-radius-bubble) var(--dex-radius-bubble) 4px var(--dex-radius-bubble);
    box-shadow: 0 4px 12px rgba(255, 111, 0, 0.2);
}

/* Message Content Formatting */
.message-bubble ul {
    margin: 8px 0 0 16px;
    padding: 0;
    list-style-type: none;
}

.message-bubble li {
    position: relative;
    margin-bottom: 6px;
    padding-left: 4px;
}

.message-bubble li::before {
    content: "•";
    color: var(--dex-primary);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

.message.user .message-bubble li::before {
    color: white;
    /* White bullets for user messages if any */
}

/* Time */
.message-time {
    font-size: 11px;
    color: var(--dex-text-light);
    margin-top: 6px;
    margin-left: 2px;
}

.message.user .message-time {
    text-align: right;
}

/* Quick Suggestions */
.quick-suggestions {
    padding: 16px 24px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}

.suggestions-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--dex-text-light);
    margin-bottom: 12px;
    font-weight: 600;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.suggestion-chip {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--dex-text-dark);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.suggestion-chip:hover {
    background: #fff5eb;
    /* Light orange tint */
    border-color: var(--dex-primary);
    color: var(--dex-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 111, 0, 0.1);
}

/* Chat Input Area */
.chatbot-input {
    padding: 20px 24px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 12px;
    align-items: center;
}

.chatbot-input input {
    flex: 1;
    padding: 14px 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    font-family: var(--dex-font);
}

.chatbot-input input:focus {
    background: #fff;
    border-color: var(--dex-primary);
    box-shadow: 0 0 0 3px rgba(255, 111, 0, 0.1);
}

.chatbot-input button {
    background: var(--dex-primary);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(255, 111, 0, 0.2);
}

.chatbot-input button:hover {
    transform: scale(1.05);
    background: var(--dex-primary-dark);
}

.typing-message .message-avatar {
    background: url('../images/rx/dex-avatar.jpg') no-repeat center center/cover !important;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    background: var(--dex-bg-bubble-bot);
    border-radius: var(--dex-radius-bubble);
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .chatbot-choices {
        bottom: 160px;
        /* Adjust for mobile toggle position */
        right: 28px;
    }

    .chatbot-window {
        width: 85vw;
        /* 50% smaller visual footprint compared to fullscreen */
        height: auto;
        max-height: 60vh;
        bottom: 100px;
        /* Clear bottom nav */
        right: 20px;
        border-radius: 20px;
        /* Restore border radius */
        z-index: 10000;
        left: auto;
        transform-origin: bottom right;
    }

    .chatbot-toggle {
        bottom: 90px;
        /* Shift up to avoid bottom nav */
        right: 20px;
        width: 56px;
        /* Slightly smaller toggle */
        height: 56px;
    }

    .chatbot-header {
        padding-top: max(20px, env(safe-area-inset-top));
        /* Safe area for mobiles */
    }
}