/* ========================================
   BPecom AI — Full Chat Panel (Dark Theme)
   ======================================== */

:root {
    --bot-bg-primary: #ffffff;
    --bot-bg-secondary: #f8fafc;
    --bot-bg-card: #f1f5f9;
    --bot-bg-input: #f1f5f9;
    --bot-bg-hover: #e2e8f0;
    --bot-accent: #2563eb;
    --bot-accent-light: #3b82f6;
    --bot-accent-glow: rgba(37, 99, 235, 0.2);
    --bot-highlight: #1d4ed8;
    --bot-text-primary: #1e293b;
    --bot-text-secondary: #475569;
    --bot-text-muted: #94a3b8;
    --bot-success: #22c55e;
    --bot-error: #ef4444;
    --bot-warning: #f59e0b;
    --bot-border: #e2e8f0;
    --bot-border-light: #cbd5e1;
    --bot-code-bg: #f1f5f9;
    --bot-user-bubble: #2563eb;
    --bot-bot-bubble: #f1f5f9;
    --bot-radius: 16px;
    --bot-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* ---- Trigger Button ---- */
.bot-trigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 24px var(--bot-accent-glow), 0 0 60px rgba(37, 99, 235, 0.15);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 32px var(--bot-accent-glow), 0 0 80px rgba(37, 99, 235, 0.2);
}

.bot-trigger svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform 0.3s ease;
}

.bot-trigger.active svg {
    transform: rotate(90deg);
}

/* Pulse animation when bot is ready */
.bot-trigger::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    opacity: 0;
    z-index: -1;
    animation: botPulse 2s infinite;
}

@keyframes botPulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* ---- Chat Panel (Full Side Panel) ---- */
.bot-panel {
    position: fixed;
    top: 0;
    right: -480px;
    width: 460px;
    height: 100vh;
    background: var(--bot-bg-primary);
    border-left: 1px solid var(--bot-border);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: var(--bot-font);
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.08);
}

.bot-panel.open {
    right: 0;
}

/* Backdrop overlay */
.bot-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.bot-backdrop.visible {
    opacity: 1;
    pointer-events: all;
}

/* ---- Header ---- */
.bot-header {
    padding: 16px 20px;
    background: var(--bot-bg-secondary);
    border-bottom: 1px solid var(--bot-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.bot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bot-avatar svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.bot-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--bot-text-primary);
    line-height: 1.2;
}

.bot-header-status {
    font-size: 12px;
    color: var(--bot-text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.bot-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bot-error);
    transition: background 0.3s;
}

.bot-status-dot.online {
    background: var(--bot-success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.bot-header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.bot-header-btn {
    background: none;
    border: none;
    color: var(--bot-text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.bot-header-btn:hover {
    background: var(--bot-bg-hover);
    color: var(--bot-text-primary);
}

.bot-header-btn.muted {
    color: var(--bot-error);
}

/* ---- Marketplace Tabs ---- */
.bot-marketplace-tabs {
    display: flex;
    background: var(--bot-bg-secondary);
    border-bottom: 1px solid var(--bot-border);
    padding: 0 16px;
    flex-shrink: 0;
}

.bot-mp-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--bot-text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.bot-mp-tab:hover {
    color: var(--bot-text-secondary);
}

.bot-mp-tab.active {
    color: var(--bot-accent-light);
    border-bottom-color: var(--bot-accent);
}

/* ---- Messages Area ---- */
.bot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.bot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.bot-messages::-webkit-scrollbar-thumb {
    background: var(--bot-border);
    border-radius: 3px;
}

.bot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--bot-border-light);
}

/* ---- Message Bubbles ---- */
.bot-msg-wrapper {
    display: flex;
    flex-direction: column;
    animation: botMsgIn 0.3s ease-out;
}

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

.bot-msg-wrapper.user {
    align-items: flex-end;
}

.bot-msg-wrapper.assistant {
    align-items: flex-start;
}

.bot-msg-label {
    font-size: 11px;
    color: var(--bot-text-muted);
    margin-bottom: 4px;
    padding: 0 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bot-msg {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: var(--bot-radius);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
}

.bot-msg.user {
    background: var(--bot-user-bubble);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.bot-msg.assistant {
    background: var(--bot-bot-bubble);
    color: var(--bot-text-primary);
    border-bottom-left-radius: 6px;
    border: 1px solid #dbe4f0;
}

.bot-msg.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--bot-error);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-bottom-left-radius: 6px;
    font-size: 13px;
}

/* Markdown-like formatting in bot messages */
.bot-msg.assistant strong,
.bot-msg.assistant b {
    color: var(--bot-accent-light);
    font-weight: 600;
}

.bot-msg code {
    background: var(--bot-code-bg);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 13px;
    font-family: 'Fira Code', 'SF Mono', 'Consolas', monospace;
    border: 1px solid var(--bot-border);
}

.bot-msg pre {
    background: var(--bot-code-bg);
    padding: 12px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
    border: 1px solid var(--bot-border);
    line-height: 1.5;
}

.bot-msg pre code {
    background: none;
    border: none;
    padding: 0;
}

/* Speaker button on bot messages */
.bot-msg-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.bot-msg-wrapper:hover .bot-msg-actions {
    opacity: 1;
}

.bot-msg-speak-btn,
.bot-msg-copy-btn {
    background: var(--bot-bg-hover);
    border: 1px solid var(--bot-border);
    border-radius: 6px;
    color: var(--bot-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    transition: color 0.15s, background 0.15s;
}

.bot-msg-speak-btn:hover,
.bot-msg-copy-btn:hover {
    background: var(--bot-border);
    color: var(--bot-text-primary);
}

/* ---- Typing Indicator ---- */
.bot-typing {
    display: none;
    align-items: center;
    gap: 3px;
    padding: 12px 16px;
    background: var(--bot-bot-bubble);
    border: 1px solid var(--bot-border);
    border-radius: var(--bot-radius);
    border-bottom-left-radius: 6px;
    align-self: flex-start;
    max-width: 80px;
}

.bot-typing.visible {
    display: flex;
    animation: botMsgIn 0.3s ease-out;
}

.bot-typing span {
    width: 8px;
    height: 8px;
    background: var(--bot-accent);
    border-radius: 50%;
    animation: botTypingBounce 1.4s infinite ease-in-out;
}

.bot-typing span:nth-child(1) { animation-delay: 0s; }
.bot-typing span:nth-child(2) { animation-delay: 0.2s; }
.bot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes botTypingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ---- Welcome / Intro ---- */
.bot-intro-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    animation: botMsgIn 0.5s ease-out;
}

.bot-intro-avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    box-shadow: 0 4px 16px var(--bot-accent-glow);
}

.bot-intro-avatar svg {
    width: 26px;
    height: 26px;
    fill: white;
}

.bot-intro-text {
    background: var(--bot-bot-bubble);
    border: 1px solid var(--bot-border);
    border-radius: var(--bot-radius);
    border-bottom-left-radius: 6px;
    padding: 16px 20px;
    color: var(--bot-text-primary);
    font-size: 14px;
    line-height: 1.6;
    max-width: 90%;
}

.bot-intro-text h4 {
    margin: 0 0 6px 0;
    color: var(--bot-accent-light);
    font-size: 16px;
}

/* Quick action suggestions */
.bot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    animation: botMsgIn 0.5s ease-out 0.3s both;
}

.bot-suggestion {
    padding: 8px 14px;
    background: var(--bot-bg-card);
    border: 1px solid var(--bot-border);
    border-radius: 20px;
    color: var(--bot-text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--bot-font);
}

.bot-suggestion:hover {
    border-color: var(--bot-accent);
    color: var(--bot-accent-light);
    background: rgba(37, 99, 235, 0.06);
}

/* ---- Input Area ---- */
.bot-input-area {
    padding: 16px 20px;
    background: var(--bot-bg-secondary);
    border-top: 1px solid var(--bot-border);
    flex-shrink: 0;
}

.bot-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bot-bg-input);
    border: 1px solid var(--bot-border);
    border-radius: 14px;
    padding: 6px 6px 6px 16px;
    transition: border-color 0.2s;
}

.bot-input-row:focus-within {
    border-color: var(--bot-accent);
    box-shadow: 0 0 0 3px var(--bot-accent-glow);
}

.bot-input {
    flex: 1;
    padding: 10px 0;
    background: transparent;
    border: none;
    color: var(--bot-text-primary);
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 100px;
    min-height: 20px;
    font-family: var(--bot-font);
    line-height: 1.5;
}

.bot-input::placeholder {
    color: var(--bot-text-muted);
}

.bot-send {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bot-accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
}

.bot-send:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.bot-send:disabled {
    background: var(--bot-border);
    cursor: not-allowed;
    transform: none;
}

.bot-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Powered by line */
.bot-powered {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: var(--bot-text-muted);
    background: var(--bot-bg-secondary);
}

.bot-powered a {
    color: var(--bot-accent-light);
    text-decoration: none;
}

/* ---- Responsive ---- */
@media (max-width: 520px) {
    .bot-panel {
        width: 100vw;
        right: -100vw;
    }

    .bot-panel.open {
        right: 0;
    }

    .bot-trigger {
        bottom: 20px;
        right: 20px;
        width: 52px;
        height: 52px;
    }
}

/* ---- Utility ---- */
.bot-hidden {
    display: none !important;
}
