/* ==========================================================================
   Chatbot "Juanpa" 🌱 - Premium Glassmorphism Widget
   ========================================================================== */

:root {
    --chat-primary: #2d6a4f;
    --chat-primary-hover: #1b4332;
    --chat-secondary: #40916c;
    --chat-bg-glass: rgba(255, 255, 255, 0.85);
    --chat-border-glass: rgba(45, 90, 39, 0.12);
    --chat-shadow: 0 16px 48px rgba(28, 40, 38, 0.15);
    --chat-text-main: #1c2826;
    --chat-text-muted: #526b65;
    --chat-user-msg: #d8f3dc;
    --chat-bot-msg: #f4f9f4;
    --chat-font: 'Plus Jakarta Sans', 'Outfit', 'Inter', sans-serif;
}

/* Container */
.chatbot-widget-container {
    position: fixed;
    bottom: 24px;
    right: 96px; /* A la izquierda del botón de WhatsApp (que está a 24px) */
    z-index: 9998;
    font-family: var(--chat-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Chat Button */
.chatbot-trigger-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-secondary) 100%);
    box-shadow: 0 8px 24px rgba(45, 90, 39, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
    position: relative;
}

.chatbot-trigger-btn:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 10px 28px rgba(45, 90, 39, 0.45);
}

.chatbot-trigger-btn .icon-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background-color: #ff4d4f;
    border-radius: 50%;
    color: white;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse-badge 2s infinite;
}

/* Chat Panel */
.chatbot-panel {
    position: absolute;
    bottom: 72px;
    right: 0; /* Alínea el panel directamente sobre el botón del chatbot (a 96px del borde), dejando libre la esquina del WhatsApp */
    width: 360px;
    height: 520px;
    border-radius: 24px;
    background: var(--chat-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--chat-border-glass);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--chat-primary) 0%, #1b4332 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

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

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.chatbot-avatar-text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.chatbot-avatar-text span {
    font-size: 11px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-avatar-text span::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #2ec4b6;
    border-radius: 50%;
    box-shadow: 0 0 8px #2ec4b6;
}

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

.chatbot-close-btn, .chatbot-reset-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-close-btn:hover, .chatbot-reset-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Body (Messages) */
.chatbot-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: rgba(255, 255, 255, 0.3);
}

/* Message Styles */
.chat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    animation: fade-in-up 0.3s ease forwards;
    position: relative;
    word-wrap: break-word;
}

.chat-msg.bot {
    align-self: flex-start;
    background-color: var(--chat-bot-msg);
    border: 1px solid rgba(45, 90, 39, 0.05);
    color: var(--chat-text-main);
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    align-self: flex-end;
    background-color: var(--chat-user-msg);
    color: var(--chat-primary-hover);
    border-bottom-right-radius: 4px;
}

.chat-msg.system {
    align-self: center;
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--chat-text-muted);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 12px;
    text-align: center;
    max-width: 90%;
}

.chat-msg p {
    margin: 0;
}

.chat-msg a {
    color: var(--chat-primary);
    text-decoration: underline;
    font-weight: 600;
}

.chat-msg a:hover {
    color: var(--chat-primary-hover);
}

/* Quick Actions / Suggestions */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    animation: fade-in 0.5s ease forwards;
}

.suggestion-chip {
    background: white;
    border: 1px solid rgba(45, 90, 39, 0.15);
    color: var(--chat-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.suggestion-chip:hover {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 90, 39, 0.1);
}

/* Escalate button inside chat */
.escalate-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

.escalate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white !important;
    text-decoration: none !important;
    padding: 10px 16px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 13.5px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2);
    transition: all 0.2s ease;
}

.escalate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.3);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background-color: var(--chat-bot-msg);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    animation: fade-in 0.2s ease forwards;
}

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

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

/* Chat Footer (Input) */
.chatbot-footer {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid rgba(45, 90, 39, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.chatbot-input {
    flex: 1;
    border: 1px solid rgba(45, 90, 39, 0.15);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    font-family: var(--chat-font);
    color: var(--chat-text-main);
}

.chatbot-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.08);
}

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

.chatbot-send-btn:hover {
    background: var(--chat-primary-hover);
    transform: scale(1.05);
}

.chatbot-send-btn:disabled {
    background: rgba(0, 0, 0, 0.15);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
    transform: none;
}

/* Visual Stats / Message Counter */
.chatbot-status-bar {
    display: none;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--chat-text-muted);
    padding: 0 4px;
}

.captcha-container {
    background: #fff9e6;
    border: 1px solid #ffe58f;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: fade-in 0.3s ease;
}

.captcha-title {
    font-size: 12px;
    font-weight: 600;
    color: #b78103;
    margin: 0;
}

.captcha-question {
    font-size: 13px;
    color: var(--chat-text-main);
    margin: 0;
}

.captcha-input-group {
    display: flex;
    gap: 8px;
}

.captcha-input {
    flex: 1;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
}

.captcha-btn {
    background: #d48806;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.captcha-btn:hover {
    background: #ad6800;
}

/* Animations */
@keyframes pulse-badge {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.4); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(255, 77, 79, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); }
}

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

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .chatbot-widget-container {
        right: 84px;
        bottom: 20px;
    }
    
    .chatbot-panel {
        position: fixed;
        left: 16px;
        right: 16px;
        width: auto;
        bottom: 88px;
        height: calc(100vh - 120px);
    }
}



