/* 💬 Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--font-body);
}

/* Botón flotante */
.chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--green-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(76, 175, 80, 0.5);
}

.chat-toggle-icon {
    width: 26px;
    height: 26px;
    color: #ffffff;
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
}

.chat-toggle-close {
    position: absolute;
    font-size: 1.4rem;
    color: #ffffff;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s ease;
}

.chat-toggle.active .chat-toggle-icon {
    opacity: 0;
    transform: scale(0.5);
}

.chat-toggle.active .chat-toggle-close {
    opacity: 1;
    transform: scale(1);
}

/* Panel */
.chat-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    height: 520px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.96);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}

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

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--green-primary), var(--green-dark));
    color: #ffffff;
    flex-shrink: 0;
}

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

.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chat-header-avatar img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

.chat-header-title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.chat-header-status {
    font-size: 0.75rem;
    opacity: 0.85;
    line-height: 1.2;
}

.chat-header-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-header-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Body */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8f9fa;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    animation: messageIn 0.3s ease;
}

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

.chat-message.bot {
    align-self: flex-start;
    background: #ffffff;
    color: var(--gray-dark);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

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

/* FAQ */
.chat-faq {
    padding: 8px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.faq-btn {
    display: block;
    width: 100%;
    padding: 11px 16px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--gray-dark);
    text-align: left;
    transition: all 0.2s ease;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.faq-btn:hover {
    border-color: var(--green-primary);
    color: var(--green-primary);
    background: rgba(76, 175, 80, 0.04);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.1);
    transform: translateY(-1px);
}

.faq-back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--green-primary);
    font-weight: 600;
    transition: color 0.2s;
}

.faq-back-btn:hover {
    color: var(--green-dark);
}

/* Footer */
.chat-footer {
    padding: 10px 18px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: #ffffff;
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-medium);
    flex-shrink: 0;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

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

/* Responsive: móvil */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        transform: translateY(20px) scale(0.96);
    }

    .chat-panel.active {
        transform: translateY(0) scale(1);
    }

    .chat-toggle {
        width: 52px;
        height: 52px;
    }
}
