/* ============================================
   Vexora Chatbot Widget - Premium Design
   ============================================ */

/* Chatbot Toggle Button */
.chatbot-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    width: 60px;
    height: 60px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    overflow: hidden;
}

.chatbot-toggle:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.5);
}

.chatbot-toggle:active {
    transform: translateY(-2px) scale(0.98);
}

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

.chatbot-toggle:hover svg {
    transform: scale(1.1);
}

/* Pulse Indicator */
.chatbot-toggle::before {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #0a0a0f;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Chatbot Window */
.chatbot-window {
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    width: 380px;
    max-width: calc(100vw - 3rem);
    height: 550px;
    max-height: calc(100vh - 10rem);
    background: rgba(18, 18, 26, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 9998;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

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

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

.chatbot-title {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.chatbot-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

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

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

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

/* Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #0a0a0f;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* Message Bubbles */
.chatbot-message {
    display: flex;
    margin-bottom: 0.75rem;
    animation: messageSlideIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.chatbot-message.system {
    justify-content: center;
}

.message-bubble {
    max-width: 85%;
    padding: 0.875rem 1.125rem;
    border-radius: 16px;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.chatbot-message.user .message-bubble {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message.bot .message-bubble {
    background: rgba(39, 39, 42, 0.8);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #ffffff;
    border-bottom-left-radius: 4px;
}

.chatbot-message.system .message-bubble {
    background: rgba(39, 39, 42, 0.5);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    color: rgba(161, 161, 170, 0.9);
    font-style: italic;
    font-size: 0.875rem;
    text-align: center;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: rgba(161, 161, 170, 0.8);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}

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

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

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-6px);
    }
}

/* Markdown Styling in Messages */
.message-bubble p {
    margin: 0 0 0.5em 0;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble strong {
    font-weight: 700;
    color: inherit;
}

.message-bubble em {
    font-style: italic;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.875em;
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin: 0.75rem 0;
    overflow-x: auto;
}

.message-bubble pre code {
    background: transparent;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.message-bubble ul,
.message-bubble ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-bubble li {
    margin: 0.25em 0;
}

.message-bubble a {
    color: #fbbf24;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.message-bubble a:hover {
    color: #fcd34d;
}

.message-bubble img {
    max-width: 200px;
    border-radius: 12px;
    margin: 0.5rem 0;
    display: block;
}

.message-bubble iframe {
    border-radius: 10px;
    margin: 0.75rem 0;
}

/* Input Area */
.chatbot-input-area {
    padding: 1rem 1.25rem;
    background: rgba(18, 18, 26, 0.98);
    border-top: 1px solid rgba(99, 102, 241, 0.2);
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    background: rgba(39, 39, 42, 0.8);
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 0.9375rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.2s ease;
}

.chatbot-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chatbot-input::placeholder {
    color: rgba(161, 161, 170, 0.7);
}

/* Better handling for mobile keyboards */
@supports (-webkit-touch-callout: none) {
    .chatbot-window.active {
        position: fixed;
        bottom: 0;
        transform: translateY(0) scale(1);
    }
}

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

.chatbot-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.chatbot-send:active {
    transform: translateY(0);
}

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

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

/* Suggested Questions */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    animation: fadeIn 0.4s ease;
}

.suggestion-chip {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #6366f1;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25));
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.suggestion-chip:active {
    transform: translateY(0);
}

/* CTA Button in Message */
.message-cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    margin-top: 0.75rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.message-cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    text-decoration: none;
}

.message-cta-button svg {
    width: 18px;
    height: 18px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .chatbot-toggle {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 58px;
        height: 58px;
        border-radius: 18px;
    }

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

    .chatbot-window {
        bottom: 5.5rem;
        right: 1rem;
        left: 1rem;
        width: auto;
        max-width: none;
        height: 520px;
        max-height: calc(100vh - 8rem);
        border-radius: 20px;
    }

    .chatbot-header {
        padding: 1rem 1.25rem;
    }

    .chatbot-title {
        font-size: 1.05rem;
    }

    .chatbot-status {
        font-size: 0.7rem;
    }

    .chatbot-messages {
        padding: 1rem;
    }

    .message-bubble {
        max-width: 92%;
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }

    .message-bubble img {
        max-width: 100%;
    }

    .chatbot-input-area {
        padding: 1rem 1.125rem;
    }

    .chatbot-input {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 0.875rem 1rem;
    }

    .chatbot-send {
        min-width: 44px;
        min-height: 44px;
    }

    .chatbot-suggestions {
        padding: 0.75rem 1rem;
        gap: 0.375rem;
    }

    .suggestion-chip {
        font-size: 0.8125rem;
        padding: 0.5rem 0.875rem;
    }
}

@media (max-width: 480px) {
    .chatbot-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 54px;
        height: 54px;
    }

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

    .chatbot-window {
        height: 480px;
        max-height: calc(100vh - 6rem);
        bottom: 4.75rem;
        left: 0.75rem;
        right: 0.75rem;
        border-radius: 18px;
    }

    .chatbot-header {
        padding: 0.875rem 1rem;
    }

    .chatbot-avatar {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .chatbot-avatar svg {
        width: 20px;
        height: 20px;
    }

    .chatbot-title {
        font-size: 0.95rem;
    }

    .chatbot-status {
        font-size: 0.65rem;
    }

    .chatbot-close {
        width: 32px;
        height: 32px;
    }

    .chatbot-close svg {
        width: 18px;
        height: 18px;
    }

    .chatbot-messages {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .message-bubble {
        max-width: 95%;
        font-size: 0.875rem;
        padding: 0.75rem 0.875rem;
    }

    .message-bubble code {
        font-size: 0.8em;
    }

    .message-bubble pre {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .chatbot-input-area {
        padding: 0.875rem 1rem;
        gap: 0.5rem;
    }

    .chatbot-input {
        font-size: 16px;
        padding: 0.75rem 0.875rem;
    }

    .chatbot-send {
        width: 42px;
        height: 42px;
        min-width: 42px;
        min-height: 42px;
    }

    .chatbot-send svg {
        width: 18px;
        height: 18px;
    }

    .suggestion-chip {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }

    .message-cta-button {
        padding: 0.65rem 1.25rem;
        font-size: 0.875rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {

    .chatbot-toggle,
    .chatbot-window,
    .chatbot-message,
    .chatbot-close,
    .chatbot-send {
        animation: none !important;
        transition: none !important;
    }

    .typing-dot {
        animation: none !important;
    }
}

/* Focus States */
.chatbot-toggle:focus-visible,
.chatbot-close:focus-visible,
.chatbot-send:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}