/* Prefixo global para evitar conflitos com outros plugins */
.wp-flow-plugin {
    /* Variáveis globais que podem ser usadas em todo o plugin */
    --wp-flow-primary-color: #2196F3;
    --wp-flow-secondary-color: #1976D2;
    --wp-flow-text-color: #333;
    --wp-flow-bg-color: #fff;
    --wp-flow-border-color: #ccc;
    --wp-flow-shadow: 0 2px 10px rgba(0,0,0,0.1);
    --wp-flow-border-radius: 10px;
}

/* Classe para ocultar elementos */
.wp-flow-plugin .hidden, 
.wp-flow-plugin .google-visualization-orgchart-nodesel {
    display: none !important;
}

.wp-flow-plugin .flowchart-node {
    position: relative;
    padding: 10px;
    border: 1px solid var(--wp-flow-border-color, #ccc);
    border-radius: 5px;
}

.wp-flow-plugin .flowchart-node .edit-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    cursor: pointer;
    font-size: 16px;
    color: var(--wp-flow-text-color, #333);
}

.wp-flow-plugin .flowchart-node .edit-icon:hover {
    color: #000;
}

.wp-flow-plugin .flowchart-node .node-text {
    margin-top: 20px;
}

.wp-flow-plugin .support-button {
    background-color: var(--wp-flow-primary-color, #2196F3);
    color: #fff;
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
}

.wp-flow-plugin .support-button:hover {
    background-color: var(--wp-flow-secondary-color, #1976D2);
}

/* Contêiner para o ícone do bot e o botão de áudio */
.wp-flow-plugin .bot-message .icon-container {
    margin-right: 10px;
}

/* Wrapper para posicionar o botão de áudio sobre o ícone */
.wp-flow-plugin .icon-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
}

/* Ícone do bot */
.wp-flow-plugin .bot-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    border-radius: 50%;
}

/* Botão de áudio sobre o ícone */
.wp-flow-plugin .audio-button {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
}

.wp-flow-plugin .audio-button img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.wp-flow-plugin .audio-button:hover img {
    opacity: 0.8;
}

/* Estilos para o contêiner do texto */
.wp-flow-plugin .text-container {
    display: block;
}

/* Estilos para o contêiner do botão de áudio */
.wp-flow-plugin .audio-container {
    margin-top: 5px;
    text-align: left;
}

/* Estilos para o Teaser do Chat */
.wp-flow-plugin #chatTeaser {
    position: fixed;
    bottom: 20px !important;
    right: 90px;
    background-color: var(--wp-flow-bg-color, #fff);
    padding: 10px 15px;
    border-radius: var(--wp-flow-border-radius, 10px);
    box-shadow: var(--wp-flow-shadow, 0 2px 5px rgba(0, 0, 0, 0.2));
    max-width: 250px;
    z-index: 1000;
    opacity: 0;
    animation: fadeInTeaser 1s forwards;
    animation-delay: 2s;
    transition: opacity 0.5s ease;
}

/* Animação de fade-in para o teaser */
@keyframes fadeInTeaser {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Garantir que o teaser seja visível mesmo se a animação falhar */
.wp-flow-plugin #chatTeaser.force-visible {
    opacity: 1 !important;
    animation: none !important;
}

/* Esconder o teaser quando necessário */
.wp-flow-plugin #chatTeaser.hidden {
    display: none !important;
}

/* Efeito de fade-in para o ícone do chat */
.wp-flow-plugin #chatIcon {
    width: 60px;
    height: 60px;
    cursor: pointer;
    opacity: 0;
    animation: fadeInIcon 1s forwards;
    animation-delay: 2s;
    position: relative;
    border-radius: 50%;
}

/* Keyframes para o fade-in do ícone */
@keyframes fadeInIcon {
    to {
        opacity: 1;
    }
}

/* Container do ícone do chat */
.wp-flow-plugin #chatIconContainer {
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 1000;
    background: white;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--wp-flow-shadow, 0 2px 10px rgba(0,0,0,0.1));
    cursor: pointer;
}

.wp-flow-plugin #chatIconContainer::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 15px;
    height: 15px;
    background-color: #2ecc71;
    border-radius: 50%;
}

/* Container do Chat */
.wp-flow-plugin #chatContainer {
    position: fixed;
    bottom: 50px;
    right: 10px;
    width: 400px;
    max-width: 420px;
    max-height: 420px;
    background: var(--wp-flow-bg-color, #fff);
    border: 0px solid var(--wp-flow-border-color, #ccc);
    border-radius: var(--wp-flow-border-radius, 10px);
    box-shadow: var(--wp-flow-shadow, 0 0 10px rgba(0, 0, 0, 0.1));
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 1s ease, transform 1s ease;
    overflow: hidden;
}

.wp-flow-plugin #chatContainer.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Flowchat Container */
.wp-flow-plugin #flowchat {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    border: none !important;
}

/* Estilos do cabeçalho do chat */
.wp-flow-plugin #chatHeader {
    display: flex;
    align-items: center;
    background-color: var(--wp-flow-primary-color, #2196F3);
    padding: 10px;
    border-top-left-radius: var(--wp-flow-border-radius, 10px);
    border-top-right-radius: var(--wp-flow-border-radius, 10px);
    position: relative;
    flex-shrink: 0;
}

/* Ícone do usuário no cabeçalho */
.wp-flow-plugin .header-user-wrapper {
    position: relative;
    width: 50px;
    height: 50px;
    margin-right: 10px;
}

.wp-flow-plugin .header-user-wrapper::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 15px;
    height: 15px;
    background-color: #2ecc71;
    border-radius: 50%;
    z-index: 9999;
}

.wp-flow-plugin #headerUserIcon {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    max-width: 50px;
    max-height: 50px;
    border-radius: 50%;
}

/* Texto do cabeçalho */
.wp-flow-plugin #headerText {
    flex: 1;
    font-weight: bold;
    font-size: 16px;
    color: #fff;
}

/* Status online */
.wp-flow-plugin .online-status {
    color: #fff;
    font-size: 12px;
    font-weight: 400;
}

/* Botão de fechar no cabeçalho */
.wp-flow-plugin #chatCloseButton {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    background-color: transparent;
    width: 40px;
    height: 40px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-flow-plugin #chatCloseButton img {
    width: 25px;
    height: 25px;
    object-fit: contain;
    display: block;
    margin: auto;
}

.wp-flow-plugin #chatCloseButton:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Estilos do campo de entrada */
.wp-flow-plugin .input-field {
    display: flex;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
    flex-shrink: 0;
    width: 100%;
    height: auto;
}

.wp-flow-plugin .input-field .user-input {
    flex: 1;
    padding: 10px 40px 10px 25px;
    border-radius: var(--wp-flow-border-radius, 10px);
    border: 1px solid var(--wp-flow-border-color, #ccc);
    font-size: 14px;
    outline: none;
    transition: border 0.3s ease;
    width: 100%;
    margin: 0;
    height: auto;
    line-height: 40px;
}

.wp-flow-plugin .input-field .user-input:focus {
    border-color: var(--wp-flow-primary-color, #2196F3);
}

.wp-flow-plugin .input-field button {
    margin-left: -40px;
    padding: 5px;
    border: none;
    background: var(--wp-flow-bg-color, #fff);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: relative;
    top: 5px;
}

.wp-flow-plugin .input-field button img {
    width: 28px;
    height: 28px;
    filter: none;
}

.wp-flow-plugin .input-field button svg {
    fill: inherit;
}

/* Remove a seta antiga */
.wp-flow-plugin .input-field button::after {
    content: none;
}

.wp-flow-plugin .input-field button::before {
    content: '';
}

/* Aplica a cor do chat ao ícone SVG dinamicamente via JS */
.wp-flow-plugin .send-button svg {
    fill: var(--wp-flow-primary-color, #007bff);
}

/* Estilos da janela do chat */
.wp-flow-plugin ul.chat-window {
    width: 100%;
    padding: 20px;
    list-style: none;
    margin: 0;
    box-sizing: border-box;
    overflow-y: auto;
    scroll-behavior: smooth;
    max-height: calc(100%);
}

/* Espaçamento entre as mensagens */
.wp-flow-plugin ul.chat-window > li {
    margin-bottom: 10px;
    clear: both;
    max-width: 100%;
    box-sizing: border-box;
    white-space: pre-wrap;
}

.wp-flow-plugin ul.chat-window > li .text {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Mensagens do usuário */
.wp-flow-plugin ul.chat-window > li.user {
    float: right;
    text-align: right;
}

.wp-flow-plugin ul.chat-window > li.user .text {
    background-color: #ddd;
    color: #000;
    padding: 10px 15px;
    border-radius: var(--wp-flow-border-radius, 10px);
    max-width: 90%;
    display: inline-block;
}

/* Mensagens do bot */
.wp-flow-plugin ul.chat-window > li.bot {
    float: left;
    text-align: left;
}

.wp-flow-plugin ul.chat-window > li.bot .text {
    background-color: var(--wp-flow-primary-color, #2196F3);
    color: #fff;
    padding: 10px 15px;
    border-radius: var(--wp-flow-border-radius, 10px);
    max-width: 90%;
    display: inline-block;
}

/* Estilos para a mensagem do bot com ícone */
.wp-flow-plugin .bot-message {
    display: flex;
    align-items: flex-start;
}

/* Estilos para as opções */
.wp-flow-plugin .options-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.wp-flow-plugin .options-list > li {
    border-radius: var(--wp-flow-border-radius, 10px);
    padding: 10px 15px;
    border: 1px solid var(--wp-flow-primary-color, #2196F3);
    display: block;
    cursor: pointer;
    margin-bottom: 10px;
    background-color: var(--wp-flow-bg-color, #fff);
    transition: background-color 0.3s ease, color 0.3s ease;
    color: var(--wp-flow-primary-color, #2196F3);
    word-break: break-word;
    text-align: center;
}

.wp-flow-plugin .options-list > li:hover {
    background-color: var(--wp-flow-secondary-color, #1976D2);
    color: var(--wp-flow-bg-color, #fff);
}

/* Estilos do indicador de digitação */
.wp-flow-plugin .typing-indicator {
    background-color: #E6E7ED;
    will-change: transform;
    width: auto;
    border-radius: 50px;
    padding: 10px;
    display: table;
    margin: 0;
    margin-left: 10px;
    position: relative;
    animation: 2s bulge infinite ease-out;
}

.wp-flow-plugin .typing-indicator::before,
.wp-flow-plugin .typing-indicator::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: -2px;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background-color: #E6E7ED;
}

.wp-flow-plugin .typing-indicator::after {
    height: 10px;
    width: 10px;
    left: -10px;
    bottom: -10px;
}

.wp-flow-plugin .typing-indicator span {
    height: 8px;
    width: 8px;
    float: left;
    margin: 0 1px;
    background-color: #9E9EA1;
    display: block;
    border-radius: 50%;
    opacity: 0.4;
}

.wp-flow-plugin .typing-indicator span:nth-of-type(1) {
    animation: 1s blink infinite 0.3333s;
}

.wp-flow-plugin .typing-indicator span:nth-of-type(2) {
    animation: 1s blink infinite 0.6666s;
}

.wp-flow-plugin .typing-indicator span:nth-of-type(3) {
    animation: 1s blink infinite 0.9999s;
}

/* Animações */
@keyframes blink {
    50% {
        opacity: 1;
    }
}

@keyframes bulge {
    50% {
        transform: scale(1.05);
    }
}

/* Estilos adicionais */
.wp-flow-plugin body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

.wp-flow-plugin * {
    box-sizing: border-box;
}

/* Media Queries para telas menores */
@media (max-width: 768px) {
    .wp-flow-plugin #chatContainer {
        bottom: 70px;
        left: 10px;
        right: 0;
        width: 95%;
        max-width: 95%;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .wp-flow-plugin #chatIconContainer {
        bottom: 20px;
        right: 20px;
    }

    .wp-flow-plugin #chatTeaser {
        right: 80px;
        max-width: 80%;
    }

    .wp-flow-plugin .options-list > li {
        display: block;
        margin-right: 0;
        width: 100%;
        text-align: center;
    }

    .wp-flow-plugin ul.chat-window > li.user .text,
    .wp-flow-plugin ul.chat-window > li.bot .text {
        max-width: 100%;
    }
}

/* Ajustes adicionais para evitar overflow em dispositivos móveis */
.wp-flow-plugin #chatContainer * {
    box-sizing: border-box;
    max-width: 100%;
}

.wp-flow-plugin #chatContainer img {
    max-width: 100%;
    height: auto;
}

.wp-flow-plugin ul.chat-window {
    max-width: 100%;
    overflow-x: hidden;
}

.wp-flow-plugin .options-list > li {
    max-width: 100%;
    word-wrap: break-word;
}

.wp-flow-plugin .switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.wp-flow-plugin .switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.wp-flow-plugin .slider.round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.wp-flow-plugin .slider.round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.wp-flow-plugin input:checked + .slider.round {
    background-color: var(--wp-flow-primary-color, #2196F3);
}

.wp-flow-plugin input:checked + .slider.round:before {
    transform: translateX(26px);
}

.wp-flow-plugin .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 9999;
}

.wp-flow-plugin .modal-content {
    background-color: var(--wp-flow-bg-color, #fff);
    margin: 5% auto;
    padding: 20px;
    width: 80%;
    max-width: 600px;
}

/* Responsive styles for the admin panel */
@media (max-width: 768px) {
    /* Stack form fields vertically on mobile */
    .wp-flow-plugin .form-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .wp-flow-plugin .form-row label {
        margin-bottom: 5px;
        min-width: unset;
    }
    .wp-flow-plugin .form-row input[type="text"],
    .wp-flow-plugin .form-row input[type="number"],
    .wp-flow-plugin .form-row select {
        max-width: 100%;
        margin-right: 0;
    }
    /* Adjust modal width on mobile */
    .wp-flow-plugin #form-container {
        max-width: 90%;
    }
}

.wp-flow-plugin #message-table-container {
    overflow-x: auto;
}

.wp-flow-plugin #message-table-container table {
    min-width: 800px;
}

/* Ensure table headers and cells adjust properly */
.wp-flow-plugin table th, 
.wp-flow-plugin table td {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .wp-flow-plugin .form-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .wp-flow-plugin .form-row label {
        margin-bottom: 5px;
    }
    .wp-flow-plugin .form-row input,
    .wp-flow-plugin .form-row select,
    .wp-flow-plugin .form-row button {
        width: 100%;
        max-width: 100%;
    }
}

.wp-flow-plugin #message-table-container tbody {
    background-color: white !important;
}

/* Estilo para o menu "Comece Aqui!" */
.wp-flow-plugin .wp-admin #adminmenu a[href="admin.php?page=chatbot-jquery-documentation"] {
    background-color: #dc3545 !important;
    color: white !important;
}

.wp-flow-plugin .wp-admin #adminmenu a[href="admin.php?page=chatbot-jquery-documentation"]:hover {
    background-color: #c82333 !important;
}

.wp-flow-plugin .wp-admin #adminmenu a[href="admin.php?page=chatbot-jquery-documentation"]:hover {
    background-color: #c82333 !important;
}

/* Ocultar apenas li's com atributos específicos */
.wp-flow-plugin li[data-nextid="undefined"][data-action-url="undefined"][data-redirect-type="manual"] {
    display: none !important;
}

/* Estilos para o botão Adicionar */
.wp-flow-plugin .add-button {
    background-color: var(--wp-flow-primary-color, #2196F3);
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 10px;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.wp-flow-plugin .add-button:hover {
    background-color: var(--wp-flow-secondary-color, #1976D2);
}
