/* ===== AI Support Chat Widget ===== */

/* Shimmer animation for premium feel */
@keyframes supportBtnShimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* Subtle glow pulse */
@keyframes supportBtnGlow {
    0%, 100% { box-shadow: 0 4px 14px rgba(196, 136, 42, 0.25), 0 1px 4px rgba(0,0,0,0.12); }
    50%      { box-shadow: 0 4px 20px rgba(212, 168, 83, 0.35), 0 1px 4px rgba(0,0,0,0.12); }
}

/* Floating button */
.support-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    height: 52px;
    padding: 0 20px 0 16px;
    gap: 8px;
    border-radius: 26px;
    background: linear-gradient(135deg, #c4882a 0%, #d4a853 50%, #c4882a 100%);
    color: #fff;
    border: 1px solid rgba(255, 215, 160, 0.3);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(196, 136, 42, 0.25), 0 1px 4px rgba(0,0,0,0.12);
    z-index: 9991;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
    animation: supportBtnGlow 3s ease-in-out infinite;
    overflow: hidden;
}

/* Shimmer overlay via pseudo-element */
.support-chat-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    background: linear-gradient(
        110deg,
        transparent 20%,
        rgba(255, 255, 255, 0.15) 40%,
        rgba(255, 255, 255, 0.25) 50%,
        rgba(255, 255, 255, 0.15) 60%,
        transparent 80%
    );
    background-size: 200% 100%;
    animation: supportBtnShimmer 4s ease-in-out infinite;
    pointer-events: none;
}

.support-chat-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 24px rgba(196, 136, 42, 0.4), 0 2px 6px rgba(0,0,0,0.15);
}
.support-chat-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}
.support-chat-btn-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
    text-transform: none; /* override global `button { text-transform: uppercase }` so it reads "Hey RemoraAI" */
}

/* Light-mode refinement: slightly deeper gradient for contrast on bright backgrounds */
[data-theme="light"] .support-chat-btn {
    background: linear-gradient(135deg, #b07a22 0%, #d4a853 50%, #b07a22 100%);
    border-color: rgba(180, 130, 40, 0.3);
    box-shadow: 0 4px 14px rgba(176, 122, 34, 0.3), 0 1px 4px rgba(0,0,0,0.08);
}
[data-theme="light"] .support-chat-btn:hover {
    box-shadow: 0 6px 24px rgba(176, 122, 34, 0.45), 0 2px 6px rgba(0,0,0,0.1);
}

/* Chat panel */
.support-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-default, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 9990;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.support-chat-panel.open {
    display: flex;
}

/* Header */
.support-chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-default, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary, #f8fafc);
}
.support-chat-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}

/* Close button */
.support-chat-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    font-size: 18px;
    padding: 4px;
    line-height: 1;
}
.support-chat-close-btn:hover {
    color: var(--text-primary, #1a1a2e);
}

/* Messages area */
.support-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: min(300px, 50vh);
    max-height: 360px;
}

/* Message bubbles */
.support-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.support-msg--user {
    align-self: flex-end;
    background: var(--accent-primary, #5b94b8);
    color: white;
    border-bottom-right-radius: 4px;
}
.support-msg--assistant {
    align-self: flex-start;
    background: var(--bg-secondary, #f1f5f9);
    color: var(--text-primary, #1a1a2e);
    border-bottom-left-radius: 4px;
}
.support-msg--tool {
    align-self: flex-start;
    background: var(--bg-hover, #e2e8f0);
    color: var(--text-secondary, #64748b);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 8px;
    font-style: italic;
}
.support-msg--error {
    align-self: flex-start;
    background: rgba(239, 68, 68, 0.1);
    color: var(--red, #ef4444);
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
}

/* Typing indicator */
.support-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 14px;
    background: var(--bg-secondary, #f1f5f9);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}
.support-typing.active { display: block; }
.support-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary, #94a3b8);
    margin: 0 1px;
    animation: supportTyping 1.4s infinite;
}
.support-typing span:nth-child(2) { animation-delay: 0.2s; }
.support-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes supportTyping {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Input area */
.support-chat-input {
    padding: 12px 16px;
    border-top: 1px solid var(--border-default, #e2e8f0);
    display: flex;
    gap: 8px;
    background: var(--bg-primary, #ffffff);
}
.support-chat-input textarea {
    flex: 1;
    border: 1px solid var(--border-default, #e2e8f0);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1a1a2e);
    font-family: inherit;
    max-height: 80px;
    min-height: 36px;
}
.support-chat-input textarea:focus {
    outline: none;
    border-color: var(--accent-primary, #5b94b8);
}
.support-chat-input button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--accent-primary, #5b94b8);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.support-chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Markdown rendering in assistant messages */
.support-msg--assistant strong { font-weight: 600; }
.support-msg--assistant em { font-style: italic; }
.support-msg--assistant code {
    background: rgba(255,255,255,0.08);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}
.support-msg--assistant ul,
.support-msg--assistant ol {
    margin: 4px 0;
    padding-left: 18px;
}
.support-msg--assistant li {
    margin: 2px 0;
}
.support-msg--assistant p {
    margin: 0;
}
.support-msg--assistant p + p {
    margin-top: 8px;
}
.support-md-h1, .support-md-h2, .support-md-h3 {
    display: block;
    margin-top: 8px;
    margin-bottom: 2px;
}
.support-md-h1 { font-size: 16px; }
.support-md-h2 { font-size: 15px; }
.support-md-h3 { font-size: 14px; }

/* Mobile responsive */
@media (max-width: 480px) {
    .support-chat-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        max-height: calc(100dvh - 120px);
    }
}
