:root {
    --sidebar-width: 260px;
    --primary-color: #4f46e5;
    --sidebar-bg: #111827;
    --sidebar-text: #e5e7eb;
    --sidebar-hover: rgba(79, 70, 229, 0.15);
    --body-bg: #f3f4f6;
    --bs-nav-link-font-size: 15px;
}

body {
    background-color: var(--body-bg);
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand {
    padding: 1.5rem;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
}

.sidebar .brand .brand-logo {
    max-width: 200px;
    max-height: 64px;
    width: auto;
}

.filter-white{
    filter: brightness(10);
}

.sidebar .brand .brand-icon {
    font-size: 2rem;
    color: var(--primary-color);
}

.sidebar .brand .brand-name {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.2;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    margin: 0.2rem 1rem;
    font-weight: 500;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.sidebar .nav-link i {
    margin-right: 0.75rem;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}


.topbar .user-menu img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.page-content {
    padding: 30px;
}

.card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.2);
}

.card-header {
    background: transparent;
    border-bottom: none;
    font-weight: 600;
}

.badge{
    height: fit-content;
}

#ticketStatusFilter{
    width: 100px;
}

.badge-soft {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.table > :not(caption) > * > * {
    padding: 0.9rem 0.75rem;
    vertical-align: middle;
}

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
}

.avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-md {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.pg-conhecimento div{
        flex-direction: row-reverse;
    }

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        left: -100%;
        transition: left 0.3s ease;
        z-index: 1050;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .toast-container{
        width: 90%;
    }

    .page-content {
    padding: 15px;
    }


    /* .topbar nav{
        display: none;
    } */

    /* PAGINA TICKETS ///////////////////////////////////////////////////////////////*/

    .pg-tickets .card-header{
        padding: 0;
        flex-direction: column;
    }

    .pg-tickets .card-header div{
        margin-top: 10px;
        margin-bottom: 10px;
    }

    .tickets-abertos{
        flex-wrap: wrap;
        margin-top: 0 !important;
        margin-bottom: 20px !important;
    }

    .card-body{
        padding: 0;
    }

    .ticket-conversa{
        max-height: unset !important;
        overflow-y: hidden !important;
    }

    .card-header{
        padding: 0;
        margin-bottom: 15px;
    }

    /* PAGINA CONHECIMENTO ///////////////////////////////////////////////////////////////*/
    .pg-conhecimento{
        flex-direction: column;
    }

    .pg-conhecimento div{
        overflow-x: scroll;
        max-width: calc(100vw - 30px);
        flex-direction: initial;
    }

    .pg-conhecimento .tit-conteudo-base{
        flex-direction: column;
    }

    .tit-conteudo-base{
        flex-direction: column;
    }

    .tit-conteudo-base >div{
        flex-direction: column;
    }

    .tabela-conteudo{
        width: calc(100vw - 30px);
        overflow-x: scroll;
    }

    /* PAGINA WIDGET ///////////////////////////////////////////////////////////////*/



    /* PAGINA USUARIOS ///////////////////////////////////////////////////////////////*/

    .table-usuarios{
        width: calc(100vw - 30px);
    }

    .col-email, .col-user-name {
        max-width: 150px !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .pg-usuarios{
        flex-direction: column;
        align-items: flex-start;
    }

    .pg-usuarios button{
        margin-top: 15px;
    }

    /* PAGINA ADMIN ///////////////////////////////////////////////////////////////*/

    .bts-dominios-permitidos{
        flex-direction: column;
    }


}

.widget-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 999px;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 20px 40px -14px rgba(79, 70, 229, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.widget-launcher .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #34d399;
}

.widget-card {
    border-radius: 1rem;
    overflow: hidden;
}

.widget-chat-body {
    max-height: 420px;
    overflow-y: auto;
    padding: 1rem;
}

.widget-message {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    max-width: 85%;
}

.widget-message.agent {
    background: rgba(79, 70, 229, 0.1);
    margin-right: auto;
}

.widget-message.visitor {
    background: #4e46e54b;
    color: #fff;
    margin-left: auto;
}

.widget-typing {
    display: inline-flex;
    gap: 0.3rem;
}

.widget-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(79, 70, 229, 0.6);
    animation: typing 1s infinite ease-in-out;
}

.widget-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.widget-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.2;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar .nav-link i {
    width: 18px;
    font-size: 1.05rem;
}

.form-control, .form-select, .form-check-input{
    border-width: 2px !important;
    border-color: var(--sidebar-hover) !important;
}

.list-group-item.active{
    background-color: #cfd7e1;
    border-bottom-color: #a1a8b1;
    color: #000;
}

.cor-lista{
 gap: 10px
}

.cor-nota{
    background-color: #f0efcb;
    border-color: #d3d191 !important;
}

.card-link-wrapper {
    display: block;
    color: inherit;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card-link-wrapper:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    text-decoration: none;
}

#ticketsChart {
    width: 100% !important;
    max-height: 260px;
}

@media (max-width: 768px) {
    #ticketsChart {
        max-height: 220px;
    }

    .text-start{
        display: flex;
        flex-direction: column;
    }

    .text-start div{
        display: inline-block;
        max-width: 8ch; /* limita aproximadamente a 10 caracteres */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: top;
    }
}

/* Chart area fixes to avoid canvas resizing growing the container */
.chart-area {
    width: 100%;
    height: 260px;
    position: relative;
    overflow: hidden; /* evita scrolls e loops de redimensionamento */
}
.chart-area canvas {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

@media (max-width: 768px) {
    .chart-area { height: 220px; }
}


/* PÁGINA DASHBOARD */


/* Tooltip de URL para a coluna de campanhas */
.campaign-url-icon {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:28px;
    height:28px;
    border-radius:6px;
    background:transparent;
    color: #374151;
    cursor:pointer;
}
.campaign-url-icon:focus {
    outline: 2px solid rgba(59,130,246,0.6);
    outline-offset:2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Tooltip (sem scroll interno) */
.assistente-url-tooltip {
    position: absolute;
    z-index: 2147484000;
    background: #4f46e5; /* cor primária */
    color: #ffffff;
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15,23,42,0.4);
    max-width: 420px;
    display:flex;
    gap:10px;
    align-items:center;
    font-size:13px;
    line-height:1.2;
    word-break: break-word;
    white-space: normal;
    /* sem scroll interno: deixamos o conteúdo quebrar usando <wbr> */
}

/* URL texto: permitir quebra natural, sem barra de rolagem */
.assistente-url-tooltip .url-text {
    max-height: none;
    overflow: visible;
    word-break: break-all;
    white-space: normal;
}

/* botão/ícone que abre a URL em nova guia */
.assistente-url-tooltip .url-open {
    color: #fff;
    text-decoration:none;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:6px;
    border-radius:6px;
    background: rgba(255,255,255,0.08);
}
.assistente-url-tooltip .url-open i { font-size: 14px; }

/* ---------- PADRÃO ÚNICO PARA BADGES (padroniza tamanho, padding, gap, alinhamento) ---------- */
/* Regras consolidadas para todos os badges usados na tabela/listas */
.channel-badge,
.channel-count,
.campaign-badge,
.badge-origin-google-ads,
.badge-origin-google,
.badge-origin-direct,
.badge-origin-ref,
.campaign-badge {
    display: inline-flex;           /* alinhamento consistente (ícone + texto) */
    align-items: center;
    gap: 6px;                       /* espaço entre ícone e texto */
    padding: 4px 8px;               /* mesma "altura" visual */
    border-radius: 6px;
    font-weight: 700;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;            /* evitar quebra dentro do badge */
    vertical-align: middle;
    margin: 4px 8px 6px 0;          /* espaço entre badges; inclui margem inferior para formar linhas */
    min-height: 26px;
    box-sizing: border-box;
    flex-shrink: 0;                 /* evitar encolher em layouts apertados */
}

/* Garantir que badges em linhas apertadas quebrem em blocos (com margem inferior) */
.table td .channel-badge,
.table td .channel-count,
.table td .campaign-badge,
.table td .badge-origin-google-ads,
.table td .badge-origin-google,
.table td .badge-origin-direct,
.table td .badge-origin-ref {
    display: inline-flex;
}

/* Manter as cores específicas por tipo */
.channel-badge.whatsapp,
.channel-count.whatsapp { background: #10B981; color: #ffffff; }
.channel-badge.chat,
.channel-count.chat { background: var(--primary-color); color: #ffffff; }

.badge-origin-google-ads { background: #4285f4; color: #ffffff; }
.badge-origin-google     { background: #34a853; color: #ffffff; }
.badge-origin-direct     { background: #374151; color: #ffffff; }
.badge-origin-ref        { background: #0ea5e9; color: #ffffff; }



/* Ícones dentro dos badges: alinhamento e tamanho (gap já cobre espaçamento) */
.channel-badge i,
.channel-count i,
.campaign-badge i,
.badge-origin-google-ads i,
.badge-origin-google i,
.badge-origin-direct i,
.badge-origin-ref i {
    font-size: 0.95em;
    margin: 0;          /* gap no container já faz spacing */
    vertical-align: middle;
    color: inherit;
    opacity: 0.98;
}

/* Ajustes responsivos: reduzir padding/fonte/gap para telas pequenas e manter boa quebra de linhas */
@media (max-width: 768px) {
    .channel-badge,
    .channel-count,
    .campaign-badge,
    .badge-origin-google-ads,
    .badge-origin-google,
    .badge-origin-direct,
    .badge-origin-ref {
        gap: 5px;
        padding: 3px 7px;
        font-size: 10px;
        min-height: 22px;
        margin: 4px 6px 6px 0;
    }
    /* Forçar que as badges possam ocupar linhas múltiplas sem colidir com células vizinhas */
    .table td { word-break: break-word; }
}

/* Ajustes mais compactos para telas muito pequenas */
@media (max-width: 576px) {
    .channel-badge,
    .channel-count,
    .campaign-badge,
    .badge-origin-google-ads,
    .badge-origin-google,
    .badge-origin-direct,
    .badge-origin-ref {
        gap: 4px;
        padding: 3px 6px;
        font-size: 10px;
        min-height: 20px;
        margin: 0;
    }

    /* diminuir tamanho do ícone levemente */
    .channel-badge i,
    .channel-count i,
    .campaign-badge i,
    .badge-origin-google-ads i,
    .badge-origin-google i,
    .badge-origin-direct i,
    .badge-origin-ref i {
        font-size: 0.9em;
    }
}

/* garantir espaçamento consistente entre badges em tabelas/listas (fallback) */
.table .campaign-badge,
.table .channel-badge,
.table .channel-count,
.table .badge-origin-google-ads,
.table .badge-origin-google,
.table .badge-origin-direct,
.table .badge-origin-ref {
    margin-right: 6px;
    margin-bottom: 6px;
}

/* ========== TABELA RESPONSIVA: Conversões e Google Ads ========== */

/* Container wrapper para scroll horizontal APENAS na tabela */
.table-responsive-custom {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0;
    border-radius: 0.5rem;
}

.table-responsive-custom table {
    width: 100%;
    margin-bottom: 0;
}

/* Colunas com largura fixa e respirável (desktop) */
.table thead th.col-url,
.table tbody td.col-url-cell {
    white-space: nowrap;
}

.table thead th.col-keyword,
.table tbody td.col-keyword-cell {
    width: 180px;
    flex-shrink: 0;
}

.table thead th.col-ad,
.table tbody td.col-ad-cell {
    width: 180px;
    flex-shrink: 0;
}

.table thead th.col-origin,
.table tbody td.col-origin-cell {
    width: 300px;
    flex-shrink: 0;
}

.table thead th.col-datetime,
.table tbody td.col-datetime-cell {
    width: 160px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Célula de URL: ícone compacto */
.col-url-cell {
    text-align: center;
    padding: 0.6rem 0.5rem !important;
}

.col-keyword-cell,
.col-ad-cell {
    word-break: break-word;
    overflow-wrap: break-word;
    padding: 0.6rem 0.75rem !important;
}

/* Containers de badges: layout responsivo */
.badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Tabela: ajustes de padding compacto */
.table-responsive-custom .table > :not(caption) > * > * {
    padding: 0.6rem 0.5rem;
    vertical-align: middle;
}

/* ========== RESPONSIVIDADE MOBILE (768px e abaixo) ========== */

@media (max-width: 768px) {
    /* Permitir mais respiro nas colunas em mobile */
    .table thead th.col-url,
    .table tbody td.col-url-cell {
        width: 10px;
        flex-shrink: 0;
    }

    .table thead th.col-keyword,
    .table tbody td.col-keyword-cell {
        width: 130px;
        flex-shrink: 0;
    }

    .table thead th.col-ad,
    .table tbody td.col-ad-cell {
        width: 130px;
        flex-shrink: 0;
    }

    .table thead th.col-origin,
    .table tbody td.col-origin-cell {
        width: 200px;
        flex-shrink: 0;
    }

    .table thead th.col-datetime,
    .table tbody td.col-datetime-cell {
        width: 130px;
        flex-shrink: 0;
        white-space: normal;
        font-size: 0.75rem;
    }

    .col-url-cell {
        padding: 0.5rem 0.3rem !important;
        font-size: 0.85rem;
    }

    .col-keyword-cell,
    .col-ad-cell {
        font-size: 0.8rem;
        padding: 0.5rem 0.4rem !important;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Badges em mobile: permitir quebra */
    .badges-container {
        gap: 4px;
        flex-wrap: wrap;
    }

    .badges-container .badge-origin-google-ads i,
    .badges-container .badge-origin-google i,
    .badges-container .badge-origin-direct i,
    .badges-container .badge-origin-ref i,
    .badges-container .campaign-badge i,
    .badges-container .channel-badge i {
        font-size: 0.8em;
    }

    .link-referencia{
        max-width:120px;
        overflow:hidden;
        text-overflow:ellipsis;
    }

    .table thead th.col-url,
    .table tbody td.col-url-cell {
    width: 20px;
    max-width: 20px;
    white-space: nowrap;
}

}

/* ========== RESPONSIVIDADE EXTRA SMALL (576px e abaixo) ========== */

@media (max-width: 576px) {
    /* Colunas com largura confortável para scroll horizontal */
    .table-responsive-custom {
        font-size: 0.75rem;
        width: calc(100vw - 78px);
    }


    .table-responsive-custom table{
        width: 950px;
    }

    .table thead th.col-url,
    .table tbody td.col-url-cell {
        flex-shrink: 0;
        padding: 0.3rem 0.2rem !important;
    }

    .table thead th.col-keyword,
    .table tbody td.col-keyword-cell {
        width: 110px;
        flex-shrink: 0;
    }

    .table thead th.col-ad,
    .table tbody td.col-ad-cell {
        width: 110px;
        flex-shrink: 0;
    }

    .table thead th.col-origin,
    .table tbody td.col-origin-cell {
        width: 160px;
        flex-shrink: 0;
    }

    .table thead th.col-datetime,
    .table tbody td.col-datetime-cell {
        width: 65px;
        flex-shrink: 0;
        font-size: 0.7rem;
        padding: 0.3rem 0.2rem !important;
    }

    .col-keyword-cell,
    .col-ad-cell,
    .col-url-cell {
        padding: 0.3rem 0.2rem !important;
        font-size: 0.7rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .col-datetime-cell {
        text-align: right;
        white-space: normal;
    }

    /* Badges compactíssimos */
    .badges-container {
        gap: 2px;
        flex-wrap: wrap;
    }

    .badges-container .badge-origin-google-ads,
    .badges-container .badge-origin-google,
    .badges-container .badge-origin-direct,
    .badges-container .badge-origin-ref,
    .badges-container .campaign-badge,
    .badges-container .channel-badge {
        margin: 2px 3px 3px 0;
    }

    .badges-container .badge-origin-google-ads i,
    .badges-container .badge-origin-google i,
    .badges-container .badge-origin-direct i,
    .badges-container .badge-origin-ref i,
    .badges-container .campaign-badge i,
    .badges-container .channel-badge i {
        font-size: 0.75em;
        margin-right: 1px;
    }

    /* Remover espaçamento excessivo de tabela */
    .table-responsive-custom .table > :not(caption) > * > * {
        padding: 0.3rem 0.2rem;
        vertical-align: middle;
    }
}

/* Garantir cursor pointer para o badge de referência e para a classe usada nos badges */
.ref-tooltip,
.badge-origin-ref {
    cursor: pointer;
}

/* Botões extra-small para adicionar contatos */
.btn-xs {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.2;
    border-radius: 0.2rem;
}
