/**
 * User Guide Chatbot Widget - floating widget at bottom of page
 * Uses bot image from image/bot.png
 * Theme: matches page dark teal (primary #9de0d6, secondary #1c8b7a)
 */

.userguide-chatbot-widget {
    --ug-primary: #9de0d6;
    --ug-secondary: #1c8b7a;
    --ug-accent: #45ebd1;
    --ug-bg-dark: #0a1614;
}

@keyframes userguide-bot-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes userguide-bot-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.04); opacity: 0.98; }
}

@keyframes userguide-label-in {
    0% { opacity: 0; transform: translateY(-6px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes userguide-label-glow {
    0%, 100% { box-shadow: 0 2px 10px rgba(28, 139, 122, 0.4); }
    50% { box-shadow: 0 3px 14px rgba(69, 235, 209, 0.5); }
}

.userguide-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    font-family: 'Outfit', 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
}

.userguide-chatbot-label {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 5px 12px 8px;
    margin-bottom: -2px;
    background: linear-gradient(180deg, var(--ug-secondary) 0%, #145a4f 100%);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 10px 10px 4px 4px;
    box-shadow: 0 2px 10px rgba(28, 139, 122, 0.4);
    animation: userguide-label-in 0.4s ease-out 0.2s both, userguide-label-glow 2.5s ease-in-out 1s infinite;
    text-align: center;
    white-space: nowrap;
}

.userguide-chatbot-label::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    margin-left: -4px;
    border: 4px solid transparent;
    border-top-color: var(--ug-secondary);
}

.userguide-chatbot-label-line {
    display: block;
}

.userguide-chatbot-label-line:first-child {
    font-size: 0.68rem;
    font-weight: 500;
    opacity: 0.92;
    letter-spacing: 0.02em;
}

.userguide-chatbot-widget.window-open .userguide-chatbot-label {
    animation: none;
}

.userguide-chatbot-widget.window-open .userguide-chatbot-toggle {
    display: none;
}

.userguide-chatbot-toggle {
    width: auto;
    height: auto;
    min-width: 120px;
    border-radius: 0;
    border: none;
    padding: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: visible;
    animation: userguide-bot-float 2.5s ease-in-out infinite;
}

.userguide-chatbot-widget.window-open .userguide-chatbot-toggle {
    animation: none;
}

.userguide-chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.userguide-chatbot-toggle img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    display: block;
    animation: userguide-bot-pulse 2.2s ease-in-out infinite;
}

.userguide-chatbot-widget.window-open .userguide-chatbot-toggle img {
    animation: none;
}

.userguide-chatbot-window {
    position: absolute;
    bottom: 20px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 24px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.96);
    transition: opacity 0.25s, visibility 0.25s, transform 0.25s;
}

.userguide-chatbot-widget.window-open .userguide-chatbot-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-window {
    height: auto;
    min-height: 0;
    width: 280px;
    max-width: calc(100vw - 24px);
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-messages,
.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-suggestions,
.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-input-wrapper,
.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-typing {
    display: none;
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-header {
    cursor: pointer;
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-header {
    padding: 8px 12px;
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-avatar {
    width: 32px;
    height: 32px;
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-header-text h3 {
    font-size: 0.9rem;
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-header-text p {
    display: none;
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-minimize,
.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-close {
    width: 28px;
    height: 28px;
}

.userguide-chatbot-widget.window-open.window-minimized .userguide-chatbot-header-content {
    gap: 8px;
}

.userguide-chatbot-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--ug-secondary) 0%, #145a4f 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    cursor: pointer;
}

.userguide-chatbot-widget:not(.window-minimized) .userguide-chatbot-header {
    cursor: default;
}

.userguide-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.userguide-chatbot-minimize {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.userguide-chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}


.userguide-chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.userguide-chatbot-avatar {
    width: 52px;
    height: 52px;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
    flex-shrink: 0;
}

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

.userguide-chatbot-header-text h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.userguide-chatbot-header-text p {
    margin: 2px 0 0;
    font-size: 0.75rem;
    opacity: 0.9;
}

.userguide-chatbot-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.userguide-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.userguide-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

.userguide-chatbot-message {
    display: flex;
    gap: 10px;
    max-width: 90%;
    align-self: flex-start;
}

.userguide-chatbot-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.userguide-chatbot-message .message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 0;
    overflow: hidden;
    flex-shrink: 0;
    background: transparent;
}

.userguide-chatbot-message .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.userguide-chatbot-message.user .message-avatar {
    background: var(--ug-secondary);
}

.userguide-chatbot-message.user .message-avatar img {
    display: none;
}

.userguide-chatbot-message.user .message-avatar::after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E") center/14px no-repeat;
}

.userguide-chatbot-message .message-content {
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.45;
}

.userguide-chatbot-message.bot .message-content {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #334155;
}

.userguide-chatbot-message.user .message-content {
    background: var(--ug-secondary);
    color: #fff;
}

.userguide-chatbot-message .message-content p {
    margin: 0 0 6px;
}

.userguide-chatbot-message .message-content p:last-child {
    margin-bottom: 0;
}

.userguide-chatbot-message .message-content ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

.userguide-chatbot-message .message-content a {
    color: var(--ug-secondary);
    text-decoration: underline;
}

.userguide-chatbot-message.user .message-content a {
    color: rgba(255, 255, 255, 0.95);
}

.userguide-chatbot-suggestions {
    padding: 8px 12px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    transition: opacity 0.2s, max-height 0.2s;
}

.userguide-chatbot-suggestions.userguide-suggestions-hidden {
    display: none;
}

.userguide-suggestion-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    color: #475569;
    transition: background 0.2s, border-color 0.2s;
}

.userguide-suggestion-btn:hover {
    background: rgba(157, 224, 214, 0.12);
    border-color: var(--ug-primary);
}

.userguide-chatbot-input-wrapper {
    padding: 10px 12px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.userguide-chatbot-input-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.userguide-chatbot-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.875rem;
    resize: none;
    min-height: 42px;
    max-height: 80px;
    box-sizing: border-box;
}

.userguide-chatbot-input:focus {
    outline: none;
    border-color: var(--ug-secondary);
    box-shadow: 0 0 0 2px rgba(28, 139, 122, 0.25);
}

.userguide-chatbot-char-count {
    font-size: 0.7rem;
    color: #94a3b8;
}

.userguide-chatbot-char-count.at-limit {
    color: #dc2626;
}

.userguide-chatbot-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: var(--ug-primary);
    color: var(--ug-bg-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.userguide-chatbot-send:hover:not(:disabled) {
    background: var(--ug-accent);
    color: var(--ug-bg-dark);
}

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

.userguide-chatbot-typing {
    padding: 8px 12px;
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #64748b;
    flex-shrink: 0;
}

.userguide-chatbot-typing.active {
    display: flex;
}

.userguide-typing-dots {
    display: flex;
    gap: 4px;
}

.userguide-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: userguide-typing-bounce 1.4s ease-in-out infinite both;
}

.userguide-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.userguide-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes userguide-typing-bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 480px) {
    .userguide-chatbot-widget {
        bottom: 12px;
        right: 12px;
    }

    .userguide-chatbot-window {
        width: calc(100vw - 24px);
        right: -4px;
        bottom: 12px;
    }
}
