/* ── Engagement Nudge Bubble ── */

.engagement-nudge {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    max-width: 380px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.engagement-nudge.visible {
    transform: translateX(0);
    opacity: 1;
}

.engagement-nudge.slide-out {
    transform: translateX(120%);
    opacity: 0;
}

/* Avatar */
.nudge-avatar {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.nudge-avatar.career {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.nudge-avatar.companion {
    background: linear-gradient(135deg, #a78bfa, #6366f1);
}

/* Content */
.nudge-body {
    flex: 1;
    min-width: 0;
}

.nudge-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 4px;
}

.nudge-message {
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 10px;
}

/* CTA button (nudge state) */
.nudge-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #818cf8;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s;
    font-family: inherit;
}

.nudge-cta:hover {
    color: #a5b4fc;
}

.nudge-cta::after {
    content: '\2192';
    font-size: 14px;
    transition: transform 0.2s;
}

.nudge-cta:hover::after {
    transform: translateX(3px);
}

/* Dismiss button */
.nudge-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.nudge-dismiss:hover {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

/* ═══════════════════════════════════════════
   EXPANDED CHAT PANEL
   ═══════════════════════════════════════════ */

.engagement-nudge.expanded {
    flex-direction: column;
    gap: 0;
    padding: 0;
    width: 380px;
    max-width: 380px;
    height: 520px;
    max-height: calc(100vh - 90px);
    background: rgba(15, 15, 25, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

/* ── Chat header ── */
.nudge-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.nudge-chat-header .nudge-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
}

.nudge-chat-header-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

.nudge-chat-expand-link {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}

.nudge-chat-expand-link:hover {
    color: #818cf8;
}

.nudge-chat-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.45);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.nudge-chat-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
}

/* ── Messages area ── */
.nudge-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

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

.nudge-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

/* ── Message bubbles ── */
.nudge-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.88);
    word-wrap: break-word;
    animation: nudgeMsgIn 0.25s ease;
}

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

.nudge-msg.user {
    align-self: flex-end;
    background: rgba(99, 102, 241, 0.25);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-bottom-right-radius: 4px;
}

.nudge-msg.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 4px;
}

.nudge-msg strong {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}

.nudge-msg em {
    color: rgba(255, 255, 255, 0.7);
}

/* ── Typing indicator ── */
.nudge-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.nudge-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    animation: nudgeTypingPulse 1.4s ease-in-out infinite;
}

.nudge-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.nudge-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes nudgeTypingPulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
    30% { opacity: 1; transform: scale(1); }
}

/* ── Input bar ── */
.nudge-chat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.nudge-chat-input textarea {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    outline: none;
    min-height: 36px;
    max-height: 80px;
    transition: border-color 0.2s;
}

.nudge-chat-input textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.nudge-chat-input textarea:focus {
    border-color: rgba(129, 140, 248, 0.4);
}

.nudge-chat-input textarea:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nudge-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.nudge-send-btn:hover {
    transform: scale(1.05);
}

.nudge-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

/* ── Paywall / Upgrade CTA ── */
.nudge-paywall {
    padding: 16px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    flex-shrink: 0;
}

.nudge-paywall p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0 10px;
    line-height: 1.4;
}

.nudge-paywall-btn {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s, transform 0.15s;
}

.nudge-paywall-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ── Mobile: nudge state ── */
@media (max-width: 600px) {
    .engagement-nudge {
        left: 0;
        right: 0;
        bottom: 0;
        max-width: none;
        border-radius: 16px 16px 0 0;
        padding: 16px 18px;
        transform: translateY(100%);
    }

    .engagement-nudge.visible {
        transform: translateY(0);
    }

    .engagement-nudge.slide-out {
        transform: translateY(100%);
    }

    /* Expanded chat on mobile */
    .engagement-nudge.expanded {
        width: 100%;
        max-width: none;
        height: 70vh;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
    }

    .engagement-nudge.expanded.slide-out {
        transform: translateY(100%);
    }
}
