/* =============================================
   ProdivetZN - Chat IA (Prodivet Assist)
   Desenvolvido para R12 - UI Chat IA
   ============================================= */

/* =============================================
   BOTÃO DA IA (ao lado da pesquisa)
   ============================================= */
.ai-chat-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: var(--logo-accent);
    color: var(--white);
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: var(--btn-transition);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
    transform: translateZ(0);
}

/* =============================================
   BOTÃO FLUTUANTE FIXO (Canto inferior direito)
   ============================================= */
.ai-floating-btn {
    position: fixed;
    bottom: 90px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--logo-accent);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
    z-index: 998;
    transition: var(--btn-transition);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(20px);
}

.ai-floating-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.ai-floating-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--logo-accent);
    transform: translate(-50%, -50%);
    animation: pulseFloat 2.5s ease-in-out infinite;
    opacity: 0.5;
    z-index: -1;
}

@keyframes pulseFloat {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 0;
    }
}

.ai-floating-btn:hover {
    background-color: #a71d2a;
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.5);
}

.ai-floating-btn:active {
    transform: scale(0.95);
}

.ai-floating-btn-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.ai-floating-btn-text {
    display: none;
}

/* Badge "Novo!" no botão flutuante */
.ai-floating-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ff6b7a 0%, #ff4757 100%);
    color: var(--white);
    font-size: 9px;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
    animation: badgePulse 2s ease-in-out infinite;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* Animação Shake para chamar atenção */
@keyframes shake {
    0%, 100% {
        transform: translateX(0) scale(1);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-3px) scale(1.02);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(3px) scale(1.02);
    }
}

.ai-floating-btn.shake {
    animation: shake 0.6s ease-in-out;
}

/* Mobile */
@media (max-width: 768px) {
    .ai-floating-btn {
        bottom: 80px;
        right: 20px;
        width: 40px;
        height: 40px;
    }

    .ai-floating-badge {
        font-size: 8px;
        padding: 2px 5px;
        top: -3px;
        right: -3px;
    }
}

/* Wrapper do botão IA + bolinha */
.ai-chat-btn-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Bolinha ℹ️ ao lado do avatar */
.pa-info-dot {
    width: 35px;
    height: 35px;
    background-color: var(--logo-accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-decoration: none;
    margin-left: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.pa-info-dot:hover {
    background-color: #a71d2a;
    transform: scale(1.1);
}

/* Badge "Novo!" no botão do header */
.ai-header-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #ff6b7a 0%, #ff4757 100%);
    color: var(--white);
    font-size: 8px;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(255, 71, 87, 0.4);
    animation: badgePulse 2s ease-in-out infinite;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    z-index: 1;
}

/* Animação de pulso para atrair atenção */
.ai-chat-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--logo-accent);
    transform: translate(-50%, -50%);
    animation: pulse 2s ease-in-out infinite;
    opacity: 0.6;
    z-index: -1;
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0;
    }
}

.ai-chat-btn:hover {
    background-color: #a71d2a;
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.5);
}

.ai-chat-btn:active {
    transform: scale(0.95);
}

.ai-chat-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.4);
}

/* Imagem dentro do botão */
.ai-chat-btn-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    pointer-events: none;
}

/* =============================================
   MODAL DE CHAT - TELA CHEIA
   ============================================= */
.ai-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(3px);
}

.ai-chat-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ai-chat-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 1000px;
    height: 90vh;
    max-height: 850px;
    background-color: var(--white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    animation: modalBounce 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalBounce {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.02);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* =============================================
   CABEÇALHO DO CHAT
   ============================================= */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    background: linear-gradient(135deg, var(--logo-accent) 0%, #a71d2a 100%);
    color: var(--white);
    border-radius: 20px 20px 0 0;
    flex-shrink: 0;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ai-chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--white);
    padding: 3px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Indicador Online */
.ai-chat-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: #28a745;
    border: 2px solid var(--white);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.ai-chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.ai-chat-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-chat-info p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

.ai-chat-header-actions {
    display: flex;
    gap: 10px;
}

.ai-chat-header-btn {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--white);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 16px;
}

.ai-chat-header-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.ai-chat-header-btn:active {
    transform: scale(0.95);
}

/* =============================================
   ÁREA DE MENSAGENS
   ============================================= */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Scrollbar customizada */
.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background-color: #e9ecef;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: #adb5bd;
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: #868e96;
}

/* Mensagens */
.ai-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: messageSlideIn 0.3s ease;
}

.ai-message.user-message {
    flex-direction: row-reverse;
}

@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    60% {
        transform: translateY(-2px) scale(1);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-message-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--white);
    padding: 2px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--white);
}

.ai-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-message .ai-message-avatar {
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 18px;
}

.ai-message-content {
    padding: 16px 18px;
    border-radius: 16px;
    font-size: 16px;
    line-height: 1.6;
    overflow-wrap: break-word;
    word-break: keep-all;
    hyphens: none;
    width: fit-content;
    min-width: 50px;
}

.ai-message.user-message .ai-message-content {
    background-color: var(--primary-color);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.ai-message.bot-message .ai-message-content {
    background-color: var(--white);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Formatação de texto nas mensagens */
.ai-message-content strong {
    font-weight: 600;
}

.ai-message-content em {
    font-style: italic;
}

.ai-message-content a {
    color: var(--logo-accent);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.ai-message-content a:hover {
    color: #a71d2a;
}

.user-message .ai-message-content a {
    color: var(--white);
    text-decoration: underline;
}

.user-message .ai-message-content a:hover {
    opacity: 0.9;
}

/* Links clicáveis de produtos na resposta da IA (R15) */
.produto-link-ia {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--logo-accent) !important;
    text-decoration: none !important;
    font-weight: 600;
    border-bottom: 1.5px dashed var(--logo-accent);
    transition: all 0.2s ease;
    cursor: pointer;
}

.produto-link-ia::after {
    content: '↗';
    font-size: 11px;
    opacity: 0.7;
}

.produto-link-ia:hover {
    color: #a71d2a !important;
    border-bottom-color: #a71d2a;
    border-bottom-style: solid;
}

.ai-message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 6px;
    opacity: 0.8;
    display: block;
}

/* Indicador "A escrever..." */
.ai-typing-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ai-typing-indicator.active {
    opacity: 1;
    visibility: visible;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background-color: var(--white);
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #adb5bd;
    animation: typingDot 1.4s infinite;
}

.ai-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* =============================================
   INPUT DE MENSAGEM
   ============================================= */
.ai-chat-input-wrapper {
    padding: 20px 25px;
    background-color: var(--white);
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

/* Disclaimer (R15) */
.ai-disclaimer {
    background-color: #fff8e1;
    border-bottom: 1px solid #ffe082;
    color: #7a6000;
    font-size: 11px;
    padding: 6px 16px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ai-disclaimer i {
    font-size: 11px;
    color: #f59e0b;
}

/* Sugestões Rápidas */
.ai-quick-replies {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    opacity: 1;
    transition: opacity 0.3s ease, max-height 0.3s ease;
    max-height: 200px;
    overflow: hidden;
}

.ai-quick-replies.hidden {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
}

.ai-quick-reply-btn {
    flex: 1;
    padding: 8px 14px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.ai-quick-reply-btn:hover {
    background-color: var(--logo-accent);
    color: var(--white);
    border-color: var(--logo-accent);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2);
}

.ai-quick-reply-btn:active {
    transform: translateY(0);
}

.ai-quick-reply-btn i {
    font-size: 12px;
}

.ai-chat-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 15px;
    font-family: var(--font-body);
    resize: none;
    max-height: 120px;
    min-height: 44px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.ai-chat-input::-webkit-resizer,
.ai-chat-input::-webkit-scrollbar {
    display: none;
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--logo-accent);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.08);
}

.ai-chat-input::placeholder {
    color: #adb5bd;
}

.ai-chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--logo-accent);
    border: none;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--btn-transition);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
    flex-shrink: 0;
}

.ai-chat-send-btn:hover:not(:disabled) {
    background-color: #a71d2a;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.ai-chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Animação de enviar */
.ai-chat-send-btn.sending i {
    animation: sendPlane 0.6s ease-out;
}

@keyframes sendPlane {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(20px, -20px) rotate(45deg);
        opacity: 0.5;
    }
    100% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
}

/* =============================================
   RESPONSIVIDADE
   ============================================= */

/* Tablet */
@media (max-width: 768px) {
    .ai-chat-modal {
        width: 95%;
        height: 90vh;
        max-height: none;
    }

    .ai-chat-header {
        padding: 15px 20px;
    }

    .ai-chat-avatar {
        width: 42px;
        height: 42px;
    }

    .ai-chat-info h3 {
        font-size: 16px;
    }

    .ai-chat-info p {
        font-size: 12px;
    }

    .ai-chat-messages {
        padding: 20px 15px;
    }

    .ai-message-content {
        max-width: 80%;
        font-size: 14px;
    }

    .ai-chat-input-wrapper {
        padding: 15px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .ai-chat-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .ai-header-badge {
        font-size: 7px;
        padding: 2px 4px;
        top: -3px;
        right: -3px;
    }

    .ai-chat-modal {
        width: 100%;
        height: 100vh;
        max-width: none;
        border-radius: 0;
    }

    .ai-chat-header {
        border-radius: 0;
        padding: 15px;
    }

    .ai-chat-avatar {
        width: 38px;
        height: 38px;
    }

    .ai-chat-info h3 {
        font-size: 15px;
    }

    .ai-chat-info p {
        font-size: 11px;
    }

    .ai-chat-header-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .ai-chat-messages {
        padding: 15px 10px;
        gap: 12px;
    }

    .ai-message-avatar {
        width: 32px;
        height: 32px;
    }

    .ai-message-content {
        max-width: 85%;
        font-size: 14px;
        padding: 10px 14px;
    }

    .ai-chat-input-wrapper {
        padding: 12px 10px;
    }

    .ai-chat-input {
        font-size: 14px;
        padding: 10px 14px;
    }

    .ai-chat-send-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* =============================================
   BOTÃO IA NOS CARDS DE PRODUTOS
   ============================================= */
.btn-product-ai {
    padding: 10px 20px;
    border-radius: 5px;
    background-color: transparent;
    border: 2px solid #ff6b7a;
    color: #ff6b7a;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-body);
    transition: var(--btn-transition);
    flex-shrink: 0;
}

.btn-product-ai:hover {
    background-color: #ff6b7a;
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 122, 0.3);
}

.btn-product-ai:active {
    transform: translateY(0);
}

.product-footer {
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
    flex-wrap: wrap !important;
}

/* =============================================
   ACESSIBILIDADE
   ============================================= */
.ai-chat-btn:focus-visible,
.ai-chat-header-btn:focus-visible,
.ai-chat-send-btn:focus-visible {
    outline: 2px solid var(--logo-accent);
    outline-offset: 2px;
}

/* Ocultar elementos visualmente mas manter para screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===================================================
   SUGESTÕES RÁPIDAS DE PRODUTO (R14)
   Estilo IGUAL às quick replies normais
   =================================================== */
.ai-product-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.ai-product-quick-replies.hidden {
    display: none;
}

.ai-product-quick-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
    padding: 10px 14px;
    background: white;
    color: #495057;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
}

.ai-product-quick-btn:hover {
    background: #f8f9fa;
    border-color: var(--logo-accent);
    color: var(--logo-accent);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.ai-product-quick-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Responsive para sugestões de produto */
@media (max-width: 480px) {
    .ai-product-quick-btn {
        flex: 1 1 100%;
        min-width: auto;
    }
}
