/* ==========================================================================
   ISP Control Panel — Admin (Tabler 1.6)
   Só ajustes finos sobre o Tabler; cores e componentes vêm do framework.
   ========================================================================== */

:root {
    --tblr-sidebar-width: 15.5rem;
}

/* ---------- Marca ---------- */
.sc-brand { display: inline-flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; }
.sc-brand:hover { text-decoration: none; opacity: .9; }
.sc-brand-mark {
    display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: .5rem;
    background: var(--tblr-primary); color: #fff; font-size: 1.15rem;
}
.sc-brand-name { font-weight: 600; font-size: 1rem; letter-spacing: -.01em; }

/* ---------- Sidebar ---------- */
.sc-nav .sc-nav-heading {
    padding: 1.1rem 1.25rem .35rem;
    font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--tblr-secondary);
}
.sc-nav .nav-link { gap: 0; border-radius: .375rem; margin: 1px .5rem; padding: .5rem .75rem; }
.sc-nav .nav-item.active > .nav-link { background: rgba(255, 255, 255, .08); color: #fff; }
.sc-nav .nav-item.active > .nav-link .nav-link-icon { color: var(--tblr-primary); opacity: 1; }
.sc-nav .badge { font-size: .6875rem; }
@media (max-width: 991.98px) {
    .navbar-vertical .navbar-collapse { max-height: calc(100vh - 3.5rem); overflow-y: auto; padding-bottom: 1rem; }
}

/* ---------- Barra superior ---------- */
.sc-topbar { min-height: 3.5rem; }
.sc-topbar .container-xl { gap: 1rem; }
.sc-search { flex: 1 1 auto; max-width: 34rem; }
.sc-search .form-control { background: var(--tblr-bg-surface-secondary); border-color: transparent; padding-right: 4rem; }
.sc-search .form-control:focus { background: var(--tblr-bg-surface); border-color: var(--tblr-primary); }
.sc-kbd {
    position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
    font-size: .6875rem; color: var(--tblr-secondary); border: 1px solid var(--tblr-border-color);
    border-radius: .25rem; padding: 0 .35rem; pointer-events: none;
}
.sc-ixc-pill {
    display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap;
    font-size: .75rem; font-weight: 500; padding: .3rem .7rem; border-radius: 999px; text-decoration: none;
}
.sc-ixc-pill:hover { text-decoration: none; }
.sc-ixc-pill.is-on  { background: var(--tblr-green-lt); color: var(--tblr-green); }
.sc-ixc-pill.is-off { background: var(--tblr-orange-lt); color: var(--tblr-orange); }
.sc-notify { width: 22rem; max-width: calc(100vw - 2rem); }

/* ---------- Switch claro/escuro ---------- */
.sc-theme-switch { display: inline-flex; align-items: center; gap: .35rem; margin: 0; cursor: pointer; color: var(--tblr-secondary); user-select: none; }
.sc-theme-switch .form-check { min-height: 0; padding-left: 2.5em; }
.sc-theme-switch .form-check-input { cursor: pointer; margin-top: 0; }
.sc-theme-switch .ti { font-size: 1.05rem; }
[data-bs-theme=dark] .sc-theme-switch .ti-moon,
html:not([data-bs-theme=dark]) .sc-theme-switch .ti-sun { color: var(--tblr-primary); }

/* ---------- Tema escuro: ajustes finos ---------- */
[data-bs-theme=dark] .navbar-vertical { border-right: 1px solid var(--tblr-border-color); }
[data-bs-theme=dark] .sc-search .form-control { background: var(--tblr-bg-surface); }
[data-bs-theme=dark] .sc-brand-mark { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
[data-bs-theme=dark] .table-hover > tbody > tr:hover > * { --tblr-table-bg-state: rgba(255, 255, 255, .03); }
[data-bs-theme=dark] .apexcharts-legend-text { color: var(--tblr-body-color) !important; }

/* ---------- Cabeçalho da página ---------- */
.page-body > .container-xl > .page-header,
.page-body > .container-xl > .alert + .page-header { margin: 0 0 1.25rem; padding: 0; min-height: 0; }
.page-body { margin-top: 1.25rem; }
.sc-back { display: inline-flex; align-items: center; gap: .25rem; font-size: .8125rem; color: var(--tblr-secondary); margin-bottom: .25rem; }
.sc-back:hover { color: var(--tblr-primary); text-decoration: none; }
@media (max-width: 767.98px) {
    .page-title { font-size: 1.15rem; }
    .sc-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
    .sc-actions > * { margin: 0 !important; }
    .sc-actions .btn { flex: 1 1 auto; }
}

/* ---------- Cards de indicadores ---------- */
.sc-stat { position: relative; height: 100%; }
.sc-stat .sc-stat-value { font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.sc-stat .min-w-0 { min-width: 0; }
@media (max-width: 575.98px) {
    .sc-stat .avatar { display: none; }
    .sc-stat .card-body { padding: .75rem .9rem; }
    .sc-stat .sc-stat-value { font-size: 1.15rem; }
}
.min-w-0 { min-width: 0; }
@media (max-width: 575.98px) {
    .sc-stat .avatar { display: none; }
    .sc-stat .card-body { padding: .75rem .9rem; }
    .sc-stat .sc-stat-value { font-size: 1.15rem; }
}
.row-cards > [class*="col"] > .card:only-child { height: 100%; }

/* ---------- Tabelas ---------- */
.table-vcenter > :not(caption) > * > * { vertical-align: middle; }
.table .sc-cell-main { font-weight: 500; color: var(--tblr-body-color); }
.table .sc-cell-sub { font-size: .75rem; color: var(--tblr-secondary); }
.table-responsive { -webkit-overflow-scrolling: touch; }
.sc-table-card .card-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.sc-table-card .pagination { margin: 0; flex-wrap: wrap; }
.font-monospace-num { font-family: var(--tblr-font-monospace); font-size: .8125rem; }
.text-tabular { font-variant-numeric: tabular-nums; }

/* Em telas pequenas, colunas marcadas somem para a tabela caber */
@media (max-width: 767.98px) {
    .table .sc-hide-sm { display: none; }
}
@media (max-width: 1199.98px) {
    .table .sc-hide-md { display: none; }
}

/* Telas originais com muitas colunas: esconde as secundárias no celular */
@media (max-width: 767.98px) {
    .sc-cols-tickets :is(th, td):is(:nth-child(2), :nth-child(4), :nth-child(5), :nth-child(7), :nth-child(8)),
    .sc-cols-fin :is(th, td):is(:nth-child(1), :nth-child(3), :nth-child(5)),
    .sc-cols-payments :is(th, td):is(:nth-child(1), :nth-child(3), :nth-child(5), :nth-child(6)),
    .sc-cols-audit :is(th, td):is(:nth-child(1), :nth-child(4), :nth-child(5), :nth-child(6)) { display: none; }
}
/* Listas IXC: no celular, nomes longos truncam mais cedo */
@media (max-width: 575.98px) {
    .table [style*="max-width: 15rem"], .table [style*="max-width: 16rem"] { max-width: 9.5rem !important; }
}

/* ---------- Filtros ---------- */
.sc-filters .form-label { font-size: .75rem; color: var(--tblr-secondary); margin-bottom: .25rem; }

/* ---------- Listas de definição (telas de detalhe) ---------- */
.sc-dl { display: grid; grid-template-columns: minmax(7rem, 38%) 1fr; gap: .55rem 1rem; margin: 0; }
.sc-dl dt { font-weight: 400; color: var(--tblr-secondary); }
.sc-dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
    .sc-dl { grid-template-columns: 1fr; gap: .1rem; }
    .sc-dl dd { margin-bottom: .5rem; }
}

/* ---------- Gráficos ---------- */
.sc-chart { min-height: 260px; }
.sc-chart-sm { min-height: 180px; }

/* ---------- Linha do tempo de OS ---------- */
.sc-progress-steps { display: flex; gap: .25rem; }
.sc-progress-steps > span { flex: 1; height: .3rem; border-radius: 1rem; background: var(--tblr-border-color); }
.sc-progress-steps > span.is-done { background: var(--tblr-primary); }

/* ---------- Código copiável ---------- */
.sc-copy { display: flex; gap: .5rem; align-items: stretch; }
.sc-copy code {
    flex: 1; min-width: 0; padding: .5rem .75rem; border-radius: .375rem; background: var(--tblr-bg-surface-secondary);
    font-size: .8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Data em destaque (agenda) ---------- */
.sc-date-badge { width: 2.5rem; line-height: 1.1; }

/* ---------- Blocos de código ---------- */
.sc-pre { white-space: pre-wrap; word-break: break-all; max-width: 100%; }

/* ---------- Faixa de modo demonstração ---------- */
.sc-demo-banner { border-left: 3px solid var(--tblr-orange); }

/* ---------- Impressão ---------- */
@media print {
    .navbar-vertical, .sc-topbar, .footer, .btn, .page-header .btn-list { display: none !important; }
    .page-wrapper { margin: 0 !important; }
}

/* Atendimentos do IXC (details/summary) */
.sc-details > summary { cursor: pointer; list-style: none; }
.sc-details > summary::-webkit-details-marker { display: none; }
.sc-details[open] > summary { margin-bottom: .25rem; }
.sc-note { background: var(--tblr-bg-surface-secondary); border-radius: var(--tblr-border-radius); padding: .6rem .75rem; }

/* Logo da marca: azul no tema claro, branca no escuro (e no menu escuro do painel) */
.sc-brand-logo { width: auto; max-width: 100%; display: inline-block; vertical-align: middle; }
.sc-brand-logo-dark { display: none; }
[data-bs-theme=dark] .sc-brand-logo-light, html[data-theme=dark] .sc-brand-logo-light { display: none; }
[data-bs-theme=dark] .sc-brand-logo-dark, html[data-theme=dark] .sc-brand-logo-dark { display: inline-block; }

/* Atendimento online (public/js/chat.js) */
.sc-chat-log { height: min(60vh, 34rem); overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.sc-chat-msg { max-width: 82%; align-self: flex-start; }
.sc-chat-msg.is-mine { align-self: flex-end; text-align: right; }
.sc-chat-meta { font-size: .75rem; opacity: .65; margin: 0 .25rem .15rem; }
.sc-chat-bubble { display: inline-block; text-align: left; padding: .55rem .8rem; border-radius: 1rem; white-space: pre-line; overflow-wrap: anywhere; background: rgba(127, 127, 127, .12); }
.sc-chat-msg.is-mine .sc-chat-bubble { background: var(--sc-brand, #1e5bd6); color: #fff; border-bottom-right-radius: .3rem; }
.sc-chat-msg:not(.is-mine) .sc-chat-bubble { border-bottom-left-radius: .3rem; }
.sc-chat-ai .sc-chat-bubble { background: rgba(30, 91, 214, .1); }
.sc-chat-system { align-self: center; max-width: 92%; text-align: center; }
.sc-chat-system .sc-chat-bubble { background: transparent; border: 1px dashed rgba(127, 127, 127, .35); font-size: .85rem; opacity: .85; }
.sc-chat-typing { padding: 0 1rem .5rem; font-size: .8rem; opacity: .7; }
.sc-chat-typing span { display: inline-block; width: .35rem; height: .35rem; margin-right: .1rem; border-radius: 50%; background: currentColor; animation: sc-chat-dot 1s infinite ease-in-out; }
.sc-chat-typing span:nth-child(2) { animation-delay: .15s; }
.sc-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes sc-chat-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.sc-chat-form { display: flex; gap: .5rem; align-items: flex-end; padding: .75rem 1rem 1rem; border-top: 1px solid rgba(127, 127, 127, .15); }
.sc-chat-form textarea { resize: none; max-height: 8rem; }
.sc-chat-form.is-sending { opacity: .6; pointer-events: none; }
.sc-chat-fab { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 1040; border-radius: 2rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
@media (prefers-reduced-motion: reduce) { .sc-chat-typing span { animation: none; } }

/* Respostas formatadas da IA (ChatFormatter): parágrafos, listas, tabelas e botões */
.sc-chat-bubble.is-rich { white-space: normal; }
.sc-chat-bubble.is-rich > :last-child, .sc-chat-bubble.is-rich p:last-child { margin-bottom: 0; }
.sc-chat-bubble.is-rich p { margin: 0 0 .5rem; }
.sc-chat-bubble.is-rich ul, .sc-chat-bubble.is-rich ol { margin: .25rem 0 .5rem; padding-left: 1.2rem; }
.sc-chat-bubble.is-rich table { width: 100%; margin: .35rem 0 .5rem; border-collapse: collapse; font-size: .875rem; display: block; overflow-x: auto; }
.sc-chat-bubble.is-rich th, .sc-chat-bubble.is-rich td { padding: .35rem .6rem; border-bottom: 1px solid rgba(127, 127, 127, .25); text-align: left; white-space: nowrap; }
.sc-chat-bubble.is-rich th { font-weight: 600; opacity: .8; }
.sc-chat-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.sc-chat-actions .btn { border-radius: 2rem; }
.sc-chat-avatar { width: 44px; height: 44px; border-radius: 50%; background: #fff; padding: 3px; box-shadow: 0 0 0 1px rgba(127, 127, 127, .2); flex-shrink: 0; }

/* Emilly: avatar nas mensagens, no "escrevendo…" e no botão flutuante */
.sc-chat-msg.sc-chat-ai { display: flex; align-items: flex-end; gap: .5rem; }
.sc-chat-msg-avatar { width: 30px; height: 30px; border-radius: 50%; background: #fff; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(127, 127, 127, .2); }
.sc-chat-content { min-width: 0; }
.sc-chat-typing img { width: 20px; height: 20px; border-radius: 50%; background: #fff; vertical-align: middle; margin-right: .25rem; }
.sc-chat-avatar { padding: 0; }
.sc-chat-hero { text-align: center; padding: 1rem 1rem 0; }
.sc-chat-hero img { width: 170px; height: auto; max-width: 60%; }
.sc-chat-fab { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem 1rem .35rem .35rem; font-weight: 600; }
.sc-chat-fab img { width: 34px; height: 34px; border-radius: 50%; background: #fff; }

/* Identidade visual (Configurações): prévia das logos */
.sc-brand-preview { height: 72px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--tblr-border-color); border-radius: var(--tblr-border-radius); padding: .5rem; }
.sc-brand-preview img { max-height: 100%; max-width: 100%; object-fit: contain; }

/* Suporte técnico do painel: respostas do desenvolvedor */
.sc-chat-dev .sc-chat-bubble { background: rgba(47, 179, 68, .14); }

/* Mapa da rede (public/js/map.js) */
.sc-map { position: relative; height: calc(100vh - 210px); min-height: 520px; border-radius: var(--tblr-border-radius-lg); overflow: hidden; border: 1px solid var(--tblr-border-color); background: var(--tblr-bg-surface-secondary); }
.sc-map:fullscreen { height: 100vh; border-radius: 0; }
.sc-map .sc-map-canvas { position: absolute; inset: 0; } /* mais específico que .maplibregl-map (position: relative) */
.sc-map-loading { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; gap: .75rem; background: color-mix(in srgb, var(--tblr-bg-surface) 70%, transparent); z-index: 5; }
.sc-map.is-loading .sc-map-loading { display: flex; }
.sc-map-panel { position: absolute; top: .75rem; left: .75rem; bottom: .75rem; width: 300px; overflow-y: auto; z-index: 4; box-shadow: 0 6px 24px rgba(0, 0, 0, .15); }
.sc-map-panel-toggle { position: absolute; top: .75rem; left: calc(300px + 1.25rem); z-index: 4; background: var(--tblr-bg-surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.sc-map.is-panel-closed .sc-map-panel { display: none; }
.sc-map.is-panel-closed .sc-map-panel-toggle { left: .75rem; }
.sc-map-results:empty { display: none; }
.sc-map-results { max-height: 14rem; overflow-y: auto; margin-top: .25rem; border: 1px solid var(--tblr-border-color); border-radius: var(--tblr-border-radius); }
.sc-map-results .list-group-item { display: flex; align-items: center; gap: .5rem; text-align: left; }
.sc-map-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; flex-shrink: 0; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.sc-map-dot-ring { background: #fff; border: 2.5px solid #ae3ec9; }
.sc-map-summary { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.sc-map-summary > div { background: var(--tblr-bg-surface-secondary); border-radius: var(--tblr-border-radius); padding: .5rem .6rem; }
.sc-map-summary span { display: block; font-size: .72rem; color: var(--tblr-secondary); }
.sc-map-summary strong { font-size: 1.15rem; }
.sc-map .maplibregl-popup-content { padding: .75rem .9rem; border-radius: .6rem; background: var(--tblr-bg-surface); color: var(--tblr-body-color); box-shadow: 0 6px 24px rgba(0, 0, 0, .2); }
.sc-map .maplibregl-popup-tip { border-top-color: var(--tblr-bg-surface) !important; border-bottom-color: var(--tblr-bg-surface) !important; }
.sc-map-pop-title { font-weight: 600; margin-bottom: .35rem; padding-right: 1rem; }
.sc-map-pop-badge { display: inline-block; color: #fff; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 1rem; margin-bottom: .4rem; }
.sc-map-pop-row { display: flex; justify-content: space-between; gap: .75rem; font-size: .82rem; padding: .15rem 0; }
.sc-map-pop-row span { color: var(--tblr-secondary); }
.sc-map-pop-row strong { text-align: right; overflow-wrap: anywhere; }
.sc-map-pop-list { max-height: 14rem; overflow-y: auto; display: grid; gap: .2rem; }
.sc-map-pop-list a { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
@media (max-width: 767.98px) {
    .sc-map { height: calc(100vh - 170px); }
    .sc-map-panel { width: auto; right: .75rem; bottom: auto; max-height: 60%; }
    .sc-map-panel-toggle { left: auto; right: 3.5rem; }
    .sc-map:not(.is-panel-closed) .sc-map-panel-toggle { top: auto; bottom: .75rem; right: .75rem; }
}
.sc-map.sc-map-compact { height: 340px; min-height: 0; border: 0; border-radius: 0; }
