/* Custom Fonts (Outfit) & CSS Reset */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

#invitar-chatbot-root {
    --invitar-bg-dark: #0c0d12;
    --invitar-bg-card: rgba(22, 24, 33, 0.85);
    --invitar-bg-card-solid: #161821;
    --invitar-bg-message-user: linear-gradient(135deg, #0e3020 0%, #161821 100%);
    --invitar-bg-message-bot: rgba(35, 38, 53, 0.6);
    --invitar-accent-glow: linear-gradient(90deg, #10b981, #059669, #29b965, #10b981);
    --invitar-text-primary: #f3f4f6;
    --invitar-text-secondary: #9ca3af;
    --invitar-text-muted: #6b7280;
    --invitar-border-color: rgba(255, 255, 255, 0.08);
    --invitar-neon-cyan: #29b965;
    --invitar-neon-purple: #9d4edd;
    --invitar-font: 'Outfit', sans-serif;
    
    font-family: var(--invitar-font);
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    direction: ltr;
}

/* Floating Chat Bubble Button */
#invitar-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #000;
    position: relative;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 229, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
}

/* Ambient Pulse Border Effect for Bubble */
#invitar-chat-bubble::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: var(--invitar-accent-glow);
    background-size: 300% 300%;
    border-radius: 50%;
    z-index: -1;
    animation: invitar-gradient-shift 4s ease infinite, invitar-pulse-glow 2s infinite alternate;
}

#invitar-chat-bubble:hover {
    transform: scale(1.1) translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 229, 255, 0.4);
}

#invitar-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: transform 0.3s ease;
}

#invitar-chat-bubble:hover svg {
    transform: rotate(10deg) scale(1.05);
}

/* Notification Badge */
#invitar-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff0055;
    color: #fff;
    border-radius: 50%;
    width: 10px;
    height: 10px;
    box-shadow: 0 0 10px #ff0055;
    animation: invitar-badge-ping 1.5s infinite;
}

/* Chat Window Box */
#invitar-chat-window {
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 100px);
    background: var(--invitar-bg-card);
    border: 1px solid var(--invitar-border-color);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 40px rgba(122, 0, 255, 0.1);
    position: absolute;
    bottom: 80px;
    right: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    transform-origin: bottom right;
}

#invitar-chatbot-root.active #invitar-chat-window {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Ambient Glowing Header Border */
#invitar-chat-window::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--invitar-accent-glow);
    background-size: 300% 300%;
    animation: invitar-gradient-shift 4s ease infinite;
    z-index: 10;
}

/* Chat Header */
.invitar-chat-header {
    padding: 16px 20px;
    background: rgba(12, 13, 18, 0.6);
    border-bottom: 1px solid var(--invitar-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
}

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

.invitar-chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1b263b 0%, #0d1b2a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--invitar-neon-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.invitar-chat-header-avatar img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.invitar-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--invitar-text-primary);
    line-height: 1.2;
}

.invitar-chat-header-subtitle {
    font-size: 11px;
    color: var(--invitar-neon-cyan);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.invitar-chat-status-dot {
    width: 7px;
    height: 7px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
    animation: invitar-pulse-green 1.5s infinite alternate;
}

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

.invitar-chat-header-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.invitar-chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.invitar-chat-header-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--invitar-text-secondary);
}

/* Chat Body (Messages Area) */
.invitar-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: radial-gradient(circle at bottom right, rgba(122, 0, 255, 0.05), transparent 60%);
    scroll-behavior: smooth;
}

/* Custom Scrollbar for Messages */
.invitar-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.invitar-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.invitar-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.invitar-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Message Styles */
.invitar-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: invitar-fade-in-up 0.35s ease forwards;
}

.invitar-msg.user {
    align-self: flex-end;
}

.invitar-msg.bot {
    align-self: flex-start;
}

.invitar-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    color: var(--invitar-text-primary);
}

.invitar-msg.user .invitar-msg-bubble {
    background: var(--invitar-bg-message-user);
    border: 1px solid rgba(157, 78, 221, 0.2);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(122, 0, 255, 0.05);
}

.invitar-msg.bot .invitar-msg-bubble {
    background: var(--invitar-bg-message-bot);
    border: 1px solid var(--invitar-border-color);
    border-bottom-left-radius: 4px;
}

.invitar-msg-time {
    font-size: 10px;
    color: var(--invitar-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.invitar-msg.user .invitar-msg-time {
    align-self: flex-end;
}

.invitar-msg.bot .invitar-msg-time {
    align-self: flex-start;
}

/* Markdown styling inside bubbles */
.invitar-msg-bubble p {
    margin: 0 0 8px 0;
}
.invitar-msg-bubble p:last-child {
    margin-bottom: 0;
}
.invitar-msg-bubble strong {
    color: #fff;
    font-weight: 600;
}
.invitar-msg-bubble ul, .invitar-msg-bubble ol {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}
.invitar-msg-bubble li {
    margin-bottom: 4px;
}
.invitar-msg-bubble li:last-child {
    margin-bottom: 0;
}
.invitar-msg-bubble a {
    color: var(--invitar-neon-cyan);
    text-decoration: underline;
    transition: color 0.2s ease;
}
.invitar-msg-bubble a:hover {
    color: #fff;
}

/* Quick Action / Suggestions Panel */
.invitar-quick-replies {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding: 0 4px;
    animation: invitar-fade-in-up 0.5s ease forwards;
}

.invitar-quick-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--invitar-border-color);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--invitar-text-primary);
    text-align: left;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-family: var(--invitar-font);
}

.invitar-quick-btn::after {
    content: '→';
    opacity: 0;
    transform: translateX(-5px);
    transition: all 0.25s ease;
    color: var(--invitar-neon-cyan);
}

.invitar-quick-btn:hover {
    background: rgba(0, 229, 255, 0.06);
    border-color: rgba(0, 229, 255, 0.3);
    transform: translateX(4px);
}

.invitar-quick-btn:hover::after {
    opacity: 1;
    transform: translateX(0);
}

/* Typing Indicator Animation */
.invitar-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
}

.invitar-typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--invitar-text-secondary);
    border-radius: 50%;
    animation: invitar-bounce 1.4s infinite ease-in-out both;
}

.invitar-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.invitar-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* Chat Footer Input Area */
.invitar-chat-footer {
    padding: 16px 20px;
    background: rgba(12, 13, 18, 0.85);
    border-top: 1px solid var(--invitar-border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 5;
}

.invitar-input-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--invitar-border-color);
    border-radius: 14px;
    padding: 6px 10px;
    transition: all 0.3s ease;
}

.invitar-input-container:focus-within {
    border-color: rgba(0, 229, 255, 0.5);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
}

.invitar-input-container textarea {
    flex: 1;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    color: var(--invitar-text-primary) !important;
    -webkit-text-fill-color: var(--invitar-text-primary) !important; /* Fixes iOS Safari black text issue */
    font-size: 14px;
    font-family: var(--invitar-font);
    resize: none;
    height: 24px;
    max-height: 100px;
    line-height: 24px;
    padding: 0 6px;
    overflow-y: auto;
}

.invitar-input-container textarea::placeholder {
    color: var(--invitar-text-muted);
}

.invitar-send-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.invitar-send-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--invitar-text-secondary);
    transition: fill 0.2s ease, transform 0.2s ease;
}

.invitar-input-container textarea:not(:placeholder-shown) ~ .invitar-send-btn svg {
    fill: var(--invitar-neon-cyan);
    transform: scale(1.1);
}

.invitar-send-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Footer branding note */
.invitar-chat-branding {
    font-size: 10px;
    color: var(--invitar-text-muted);
    text-align: center;
    user-select: none;
}

.invitar-chat-branding a {
    color: var(--invitar-neon-purple);
    text-decoration: none;
    font-weight: 500;
}

.invitar-chat-branding a:hover {
    text-decoration: underline;
}

/* Animations */
@keyframes invitar-gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes invitar-pulse-glow {
    0% { box-shadow: 0 0 15px rgba(0, 229, 255, 0.2); }
    100% { box-shadow: 0 0 25px rgba(157, 78, 221, 0.4); }
}

@keyframes invitar-badge-ping {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.5; }
}

@keyframes invitar-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes invitar-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

@keyframes invitar-pulse-green {
    from { box-shadow: 0 0 2px #10b981; }
    to { box-shadow: 0 0 10px #10b981; }
}

/* Responsive Style */
@media (max-width: 480px) {
    #invitar-chatbot-root {
        bottom: 12px;
        right: 12px;
    }
    #invitar-chat-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        max-height: 550px;
        bottom: 74px;
        border-radius: 16px;
    }
}
