:root {
    --sidebar-w: 260px;
}

/* ========================= */
/* Sidebar e navegação */
/* ========================= */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    position: sticky;
    top: 0;
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 1040;
        width: var(--sidebar-w);
    }

        .sidebar.show {
            transform: translateX(0);
        }

    body {
        overflow-x: hidden;
    }
}

.nav-link {
    padding: .65rem 1rem;
    color: var(--bs-body-color);
}

    .nav-link:hover, .nav-link.active {
        background: var(--bs-secondary-bg);
    }

    .nav-link.active {
        background-color: rgba(13,110,253,0.08);
        border-radius: 6px;
    }

/* ========================= */
/* KPI Cards */
/* ========================= */
.card-kpi .kpi {
    font-size: clamp(1.6rem, 2.5vw, 2.2rem);
    font-weight: 700;
}

/* ========================= */
/* Chat básico */
/* ========================= */
.chat-preview {
    height: 420px;
    overflow: auto;
}

.chat-bubble {
    max-width: 75%;
    padding: .6rem .8rem;
    border-radius: 12px;
}

    .chat-bubble.bot {
        background: var(--bs-secondary-bg);
    }

    .chat-bubble.user {
        background: var(--bs-primary-bg-subtle);
        border: 1px solid var(--bs-primary-border-subtle);
    }

/* ========================= */
/* Layout de Atendimento */
/* ========================= */
.atd-wrap {
    display: grid;
    grid-template-columns: 320px 1fr 320px;
    gap: 12px;
    min-height: calc(100vh - 210px);
}

@media (max-width: 1199.98px) {
    .atd-wrap {
        grid-template-columns: 1fr;
    }
}

.atd-col {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.atd-head {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-secondary-bg);
}

.atd-body {
    padding: .75rem;
    overflow: auto;
}

.atd-list .item {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--bs-border-color);
    cursor: pointer;
}

    .atd-list .item:hover {
        background: var(--bs-secondary-bg);
    }

    .atd-list .item.active {
        background: var(--bs-primary-bg-subtle);
        border-left: 3px solid var(--bs-primary);
    }

.atd-footer {
    padding: .75rem;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
}

/* ========================= */
/* Tabelas e edição inline */
/* ========================= */
.table thead {
    background: var(--bs-body-bg);
}

    .table thead th {
        border-bottom: 1px solid var(--bs-border-color) !important;
    }

    .table thead [data-sort].btn-link {
        color: var(--bs-body-color);
        text-decoration: none;
        padding: 0;
    }

        .table thead [data-sort].btn-link:hover,
        .table thead [data-sort].btn-link:focus {
            text-decoration: underline;
        }

.pagination .page-link {
    cursor: pointer;
}

tr.is-editing {
    /* fallback estável sem color-mix */
    background: var(--bs-primary-bg-subtle);
    transition: background-color .15s ease;
}

.inline-edit .form-control.form-control-sm {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
    height: 32px;
    padding: .25rem .5rem;
}

    .inline-edit .form-control.form-control-sm:focus {
        border-color: var(--bs-primary);
        box-shadow: 0 0 0 .15rem rgba(13,110,253,.15);
    }

.inline-edit .btn {
    min-width: 34px;
}

tr.is-saving {
    position: relative;
    opacity: .7;
    cursor: progress;
}

    tr.is-saving::after {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
    }

.table-hover tbody tr:hover {
    background: var(--bs-secondary-bg);
}

.text-muted-soft {
    color: var(--bs-secondary-color) !important;
}

/* ========================= */
/* Logos – alternância tema */
/* ========================= */
.logo-dark {
    display: none;
}

.logo-light {
    display: inline;
}

html[data-bs-theme="dark"] .logo-dark {
    display: inline;
}

html[data-bs-theme="dark"] .logo-light {
    display: none;
}

/* ========================= */
/* Chat Drawer refinado */
/* ========================= */

/* bolhas gerais */
.bubble-in, .bubble-out {
    max-width: 75%;
    border-radius: .9rem;
    margin: .25rem 0;
    padding: .55rem .75rem;
    display: flex;
    flex-direction: column;
}

.bubble-in {
    /* tom claro estável em qualquer tema */
    background: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
}

.bubble-out {
    background: var(--bs-primary-bg-subtle);
    border: 1px solid var(--bs-primary-border-subtle);
    color: var(--bs-body-color);
    margin-left: auto;
}

/* mídia embutida dentro da bolha (card leve) */
[data-wppid] .p-2.rounded-3 > .p-2.rounded-3 {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .65rem;
}

/* imagens / vídeos */
.offcanvas img.img-fluid.rounded-3 {
    max-height: 360px;
    object-fit: contain;
}

.offcanvas video {
    max-width: 100%;
    max-height: 360px;
    border-radius: .5rem;
    display: block;
}

/* áudio refinado */
.offcanvas audio {
    width: 100%;
    display: block;
    border-radius: .5rem;
    background: var(--bs-body-bg);
    margin-top: .15rem;
}

    .offcanvas audio::-webkit-media-controls-enclosure {
        border-radius: .5rem;
        background: transparent;
    }

/* hora + status */
.offcanvas .small.mt-1.opacity-75 {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-top: .35rem !important;
}

.offcanvas .msg-status i {
    opacity: .9;
}

/* hover leve sem color-mix */
.bubble-in:hover, .bubble-out:hover {
    filter: brightness(1.03);
    transition: filter .2s ease;
}

/* scrollbar sutil dentro do chat */
.offcanvas .offcanvas-body::-webkit-scrollbar {
    width: 6px;
}

.offcanvas .offcanvas-body::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
    border-radius: 3px;
}

/* ========================= */
/* Dropzone (upload no chat) */
/* ========================= */

/* Área alvo para dragover no drawer */
#chatDrawer.dropzone-active .offcanvas-body {
    position: relative;
}

/* Overlay de destaque durante drag */
#chatDrawer .drop-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    background: color-mix(in oklab, var(--bs-primary) 8%, transparent);
    border: 2px dashed var(--bs-primary);
    border-radius: .5rem;
    backdrop-filter: blur(1px);
}

html:not(:has(#___dummy)) /* isolado para compat */ #chatDrawer.dropzone-active .drop-overlay {
    display: flex;
}

#chatDrawer .drop-overlay .drop-msg {
    text-align: center;
    padding: .75rem 1rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .65rem;
    box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

    #chatDrawer .drop-overlay .drop-msg .title {
        font-weight: 600;
        margin-bottom: .25rem;
    }

    #chatDrawer .drop-overlay .drop-msg .hint {
        color: var(--bs-secondary-color);
        font-size: .9rem;
    }

/* Pills de anexos na área de preview (abaixo do input) */
#attachPreview {
    background: var(--bs-secondary-bg);
    border: 1px dashed var(--bs-border-color);
    border-radius: .5rem;
}

/* Cada arquivo (pill) */
.file-pill {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: .5rem .5rem;
    align-items: center;
    padding: .4rem .5rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    margin-top: .5rem;
}

    .file-pill:first-child {
        margin-top: 0;
    }

.file-icon {
    width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
}

.file-name {
    font-weight: 600;
    line-height: 1.2;
    word-break: break-all;
}

.file-meta {
    grid-column: 2 / span 1;
    font-size: .8rem;
    color: var(--bs-secondary-color);
}

/* Barra de progresso */
.file-progress {
    grid-column: 1 / -1;
}

    .file-progress .progress {
        height: .5rem;
        background: var(--bs-secondary-bg);
    }

    .file-progress .progress-bar {
        transition: width .2s linear;
    }

/* Ações do arquivo (remover, etc.) */
.file-actions {
    display: flex;
    gap: .35rem;
}

    .file-actions .btn {
        --bs-btn-padding-y: .15rem;
        --bs-btn-padding-x: .35rem;
        --bs-btn-font-size: .8rem;
    }

/* Estados */
.file-pill.is-uploading {
    opacity: .85;
}

.file-pill.is-error {
    border-color: var(--bs-danger);
    box-shadow: 0 0 0 .15rem rgba(220,53,69,.08);
}

.file-pill.is-done {
    border-color: var(--bs-success);
}

/* mini thumbnails */
.file-thumb {
    width: 32px;
    height: 32px;
    border-radius: .35rem;
    object-fit: cover;
    border: 1px solid var(--bs-border-color);
}

/* Input nativo escondido se for utilizado no dropzone personalizado */
.input-file-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Botão anexar com feedback leve ao arrastar */
#btnAttach.drag-ready {
    outline: 2px dashed var(--bs-primary);
    outline-offset: 2px;
}
