/* Botão Flutuante */
#propague-chat-widget {
    position: fixed;
    z-index: 9999;
    box-sizing: border-box;
    max-width: 100vw;
}

#propague-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border-radius: 50%;
    background-color: #000; /* Cor principal */
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
    box-sizing: border-box;
}

#propague-chat-toggle:hover {
    background-color: #333;
    transform: scale(1.05);
}

#propague-chat-toggle svg {
    width: 30px;
    height: 30px;
}

/* Container do Chat (Janela) */
#propague-chat-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 530px;
    max-height: calc(100vh - 115px);
    background-color: white;
    border-radius: 16px;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.18);
    z-index: 9999;
    display: none; /* Oculto por padrão */
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
}

/* Estado Aberto do Widget */
.propague-chat-open #propague-chat-container {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

.propague-chat-open #propague-chat-toggle {
    display: none;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cabeçalho */
.propague-chat-header {
    background-color: #000;
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
}

#propague-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#propague-chat-close:hover {
    opacity: 0.8;
}

/* Área de Mensagens */
#propague-chat-messages {
    flex: 1;
    padding: 16px 14px;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

#propague-chat-messages::-webkit-scrollbar {
    width: 6px;
}
#propague-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#propague-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}
#propague-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Balões de Mensagem */
.propague-message {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    opacity: 0;
    animation: fadeInMessage 0.3s ease-out forwards;
    transform: translateY(8px);
    box-sizing: border-box;
}

@keyframes fadeInMessage {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.propague-message.bot {
    align-self: flex-start;
    background-color: #ffffff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #eef2f6;
}

.propague-message.user {
    align-self: flex-end;
    background-color: #000000;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    max-width: 82%;
}

/* Avatar do Bot nas mensagens */
.propague-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1/1;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Conteúdo da Mensagem */
.message-content {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
    font-size: 14.5px;
    line-height: 1.55;
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ol.chat-list-ol,
.message-content ul.chat-list-ul {
    margin: 6px 0 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 5px;
    line-height: 1.5;
}

.message-content li:last-child {
    margin-bottom: 0;
}

/* Tabela Markdown no chat */
.message-content table.chat-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.4;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.message-content table.chat-table thead {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.message-content table.chat-table tbody {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.message-content table.chat-table th,
.message-content table.chat-table td {
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    text-align: left;
    word-break: break-word;
}

.message-content table.chat-table th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}

.message-content table.chat-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

.message-content table.chat-table tbody tr:hover {
    background-color: #e2e8f0;
}

.message-content strong {
    font-weight: 700;
    color: inherit;
}

.message-content em {
    font-style: italic;
    color: inherit;
}

/* Área de Input */
.propague-chat-input-area {
    padding: 10px;
    background-color: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

#propague-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    font-size: 14px;
}

#propague-chat-input:focus {
    border-color: #1E5016;
}

#propague-chat-send {
    background-color: #1E5016;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

#propague-chat-send:hover {
    background-color: #333;
}

/* Balão de Saudação Externa */
#propague-chat-greeting-bubble {
    position: fixed;
    bottom: 30px; /* Ajustado dinamicamente via JS se precisar, mas alinhado ao centro do botão */
    right: 90px; /* 20px (botão) + 60px (largura botão) + 10px (margem) */
    background-color: white;
    color: #333;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    font-size: 14px;
    font-weight: 500;
    max-width: calc(100vw - 110px);
    white-space: normal;
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.5s ease-out;
    cursor: pointer;
    box-sizing: border-box;
}

#propague-chat-greeting-bubble:after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid white;
}

#propague-chat-greeting-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    margin-left: 4px;
}

#propague-chat-greeting-close:hover {
    color: #333;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsividade Mobile */
@media (max-width: 480px) {
    #propague-chat-widget {
        bottom: 16px !important;
        right: 16px !important;
        max-width: calc(100vw - 32px) !important;
    }

    #propague-chat-toggle {
        bottom: 16px !important;
        right: 16px !important;
        width: 54px !important;
        height: 54px !important;
    }

    #propague-chat-container {
        width: 100% !important;
        height: 100% !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
    }
    
    #propague-chat-greeting-bubble {
        font-size: 12px;
        padding: 8px 12px;
        right: 76px !important;
        bottom: 20px !important;
        max-width: calc(100vw - 92px) !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
}

/* --- Novos Estilos para Links e Cards --- */

/* Negrito */
.message-content strong {
    font-weight: 700;
}

/* Link Externo Padrão */
.propague-chat-external-link {
    color: #000;
    text-decoration: underline;
    word-break: break-all;
}

.propague-chat-external-link:hover {
    color: #333;
}

/* Card de Produto com Foto Grande (Padrão Cantolli) */
.propague-chat-product-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 14px;
    overflow: hidden;
    margin: 10px 0;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
    text-decoration: none;
    color: inherit;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.propague-chat-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1);
    border-color: #000000;
}

/* Área da Foto Grande do Produto */
.propague-product-card-media {
    position: relative;
    width: 100%;
    height: 195px;
    background-color: #f7f7f7;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.propague-product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.4s ease;
}

.propague-chat-product-card:hover .propague-product-img {
    transform: scale(1.05);
}

.propague-product-card-media.is-placeholder {
    color: #a0aec0;
    background: #f1f5f9;
}

.propague-product-card-media.is-hidden {
    display: none !important;
}

.propague-product-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #000000;
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
    z-index: 2;
}

/* Informações do Produto */
.propague-product-info {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #ffffff;
    text-align: left;
}

.propague-product-title {
    font-size: 14.5px;
    font-weight: 600;
    color: #111827;
    margin: 0 !important;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.propague-product-price {
    font-size: 15px;
    font-weight: 700;
    color: #000000;
    margin: 2px 0 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.propague-product-price del {
    font-size: 12.5px;
    color: #94a3b8;
    font-weight: 400;
}

.propague-product-price ins {
    text-decoration: none;
    color: #000000;
}

/* Texto Curto do Produto com a Foto */
.propague-product-desc {
    font-size: 12.5px;
    color: #4b5563;
    line-height: 1.45;
    margin: 3px 0 6px 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.propague-product-action {
    margin-top: 4px;
}

.propague-product-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: #000000;
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 8px;
    transition: background 0.2s ease, transform 0.15s ease;
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
}

.propague-chat-product-card:hover .propague-product-btn {
    background: #27272a;
}

.propague-product-btn svg {
    transition: transform 0.2s ease;
}

.propague-chat-product-card:hover .propague-product-btn svg {
    transform: translateX(3px);
}

/* Loading state */
.propague-chat-product-card.is-loading {
    opacity: 0.85;
}

/* Card de Serviço (Links Internos) */
.propague-chat-link-card {
    display: flex;
    flex-direction: row; /* Horizontal: Coluna Principal + Coluna Seta */
    align-items: stretch;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 0; /* Padding agora é interno */
    margin-top: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0;
    text-decoration: none;
    color: inherit;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Coluna Principal (Imagem + Conteúdo) */
.card-main-column {
    display: flex;
    flex-direction: column; /* Vertical: Imagem acima, texto abaixo */
    flex: 1;
    min-width: 0;
}

/* Coluna da Seta */
.card-arrow-column {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    border-left: 1px solid #eee;
    background-color: #fff; /* Opcional: destaque leve */
}

/* Placeholder ou Área de Imagem */
.card-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0; /* Espaço reduzido */
    background-color: #f1f1f1;
}

/* Quando tem imagem real */
.card-image {
    width: 100%;
    height: 100px; /* Altura reduzida para imagem */
    overflow: hidden;
    position: relative;
    background-color: #eee;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.propague-chat-link-card:hover .card-image img {
    transform: scale(1.05);
}

.card-icon {
    background: #000;
    color: white;
    width: 32px; /* Ícone levemente menor */
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-content {
    padding: 10px; /* Padding reduzido */
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1; 
}

.card-title {
    font-weight: 600;
    font-size: 13px; /* Fonte levemente menor para compactar */
    color: #333;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.card-cta {
    font-size: 11px; /* Fonte levemente menor */
    color: #666;
    margin-top: 2px;
}

.card-arrow {
    color: #ccc;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.propague-chat-link-card:hover {
    background: #fff;
    border-color: #000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.propague-chat-link-card:hover .card-arrow {
    color: #000;
}

/* Estado antigo (has-image) não é mais necessário na estrutura nova,
   mas mantemos classes genéricas se precisar */

/* Link Simples (Auto-detectado) */
.propague-simple-link {
    color: #007bff;
    text-decoration: underline;
    word-break: break-all;
}

/* Footer do Chat */
.propague-chat-footer {
    border-top: 1px solid #eee;
    background-color: #fafafa;
    padding: 8px 12px;
}

.propague-chat-whatsapp-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.propague-chat-whatsapp-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    background-color: #e8f5e9;
    color: #1a5e1a;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.propague-chat-whatsapp-link:hover {
    background-color: #c8e6c9;
    color: #0d3d0d;
}

/* Botões de Grupos de Ofertas */
.propague-chat-whatsapp-link.propague-chat-group-link {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    display: flex;
    align-items: center;
}

.propague-chat-whatsapp-link.propague-chat-group-link:hover {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #14532d;
}

.propague-chat-group-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #16a34a;
    color: #ffffff;
    padding: 2px 7px;
    border-radius: 4px;
    margin-left: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Store Hours Info */
.propague-store-hours {
    font-size: 12px;
    color: #888;
    padding: 6px 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
    text-align: center;
}

.propague-store-hours.open {
    color: #2e7d32;
}

.propague-store-hours.closed {
    color: #c62828;
}

/* ========== Fallback WhatsApp (sem LLM ativo) ========== */
.propague-chat-whatsapp-only {
    height: auto !important;
    max-height: 500px;
}

.propague-whatsapp-fallback-body {
    padding: 28px 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
}

.propague-whatsapp-fallback-icon {
    margin-bottom: 6px;
    animation: whatsappPulse 2s ease-in-out infinite;
}

@keyframes whatsappPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.propague-whatsapp-fallback-title {
    font-size: 17px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 4px 0;
}

.propague-whatsapp-fallback-subtitle {
    font-size: 13px;
    color: #666;
    margin: 0 0 16px 0;
    line-height: 1.4;
}

.propague-whatsapp-fallback-contacts {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.propague-whatsapp-fallback-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #25D366;
    color: #fff;
    border-radius: 12px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.25);
}

.propague-whatsapp-fallback-btn:hover {
    background: #1ebe57;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
    color: #fff;
    text-decoration: none;
}

.propague-whatsapp-fallback-btn svg {
    flex-shrink: 0;
}

.propague-whatsapp-fallback-btn-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.3;
}

.propague-whatsapp-fallback-btn-text strong {
    font-size: 14px;
    font-weight: 700;
}

.propague-whatsapp-fallback-btn-text small {
    font-size: 11px;
    opacity: 0.9;
    margin-top: 2px;
}
