/* ==============================================================================
   Brain Box AI Support & Action Agent Stylesheet
   AegisCore Dark Cyber Aesthetic (Cyan #00f0ff, Emerald #10b981, Dark #060911)
   ============================================================================== */

:root {
    --bb-primary: #00f0ff;
    --bb-primary-glow: rgba(0, 240, 255, 0.35);
    --bb-secondary: #10b981;
    --bb-bg-dark: #060911;
    --bb-bg-panel: #0b1222;
    --bb-bg-card: #0f1a30;
    --bb-border: rgba(0, 240, 255, 0.2);
    --bb-border-subtle: rgba(255, 255, 255, 0.08);
    --bb-text-main: #f8fafc;
    --bb-text-muted: #94a3b8;
    --bb-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --bb-font-mono: 'JetBrains Mono', monospace;
    --bb-radius-lg: 16px;
    --bb-radius-md: 10px;
    --bb-radius-sm: 6px;
    --bb-shadow: 0 12px 40px rgba(0, 0, 0, 0.65), 0 0 20px rgba(0, 240, 255, 0.15);
}

/* Launcher Floating Button */
#brainbox-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0b1329, #060911);
    border: 2px solid var(--bb-primary);
    box-shadow: 0 4px 20px var(--bb-primary-glow), 0 0 10px rgba(0, 240, 255, 0.4);
    cursor: pointer;
    z-index: 999990;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bb-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    user-select: none;
}

#brainbox-launcher:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 240, 255, 0.55), 0 0 15px rgba(0, 240, 255, 0.6);
    border-color: #fff;
}

#brainbox-launcher .bb-launcher-icon {
    width: 30px;
    height: 30px;
    transition: transform 0.3s ease;
}

#brainbox-launcher .bb-close-icon {
    display: none;
    width: 24px;
    height: 24px;
}

#brainbox-launcher.bb-active .bb-launcher-icon {
    display: none;
}

#brainbox-launcher.bb-active .bb-close-icon {
    display: block;
}

/* Pulsing Badge / Pulse Ring */
.bb-pulse-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid var(--bb-primary);
    animation: bbPulse 2.5s infinite;
    pointer-events: none;
    opacity: 0.7;
}

@keyframes bbPulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.22); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

/* Chat Panel */
#brainbox-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--bb-bg-panel);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-lg);
    box-shadow: var(--bb-shadow);
    z-index: 999991;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--bb-font);
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.25s ease;
    backdrop-filter: blur(16px);
}

#brainbox-panel.bb-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
.bb-header {
    background: #080e1e;
    padding: 14px 18px;
    border-bottom: 1px solid var(--bb-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.bb-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bb-avatar {
    width: 36px;
    height: 36px;
    background: rgba(0, 240, 255, 0.12);
    border: 1.5px solid var(--bb-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bb-primary);
}

.bb-header-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bb-status-dot {
    width: 7px;
    height: 7px;
    background: var(--bb-secondary);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--bb-secondary);
}

.bb-header-sub {
    font-size: 0.72rem;
    color: var(--bb-primary);
    font-weight: 600;
    letter-spacing: 0.03em;
}

.bb-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bb-btn-icon {
    background: none;
    border: none;
    color: var(--bb-text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bb-btn-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* Messages Container */
.bb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: radial-gradient(circle at top right, rgba(0, 240, 255, 0.03), transparent 60%);
    scroll-behavior: smooth;
}

.bb-messages::-webkit-scrollbar {
    width: 5px;
}

.bb-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.2);
    border-radius: 4px;
}

/* Message Bubbles */
.bb-msg {
    max-width: 85%;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
    animation: bbFadeIn 0.2s ease-out forwards;
}

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

.bb-msg.bb-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.25), rgba(16, 185, 129, 0.2));
    border: 1px solid rgba(0, 240, 255, 0.4);
    color: #fff;
    border-radius: 14px 14px 2px 14px;
    padding: 10px 14px;
}

.bb-msg.bb-msg-assistant {
    align-self: flex-start;
    background: var(--bb-bg-card);
    border: 1px solid var(--bb-border-subtle);
    color: #e2e8f0;
    border-radius: 14px 14px 14px 2px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.bb-msg.bb-msg-assistant strong {
    color: #fff;
}

.bb-msg.bb-msg-assistant a {
    color: var(--bb-primary);
    text-decoration: underline;
}

.bb-msg-time {
    font-size: 0.68rem;
    color: var(--bb-text-muted);
    margin-top: 4px;
    text-align: right;
}

/* Cards Inside Messages */
.bb-card {
    background: #080f20;
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-md);
    padding: 12px 14px;
    margin-top: 8px;
}

.bb-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bb-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.bb-badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.bb-badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.bb-card-price {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--bb-primary);
    margin: 6px 0;
}

.bb-card-desc {
    font-size: 0.78rem;
    color: var(--bb-text-muted);
    margin-bottom: 8px;
}

.bb-btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: linear-gradient(135deg, #00f0ff, #00b8cc);
    color: #040812;
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: var(--bb-radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.bb-btn-action:hover {
    filter: brightness(1.15);
    box-shadow: 0 0 12px var(--bb-primary-glow);
}

.bb-btn-action-pay {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}

.bb-btn-action-pay:hover {
    filter: brightness(1.15);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

/* Suggestion Pills */
.bb-suggested-container {
    padding: 8px 14px;
    background: rgba(8, 14, 30, 0.7);
    border-top: 1px solid var(--bb-border-subtle);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.bb-suggested-container::-webkit-scrollbar {
    display: none;
}

.bb-pill {
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.25);
    color: var(--bb-text-main);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.bb-pill:hover {
    background: rgba(0, 240, 255, 0.2);
    color: var(--bb-primary);
    border-color: var(--bb-primary);
    transform: translateY(-1px);
}

/* Typing Indicator */
.bb-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bb-bg-card);
    border: 1px solid var(--bb-border-subtle);
    border-radius: 14px;
    width: fit-content;
}

.bb-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--bb-primary);
    border-radius: 50%;
    animation: bbTyping 1.4s infinite ease-in-out both;
}

.bb-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.bb-typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Input Area */
.bb-input-bar {
    padding: 12px 14px;
    background: #080e1e;
    border-top: 1px solid var(--bb-border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.bb-input {
    flex: 1;
    background: rgba(15, 26, 48, 0.8);
    border: 1px solid var(--bb-border-subtle);
    border-radius: 20px;
    padding: 10px 16px;
    color: #fff;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.bb-input:focus {
    border-color: var(--bb-primary);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.bb-input::placeholder {
    color: #64748b;
}

.bb-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bb-primary);
    color: #040812;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.bb-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 10px var(--bb-primary-glow);
}

.bb-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Footer Tag */
.bb-footer-tag {
    background: #050811;
    padding: 4px 12px;
    font-size: 0.65rem;
    color: #64748b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.bb-footer-tag a {
    color: var(--bb-primary);
    text-decoration: none;
    cursor: pointer;
}

.bb-footer-tag a:hover {
    text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #brainbox-launcher {
        bottom: 18px;
        right: 18px;
        width: 52px;
        height: 52px;
    }

    #brainbox-panel {
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .bb-msg {
        max-width: 90%;
    }
}
