/* Help AI Chat Widget Styles */
.help-chat-widget {
    position: fixed;
    bottom: max(24px, env(safe-area-inset-bottom));
    right: max(24px, env(safe-area-inset-right));
    z-index: 1050;
    font-family: inherit;
}

/* Floating Launcher Button */
.help-chat-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35), 0 2px 6px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    user-select: none;
}

.help-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45), 0 4px 10px rgba(15, 23, 42, 0.12);
}

.help-chat-launcher:active {
    transform: translateY(0);
}

.help-chat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.help-chat-launcher-label {
    letter-spacing: 0.01em;
}

.help-chat-pulse {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.4);
    animation: helpPulse 2s infinite ease-in-out;
}

@keyframes helpPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
}

/* Chat Window Panel */
.help-chat-panel {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 100px);
    max-height: calc(100dvh - 48px);
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 16px 40px -8px rgba(15, 23, 42, 0.2), 0 6px 16px -4px rgba(15, 23, 42, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.help-chat-panel.hidden {
    display: none !important;
}

/* Header */
.help-chat-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.help-chat-header-info {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-chat-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.help-chat-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
}

.help-chat-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

.help-chat-status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
}

.help-chat-header-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-chat-action-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    border: none;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.help-chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Messages Log */
.help-chat-messages {
    position: relative;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.help-chat-msg {
    flex-shrink: 0;
    min-width: 0;
    max-width: 86%;
    font-size: 0.88rem;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.help-chat-msg-user {
    align-self: flex-end;
    background: #2563eb;
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 14px 14px 3px 14px;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.15);
}

.help-chat-msg-assistant {
    align-self: flex-start;
    background: #ffffff;
    color: #1e293b;
    padding: 12px 14px;
    border-radius: 14px 14px 14px 3px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.help-chat-msg-assistant p {
    margin: 0 0 8px 0;
}

.help-chat-msg-assistant p:last-child {
    margin-bottom: 0;
}

.help-chat-msg-assistant ul, .help-chat-msg-assistant ol {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}

.help-chat-msg-assistant li {
    margin-bottom: 4px;
}

.help-chat-msg-assistant strong {
    font-weight: 600;
    color: #0f172a;
}

.help-chat-msg-assistant code {
    background: #f1f5f9;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.82em;
    color: #0369a1;
}

.help-chat-msg-assistant a {
    color: #2563eb;
    text-decoration: underline;
}

/* Typing Indicator */
.help-chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.help-chat-typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.help-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.help-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Quick Suggestion Chips */
.help-chat-suggestions {
    flex-shrink: 0;
    min-width: 0;
    padding: 8px 14px 10px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
}

.help-chat-suggestions-title {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    margin-bottom: 6px;
}

.help-chat-chips-scroll {
    min-width: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
}

.help-chip {
    flex-shrink: 0;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.help-chip:hover {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #bae6fd;
}

/* Input Form */
.help-chat-form {
    flex-shrink: 0;
    min-width: 0;
    padding: 10px 14px 8px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.help-chat-input-wrapper {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 6px 8px 6px 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.help-chat-input-wrapper:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background: #ffffff;
}

.help-chat-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 4px 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.88rem;
    font-family: inherit;
    color: #0f172a;
    resize: none;
    line-height: 1.4;
    max-height: 80px;
}

.help-chat-input::placeholder {
    color: #94a3b8;
}

.help-chat-send-btn {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
    flex-shrink: 0;
}

.help-chat-send-btn:hover:not(:disabled) {
    background: #1d4ed8;
}

.help-chat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.7;
}

.help-chat-disclaimer {
    margin-top: 6px;
    text-align: center;
    font-size: 0.68rem;
    color: #94a3b8;
}

/* Mobile Responsiveness */
@media (max-width: 600px), (max-width: 900px) and (max-height: 500px) {
    .help-chat-widget {
        bottom: max(16px, env(safe-area-inset-bottom));
        right: max(16px, env(safe-area-inset-right));
    }

    .help-chat-panel {
        position: fixed;
        top: calc(var(--help-viewport-top, 0px) + max(8px, env(safe-area-inset-top)));
        left: max(8px, env(safe-area-inset-left));
        right: max(8px, env(safe-area-inset-right));
        bottom: auto;
        width: auto;
        max-width: none;
        height: calc(var(--help-viewport-height, 100vh) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        height: calc(var(--help-viewport-height, 100dvh) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        max-height: none;
        border-radius: 16px;
    }

    .help-chat-header { padding: 10px; gap: 8px; }
    .help-chat-header-info { gap: 8px; }
    .help-chat-header-info > div:last-child { min-width: 0; }
    .help-chat-avatar { width: 30px; height: 30px; }
    .help-chat-subtitle { font-size: 11px; line-height: 1.4; }
    .help-chat-status-dot { flex-shrink: 0; }
    .help-chat-header-actions { gap: 4px; }
    .help-chat-action-btn, .help-chat-send-btn { width: 44px; height: 44px; }
    .help-chat-stop { min-height: 44px; }
    .help-chat-messages { padding: 12px; }
    .help-chat-msg { max-width: 94%; font-size: 14px; }
    .help-chat-suggestions { padding: 8px 10px; }
    .help-chip { min-height: 44px; }
    .help-chat-form { padding: 8px 10px; }
    .help-chat-input-wrapper { padding: 4px 6px 4px 10px; }
    .help-chat-input { font-size: 16px; }
    .help-chat-keyboard-open .help-chat-suggestions,
    .help-chat-keyboard-open .help-chat-disclaimer { display: none; }
}

@media (max-height: 480px) {
    .help-chat-suggestions-title, .help-chat-disclaimer { display: none; }
    .help-chat-header { padding-block: 6px; }
    .help-chat-suggestions { padding-block: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .help-chat-panel, .help-chat-launcher { transition: none; }
    .help-chat-messages { scroll-behavior: auto; }
    .help-chat-pulse, .help-chat-typing span { animation: none; }
}

.help-chat-stop{align-self:center;flex-shrink:0;border:1px solid #cbd5e1;border-radius:8px;background:#fff;color:#334155;padding:8px 10px;font-size:12px;font-weight:600}.help-chat-stop:hover{background:#f1f5f9}.help-chat-stop[hidden],.help-chat-send-btn[hidden]{display:none}

.help-agent-draft-form{flex-shrink:0;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:9px 16px;border-top:1px solid #e2e8f0;background:#fff}.help-agent-draft-form small{font-size:10px;color:#64748b}.help-agent-draft-form .text-button{font-size:12px}.help-agent-card{max-width:720px;margin-inline:auto}
@media(max-width:380px){.help-agent-draft-form{flex-wrap:wrap;gap:2px}}
