/* =========================================================================
   SOLV - estilos. As cores vêm de variaveis; cada tema (html[data-tema]) so
   troca esse conjunto. Temas: solv (padrao), insight, resolve, eureka, enigma (escuro).
   ========================================================================= */
:root,
html[data-tema="solv"] {
  --brand: #e67817;
  --brand-dark: #c4630f;
  --brand-soft: #fdf1e6;
  --brand-rgb: 230, 120, 23;
  --on-brand: #ffffff;
  --link: #c4630f;
  --ink: #2a2a2a;
  --ink-soft: #555555;
  --muted: #6b6b6b;
  --bg: #f5f5f6;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --card-border: #e6e6e8;
  --login-from: #e67817;
  --login-to: #b9560a;
  --note-bg: #fffbeb;
  --note-border: #fcd34d;
  --chip-bg: #f1f5f9;
  --bar-bg: #efeff1;
  --avatar: #b5b5b8;
}

html[data-tema="solvdark"] {
  --brand: #e67817;
  --brand-dark: #c4630f;
  --brand-soft: #3a2616;
  --brand-rgb: 230, 120, 23;
  --on-brand: #ffffff;
  --link: #f5a04d;
  --ink: #ececec;
  --ink-soft: #c4c4c8;
  --muted: #92929a;
  --bg: #141414;
  --surface: #1e1e1f;
  --surface-2: #252527;
  --card-border: #333336;
  --login-from: #1a1a1c;
  --login-to: #5a2d0b;
  --note-bg: #3a2f10;
  --note-border: #8a6b14;
  --chip-bg: #2a2a2d;
  --bar-bg: #3a3a3e;
  --avatar: #6b6b72;
}

html[data-tema="insight"] {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eaf1ff;
  --brand-rgb: 37, 99, 235;
  --on-brand: #ffffff;
  --link: #1d4ed8;
  --ink: #1e293b;
  --ink-soft: #475569;
  --muted: #64748b;
  --bg: #f1f5fb;
  --surface: #ffffff;
  --surface-2: #f6f9fe;
  --card-border: #dfe6f1;
  --login-from: #2563eb;
  --login-to: #1e3a8a;
  --chip-bg: #eef2f9;
  --bar-bg: #e4eaf5;
  --avatar: #a9b6cc;
}

html[data-tema="resolve"] {
  --brand: #059669;
  --brand-dark: #047857;
  --brand-soft: #e6f6ef;
  --brand-rgb: 5, 150, 105;
  --on-brand: #ffffff;
  --link: #047857;
  --ink: #1f2d28;
  --ink-soft: #476057;
  --muted: #62786f;
  --bg: #f1f6f3;
  --surface: #ffffff;
  --surface-2: #f6faf8;
  --card-border: #dce8e2;
  --login-from: #059669;
  --login-to: #064e3b;
  --chip-bg: #edf4f0;
  --bar-bg: #e0ebe5;
  --avatar: #a7bbb2;
}

html[data-tema="eureka"] {
  --brand: #7c3aed;
  --brand-dark: #6d28d9;
  --brand-soft: #f1eafe;
  --brand-rgb: 124, 58, 237;
  --on-brand: #ffffff;
  --link: #6d28d9;
  --ink: #2a2140;
  --ink-soft: #564a73;
  --muted: #72678c;
  --bg: #f5f2fb;
  --surface: #ffffff;
  --surface-2: #faf8fe;
  --card-border: #e5dff3;
  --login-from: #7c3aed;
  --login-to: #4c1d95;
  --chip-bg: #f0ecf8;
  --bar-bg: #e7e1f3;
  --avatar: #b5aacb;
}

html[data-tema="enigma"] {
  --brand: #2dd4bf;
  --brand-dark: #14b8a6;
  --brand-soft: #12343a;
  --brand-rgb: 45, 212, 191;
  --on-brand: #052e2b;
  --link: #5eead4;
  --ink: #e6ebf5;
  --ink-soft: #b8c3d9;
  --muted: #8d9ab4;
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #18233a;
  --card-border: #263552;
  --login-from: #0f172a;
  --login-to: #1f3a5f;
  --note-bg: #3a2f10;
  --note-border: #8a6b14;
  --chip-bg: #1c2a45;
  --bar-bg: #263552;
  --avatar: #5c6b88;
}

:root {
  --sidebar-w: 250px;
  --st-aberto: #2563eb;
  --st-em_analise: #7c3aed;
  --st-em_andamento: #0891b2;
  --st-aguardando_cliente: #db2777;
  --st-aguardando_terceiros: #64748b;
  --st-concluido: #16a34a;
  --st-cancelado: #414141;
}

/* Liga as variaveis do tema ao Bootstrap (inputs, cards, tabelas, listas, menus) */
html[data-tema] {
  --bs-body-bg: var(--surface);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--card-border);
  --bs-secondary-color: var(--muted);
  --bs-emphasis-color: var(--ink);
  --bs-secondary-bg: var(--surface-2);
  --bs-tertiary-bg: var(--surface-2);
  --bs-link-color: var(--link);
  --bs-link-hover-color: var(--brand-dark);
}

body { background: var(--bg); color: var(--ink); font-size: .94rem; font-family: 'Roboto', Helvetica, Arial, sans-serif; }
a { color: var(--link); }
.btn { font-weight: 500; }
.btn-primary { --bs-btn-color: var(--on-brand); --bs-btn-hover-color: var(--on-brand); --bs-btn-active-color: var(--on-brand); --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); --bs-btn-disabled-color: var(--on-brand); --bs-btn-focus-shadow-rgb: var(--brand-rgb); }
.btn-outline-primary { --bs-btn-color: var(--link); --bs-btn-border-color: var(--brand); --bs-btn-hover-color: var(--on-brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-color: var(--on-brand); --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark); --bs-btn-focus-shadow-rgb: var(--brand-rgb); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .22); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .22); }
.text-bg-primary { background-color: var(--brand) !important; color: var(--on-brand) !important; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.page-link { color: var(--link); background-color: var(--surface); border-color: var(--card-border); }
.page-link:focus { box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .22); }
.page-item.disabled .page-link { background-color: var(--surface-2); }
.spinner-border { color: var(--brand); }
.bg-white { background-color: var(--surface) !important; }

/* ---- Sidebar (equipe e cliente) ---- */
.sidebar { background: var(--surface); --bs-offcanvas-bg: var(--surface); color: var(--ink-soft); border-right: 1px solid var(--card-border); }
.sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: 1rem .75rem; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: .65rem; color: var(--ink); padding: .1rem .5rem 1.1rem; margin-bottom: .5rem; border-bottom: 1px solid var(--card-border); }
.sidebar .brand a { display: inline-flex; }
.sidebar .brand img { height: 58px; width: auto; }
.sidebar .nav-link { color: var(--ink-soft); font-weight: 500; border-radius: .5rem; padding: .55rem .75rem; display: flex; align-items: center; gap: .65rem; }
.sidebar .nav-link:hover { background: var(--brand-soft); color: var(--link); }
.sidebar .nav-link.active { background: var(--brand); color: var(--on-brand); }
.sidebar-rodape { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--card-border); }
.sidebar .usuario { display: flex; gap: .6rem; align-items: center; padding: 0 .5rem .5rem; color: var(--ink); }
.sidebar .usuario .dados { min-width: 0; flex: 1; line-height: 1.25; }
.sidebar .usuario .dados strong, .sidebar .usuario .dados small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .usuario > i { font-size: 1.7rem; color: var(--avatar); }
.sidebar .usuario small { display: block; color: var(--muted); }
.topbar { position: sticky; top: 0; z-index: 1020; background: var(--surface); border-bottom: 1px solid var(--card-border); display: flex; align-items: center; gap: .6rem; padding: .4rem .75rem; }
.topbar img { height: 38px; width: auto; }
.topbar .btn-light { background: transparent; border-color: transparent; color: var(--ink); }
@media (min-width: 992px) {
  /* o .offcanvas-lg do Bootstrap zera fundo/largura/altura com !important no desktop */
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w) !important; height: 100vh !important; background-color: var(--surface) !important; border-right: 1px solid var(--card-border) !important; z-index: 1030; visibility: visible !important; transform: none !important; }
  .conteudo { margin-left: var(--sidebar-w); }
  .sidebar-inner { width: 100%; }
}
@media (max-width: 991.98px) { .sidebar { --bs-offcanvas-width: 270px; } }

/* Empresa que o usuario do cliente representa */
.empresa-card { display: flex; align-items: center; gap: .65rem; margin: .1rem .25rem 1rem; padding: .6rem .75rem; border: 1px solid var(--card-border); border-left: 4px solid var(--brand); border-radius: .6rem; background: var(--surface-2); }
.empresa-card > i { font-size: 1.4rem; color: var(--brand); }
.empresa-card small { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.empresa-card strong { display: block; line-height: 1.2; word-break: break-word; color: var(--ink); }

/* ---- Logo claro/escuro ---- */
.logo-escuro { display: none; }
html[data-bs-theme="dark"] .logo-claro { display: none; }
html[data-bs-theme="dark"] .logo-escuro { display: inline-block; }

/* ---- Login ---- */
.pagina-simples { position: relative; background: linear-gradient(135deg, var(--login-from) 0%, var(--login-to) 100%); min-height: 100vh; display: flex; align-items: center; }
.pagina-simples main { max-width: 440px; }
.login-card { border: 0; border-radius: .75rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.login-logo { height: 108px; width: auto; }
.tema-login { position: absolute; top: 1rem; right: 1rem; z-index: 5; }
.tema-login .seletor-tema-btn { color: #fff; background: rgba(255, 255, 255, .18); border-radius: .5rem; padding: .4rem .8rem; }
.tema-login .seletor-tema-btn:hover { background: rgba(255, 255, 255, .3); color: #fff; }

/* ---- Seletor de tema ---- */
.seletor-tema .seletor-tema-btn { background: none; border: 0; display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.seletor-tema .dropdown-menu { min-width: 15.5rem; border-color: var(--card-border); }
.seletor-tema .dropdown-item { padding: .45rem .75rem; }
.seletor-tema .dropdown-item small { font-size: .72rem; }
.seletor-tema .dropdown-item .marca-tema { visibility: hidden; color: var(--brand); font-size: 1.1rem; }
.seletor-tema .dropdown-item.ativo { background: var(--brand-soft); }
.seletor-tema .dropdown-item.ativo .marca-tema { visibility: visible; }
.amostra-tema { width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px; background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%); border: 1px solid rgba(128, 128, 128, .45); }

/* ---- Cards e titulos ---- */
.card { --bs-card-bg: var(--surface); --bs-card-border-color: var(--card-border); border: 1px solid var(--card-border); border-radius: .75rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--card-border); font-weight: 600; }
.card-footer { border-top-color: var(--card-border); }
.page-title { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-sub { color: var(--muted); }
.page-sub .empresa-tag { display: inline-flex; align-items: center; gap: .3rem; font-weight: 500; color: var(--ink-soft); }

/* ---- Cards de indicadores ---- */
.stat-card { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--card-border); border-left: 4px solid var(--cor, var(--brand)); border-radius: .75rem; padding: .9rem 1rem; height: 100%; transition: transform .12s, box-shadow .12s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 24, 40, .12); color: inherit; }
.stat-card .rotulo { color: var(--muted); font-size: .8rem; display: flex; justify-content: space-between; align-items: center; }
.stat-card .rotulo i { color: var(--cor, var(--brand)); font-size: 1.1rem; }
.stat-card .valor { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.chart-box { position: relative; height: 270px; }

/* ---- Badges ---- */
.badge-status { font-weight: 600; padding: .4em .65em; color: #fff; }
.st-aberto { background: var(--st-aberto); }
.st-em_analise { background: var(--st-em_analise); }
.st-em_andamento { background: var(--st-em_andamento); }
.st-aguardando_cliente { background: var(--st-aguardando_cliente); }
.st-aguardando_terceiros { background: var(--st-aguardando_terceiros); }
.st-concluido { background: var(--st-concluido); }
.st-cancelado { background: var(--st-cancelado); }
.badge-prio { font-weight: 600; padding: .4em .65em; }
.pr-baixa { background: #e2e8f0; color: #334155; }
.pr-normal { background: #dbeafe; color: #1e40af; }
.pr-alta { background: #fed7aa; color: #9a3412; }
.pr-urgente { background: #fecaca; color: #991b1b; }
html[data-bs-theme="dark"] .pr-baixa { background: rgba(148, 163, 184, .22); color: #cbd5e1; }
html[data-bs-theme="dark"] .pr-normal { background: rgba(96, 165, 250, .22); color: #bfdbfe; }
html[data-bs-theme="dark"] .pr-alta { background: rgba(251, 146, 60, .24); color: #fed7aa; }
html[data-bs-theme="dark"] .pr-urgente { background: rgba(248, 113, 113, .26); color: #fecaca; }
html[data-bs-theme="dark"] .text-bg-light { background-color: var(--surface-2) !important; color: var(--ink) !important; }
html[data-bs-theme="dark"] .text-bg-secondary { background-color: #3b4a68 !important; }

/* ---- Busca / filtros ---- */
.busca-destaque .form-control { font-size: 1.05rem; padding: .7rem 1rem; }
.busca-destaque .input-group-text { background: var(--surface); }
.filtros label { font-size: .78rem; color: var(--muted); margin-bottom: .15rem; }

/* ---- Meses (acordeao) ---- */
.mes-item { background: var(--surface); border: 1px solid var(--card-border); border-radius: .75rem; margin-bottom: .6rem; overflow: hidden; }
.mes-item .mes-cab { width: 100%; text-align: left; background: none; border: 0; color: var(--ink); padding: .8rem 1rem; display: flex; align-items: center; gap: .75rem; font-weight: 600; }
.mes-item .mes-cab .contador { margin-left: auto; }
.mes-item .mes-cab .seta { transition: transform .15s; color: var(--muted); }
.mes-item .mes-cab:not(.collapsed) .seta { transform: rotate(90deg); }
.mes-item .mes-cab:not(.collapsed) { background: var(--brand-soft); }
.mes-item.mes-atual .mes-cab::after { content: 'mês atual'; font-size: .68rem; font-weight: 600; background: var(--brand); color: var(--on-brand); padding: .1rem .45rem; border-radius: 1rem; order: 2; }
.mes-item .mes-cab .contador { order: 3; }
.mes-corpo { border-top: 1px solid var(--card-border); }
.mes-carregando { padding: 1.5rem; text-align: center; color: var(--muted); }

/* ---- Tabelas ---- */
.tabela-chamados { margin: 0; }
.tabela-chamados th { font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface-2); }
.tabela-chamados th a { color: inherit; text-decoration: none; }
.tabela-chamados th a:hover { color: var(--link); }
.tabela-chamados td { vertical-align: middle; }
.tabela-chamados .protocolo { font-weight: 600; white-space: nowrap; }
.tabela-chamados .cliente { min-width: 140px; }
.tabela-chamados .assunto { max-width: 340px; }
.tabela-chamados .assunto small { display: block; color: var(--muted); }
.atrasado { color: #dc2626; }
html[data-bs-theme="dark"] .atrasado { color: #f87171; }

/* ---- Linha do tempo ---- */
.timeline { position: relative; margin: 0; padding: 0 0 0 1.6rem; list-style: none; }
.timeline::before { content: ''; position: absolute; left: .55rem; top: .3rem; bottom: .3rem; width: 2px; background: var(--card-border); }
.timeline > li { position: relative; margin-bottom: 1rem; }
.timeline > li::before { content: ''; position: absolute; left: -1.6rem; top: .7rem; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); margin-left: 1px; }
.timeline > li.evento::before { border-color: #94a3b8; width: 10px; height: 10px; top: .45rem; margin-left: 2px; }
.timeline > li.interna::before { border-color: #f59e0b; }
.timeline > li.do-cliente::before { border-color: #7c3aed; }
.msg { background: var(--surface); border: 1px solid var(--card-border); border-radius: .75rem; padding: .75rem 1rem; }
.msg.interna { background: var(--note-bg); border-color: var(--note-border); }
.msg-cab { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-bottom: .35rem; font-size: .85rem; }
.msg-cab .data { color: var(--muted); margin-left: auto; font-size: .78rem; }
.msg-texto { white-space: normal; word-break: break-word; }
.evento-linha { color: var(--muted); font-size: .84rem; padding: .15rem 0; }
.anexos { display: flex; flex-wrap: wrap; gap: .4rem; }
.anexo { display: inline-flex; align-items: center; gap: .35rem; background: var(--chip-bg); border: 1px solid var(--card-border); border-radius: .5rem; padding: .2rem .6rem; text-decoration: none; font-size: .83rem; color: var(--ink); }
.anexo:hover { background: var(--brand-soft); }

.detalhes dt { font-weight: 500; color: var(--muted); font-size: .8rem; }
.detalhes dd { margin-bottom: .65rem; }
.sem-registros { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.sem-registros i { font-size: 2rem; display: block; margin-bottom: .4rem; opacity: .6; }

@media (max-width: 575.98px) {
  .page-title { font-size: 1.2rem; }
  .stat-card .valor { font-size: 1.5rem; }
  .tabela-chamados .assunto { max-width: 200px; }
}

/* ---- Olho de mostrar/ocultar senha ---- */
.senha-campo { position: relative; }
.senha-campo .form-control { padding-right: 2.9rem; }
.senha-campo input::-ms-reveal, .senha-campo input::-ms-clear { display: none; }
.senha-olho { position: absolute; top: 0; right: 0; height: 100%; width: 2.9rem; border: 0; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 1.15rem; border-radius: 0 .375rem .375rem 0; }
.senha-olho:hover { color: var(--link); }
.senha-olho:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* ---- Controle de horas ---- */
.barra-horas { height: 10px; background: var(--bar-bg); border-radius: 6px; overflow: hidden; min-width: 60px; }
.barra-horas span { display: block; height: 100%; background: linear-gradient(90deg, rgba(var(--brand-rgb), .55), var(--brand)); border-radius: 6px; }
.table-active > td { background-color: var(--brand-soft) !important; box-shadow: none !important; }

/* ---- Botao Sair: sempre vermelho com texto branco ---- */
.btn-sair, .btn-sair:hover, .btn-sair:focus, .btn-sair:active, .btn-sair:focus-visible { color: #fff; }
.btn-sair { --bs-btn-bg: #dc3545; --bs-btn-border-color: #dc3545; --bs-btn-hover-bg: #bb2d3b; --bs-btn-hover-border-color: #b02a37; --bs-btn-active-bg: #b02a37; --bs-btn-active-border-color: #a52834; --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; font-weight: 500; }

/* ---- Rodape do menu: Sair compacto ao lado do usuario ---- */
.sidebar .btn-sair { padding: .22rem .6rem; font-size: .78rem; line-height: 1.3; border-radius: .4rem; display: inline-flex; align-items: center; gap: .3rem; }
.sidebar .nav-link.nav-link-sm { font-size: .85rem; padding: .35rem .5rem; color: var(--muted); }
.sidebar .nav-link.nav-link-sm:hover { color: var(--link); }
.sidebar .nav-link.nav-link-sm.active { color: var(--on-brand); }
.rodape-links { display: flex; align-items: center; justify-content: space-between; gap: .25rem; }

/* Se o logo para fundo escuro nao estiver no servidor, mostra o logo claro sobre uma base clara */
html.sem-logo-escuro[data-bs-theme="dark"] .logo-claro { display: inline-block; background: #fff; border-radius: .5rem; padding: .25rem .5rem; }
