/* Simple Chatbot Widget */

/* Screen-reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chatbot-trigger {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #605cfd, #4c49d8);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(96, 92, 253, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chatbot-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(96, 92, 253, 0.6);
}

.chatbot-trigger i {
    color: white;
    font-size: 28px;
}

.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 32px;
    width: 380px;
    max-width: calc(100% - 40px);
    height: 600px;
    max-height: calc(100% - 120px);
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

.chatbot-header {
    background: linear-gradient(135deg, #605cfd, #4c49d8);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #605cfd;
}

.chatbot-info h3 {
    color: white;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.chatbot-info p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    margin: 0;
}

.chatbot-status {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    margin-left: 6px;
    display: inline-block;
}

.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #0a0a0a;
    scroll-behavior: smooth;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-out forwards;
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
    min-height: 20px !important;
    flex-shrink: 0;
}

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

.message.bot {
    background: #1e1e1e !important;
    color: #e5e5e5 !important;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.user {
    background: #605cfd !important;
    color: white !important;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.typing-indicator {
    padding: 12px 16px;
    background: #1e1e1e;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    display: flex;
    gap: 4px;
    width: fit-content;
}

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

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.chatbot-input-area {
    padding: 16px;
    background: #1e1e1e;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 10px;
}

.chatbot-input {
    flex: 1;
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: #605cfd;
}

.chatbot-send {
    width: 40px;
    height: 40px;
    background: #605cfd;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-send:hover {
    background: #4c49d8;
}

/* Markdown inside bot messages */
.message.bot ul {
    margin: 6px 0 6px 16px;
    padding: 0;
    list-style: disc;
}
.message.bot li {
    margin: 2px 0;
}
.message.bot code {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 13px;
}
.message.bot pre {
    background: rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 6px 0;
}
.message.bot pre code {
    background: none;
    padding: 0;
}
.message.bot strong { font-weight: 700; }
.message.bot em     { font-style: italic; }
.message.bot .chat-link {
    color: #a5a2ff;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
.message.bot .chat-link:hover { color: #fff; }

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}
.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Mobile: full-screen chat */
@media (max-width: 639px) {
    .chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        /* Support notch/home bar */
        padding-bottom: env(safe-area-inset-bottom);
    }

    .chatbot-trigger {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .chatbot-trigger i {
        font-size: 24px;
    }

    /* Prevent iOS auto-zoom on input focus */
    .chatbot-input {
        font-size: 16px;
    }

    .chatbot-window.visible {
        transform: translateY(0) scale(1);
    }

    .chatbot-window:not(.visible) {
        transform: translateY(100%);
        opacity: 0;
    }
}
