/**
 * Ask Musick — Chat Widget Styles
 * Floating chat bubble + panel, dark/light mode aware
 */

/* Trigger Button */
.chatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8338EC, #FF006E);
    border: none;
    cursor: pointer;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(131, 56, 236, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(131, 56, 236, 0.5);
}

.chatbot-trigger svg {
    width: 26px;
    height: 26px;
    fill: white;
    transition: opacity 0.2s;
}

.chatbot-trigger .chatbot-close-icon {
    display: none;
}

.chatbot-trigger.active .chatbot-open-icon {
    display: none;
}

.chatbot-trigger.active .chatbot-close-icon {
    display: block;
}

/* Chat Panel */
.chatbot-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: var(--card-bg, #1a1a2e);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.4);
    z-index: 9991;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.25s ease;
    overflow: hidden;
}

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

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #8338EC, #FF006E);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-header-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.chatbot-header-text h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

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

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 340px;
    scroll-behavior: smooth;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(131, 56, 236, 0.3);
    border-radius: 4px;
}

/* Message Bubbles */
.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-msg.bot {
    background: rgba(131, 56, 236, 0.12);
    border: 1px solid rgba(131, 56, 236, 0.2);
    color: var(--text-color, #e0e0e0);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chatbot-msg.user {
    background: linear-gradient(135deg, #8338EC, #FF006E);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Markdown in bot messages */
.chatbot-msg.bot a {
    color: #a78bfa;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chatbot-msg.bot a:hover {
    color: #c4b5fd;
}

.chatbot-msg.bot strong {
    color: var(--text-color, white);
    font-weight: 600;
}

.chatbot-msg.bot ul,
.chatbot-msg.bot ol {
    margin: 6px 0;
    padding-left: 18px;
}

.chatbot-msg.bot li {
    margin-bottom: 4px;
}

.chatbot-msg.bot p {
    margin: 0 0 6px;
}

.chatbot-msg.bot p:last-child {
    margin-bottom: 0;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    align-self: flex-start;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    background: rgba(131, 56, 236, 0.5);
    border-radius: 50%;
    animation: chatTyping 1.2s ease-in-out infinite;
}

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

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

@keyframes chatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Suggested Questions */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.chatbot-suggestion {
    padding: 6px 12px;
    background: rgba(131, 56, 236, 0.1);
    border: 1px solid rgba(131, 56, 236, 0.25);
    border-radius: 20px;
    color: #a78bfa;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.chatbot-suggestion:hover {
    background: rgba(131, 56, 236, 0.2);
    border-color: rgba(131, 56, 236, 0.4);
}

/* Input Area */
.chatbot-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.chatbot-input input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 10px 16px;
    color: var(--text-color, #e0e0e0);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.chatbot-input input:focus {
    border-color: rgba(131, 56, 236, 0.5);
}

.chatbot-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8338EC, #FF006E);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}

.chatbot-input button:hover {
    transform: scale(1.05);
}

.chatbot-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-input button svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Light Mode */
[data-theme="light"] .chatbot-panel {
    background: #ffffff;
    border-color: #e0e0e0;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .chatbot-msg.bot {
    background: rgba(131, 56, 236, 0.06);
    border-color: rgba(131, 56, 236, 0.15);
    color: #333;
}

[data-theme="light"] .chatbot-msg.bot a {
    color: #7c3aed;
}

[data-theme="light"] .chatbot-msg.bot strong {
    color: #111;
}

[data-theme="light"] .chatbot-input input {
    background: #f5f5f5;
    border-color: #ddd;
    color: #333;
}

[data-theme="light"] .chatbot-input input::placeholder {
    color: #999;
}

[data-theme="light"] .chatbot-suggestion {
    background: rgba(131, 56, 236, 0.05);
    border-color: rgba(131, 56, 236, 0.2);
    color: #7c3aed;
}

[data-theme="light"] .chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(131, 56, 236, 0.2);
}

/* Mobile */
@media (max-width: 480px) {
    .chatbot-trigger {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .chatbot-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
    }

    .chatbot-messages {
        max-height: calc(85vh - 200px);
    }
}

/* Push theme toggle above chatbot on mobile (this CSS only loads when chatbot is enabled) */
@media (max-width: 768px) {
    .theme-toggle {
        bottom: 90px !important;
    }
}

/* Hide when cookie consent is showing */
.cookie-consent[style*="display: block"] ~ .chatbot-trigger {
    bottom: 100px;
}
