/* ============================================================
   custom.css — Sistema de Chamados de TI
   Layout baseado no Controle de Veículos (mesmo padrão visual)
   Paleta azul #0079B8
   ============================================================ */

:root {
  --brand:    #0079B8;
  --brand-dk: #00618f;
  --success:  #16A34A;
  --success-bg: #D1FAE5;
  --success-tx: #065F46;
  --danger:   #DC2626;
  --danger-bg: #FEE2E2;
  --danger-tx: #991B1B;
  --warn:     #D97706;
  --warn-bg:  #FEF3C7;
  --warn-tx:  #92400E;
  --info-bg:  #DBEAFE;
  --info-tx:  #1E40AF;
  --neutral:  #6B7280;
  --bg-sect:  #F8FAFC;
  --border:   #E2E8F0;
  --radius:   8px;

  /* Prioridades */
  --urgente-bg: #FEE2E2;
  --urgente-tx: #991B1B;
  --alta-bg:    #FEF3C7;
  --alta-tx:    #92400E;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Source Sans Pro', Arial, sans-serif;
  background: #F1F4F8;
  color: #1F2937;
  margin: 0;
  padding: 0;
  font-size: 17px;
}

/* ---------- Barra superior ---------- */
.app-header {
  background: var(--brand);
  color: #fff;
  padding: 16px 0;
  margin-bottom: 24px;
}

.app-header .container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.app-header-logo { display: flex; justify-content: center; }
.app-header-logo img { height: 48px; width: auto; display: block; }
.app-header .app-header-left  { justify-self: start; }
.app-header .d-flex.align-items-center.gap-2 { justify-self: end; }

.app-header-left { display: flex; align-items: center; gap: 12px; }

.app-header-icon {
  width: 46px; height: 46px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.app-header-icon svg { width: 26px; height: 26px; color: #fff; }

.app-header-text .navbar-brand {
  font-size: 20px; font-weight: 600; color: #fff !important; margin: 0; padding: 0;
}
.app-header-text small { display: block; font-size: 15px; opacity: .75; }

.app-user-badge {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: var(--radius);
  padding: 6px 14px; text-align: right;
  font-size: 15px; color: rgba(255,255,255,.9); flex-shrink: 0;
}
.app-user-badge strong { display: block; color: #fff; font-size: 16px; }

/* ---------- Container principal ---------- */
main.container { max-width: 1200px; margin: 0 auto 32px; }

.page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-toolbar h1 { font-size: 23px; font-weight: 600; color: var(--brand); margin: 0 0 2px; }
.page-toolbar .subtitle { font-size: 15px; color: var(--neutral); }

/* ---------- Cards de estatística ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,.09);
  padding: 20px 24px;
  border-left: 4px solid transparent;
}

.stat-card.stat-novo       { border-left-color: #7C3AED; }
.stat-card.stat-aberto     { border-left-color: var(--brand); }
.stat-card.stat-andamento  { border-left-color: var(--brand); }
.stat-card.stat-pendente   { border-left-color: var(--warn); }
.stat-card.stat-urgente    { border-left-color: var(--danger); }
.stat-card.stat-resolvido  { border-left-color: var(--success); }

.stat-clicavel {
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.stat-clicavel:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.13);
}
.stat-clicavel.stat-ativo {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.stat-number { font-size: 32px; font-weight: 700; color: #1F2937; line-height: 1; }
.stat-label  { font-size: 13px; font-weight: 600; color: var(--neutral); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Barra de pesquisa ---------- */
.search-wrap { margin-bottom: 20px; }
.search-with-icon {
  display: flex; align-items: stretch;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; overflow: hidden;
  transition: border-color .18s, box-shadow .18s;
}
.search-with-icon:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,121,184,.1); }
.search-wrap.search-with-icon { max-width: 480px; }
.search-with-icon .form-control { flex: 1; min-width: 0; border: none; border-radius: 0; }
.search-with-icon .form-control:focus { border: none; box-shadow: none; }
.search-icon-box {
  display: flex; align-items: center; justify-content: center; width: 42px; flex-shrink: 0;
  background: var(--bg-sect); border-left: 1px solid var(--border); pointer-events: none;
}
.search-icon { width: 17px; height: 17px; color: var(--neutral); }

/* ---------- Form card (seção) ---------- */
.form-card {
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,.09); overflow: hidden; margin-bottom: 22px;
}

.card-section-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-section-header .section-title-main {
  font-size: 17px; font-weight: 600; color: var(--brand); margin: 0;
}
.card-section-body { padding: 18px 24px 22px; }

/* ---------- Grid ---------- */
.row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.row:last-child { margin-bottom: 0; }

.c12 { flex: 0 0 100%; }
.c8  { flex: 0 0 calc(66.66% - 5px); }
.c6  { flex: 0 0 calc(50% - 7px); }
.c4  { flex: 0 0 calc(33.33% - 10px); }

@media (max-width: 600px) {
  .c6, .c4, .c8 { flex: 0 0 100%; }
  .app-header .container { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
  .app-header-logo, .app-header .d-flex.align-items-center.gap-2 { justify-self: auto; align-self: flex-start; }
}

/* ---------- Campos ---------- */
.form-group { width: 100%; }

label {
  display: block; font-size: 15px; font-weight: 600; color: #374151; margin-bottom: 4px;
}
label .r { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  width: 100%; padding: 7px 11px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 16px; color: #1F2937; background: #fff;
  transition: border-color .18s, box-shadow .18s;
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 32px; appearance: none; -webkit-appearance: none;
}
textarea.form-control { resize: vertical; min-height: 66px; }
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,121,184,.1);
}
.form-control[readonly] { background: var(--bg-sect); color: var(--neutral); cursor: not-allowed; }

/* ---------- Info-box (leitura) ---------- */
.info-box {
  background: var(--bg-sect); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px 2px; margin-bottom: 18px;
}
.info-box-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--neutral); margin: 0 0 12px;
}
.info-box .form-control[readonly] { background: #fff; }

/* ---------- Divisor de seção ---------- */
.section-divider {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--neutral);
  margin: 4px 0 16px;
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ---------- Botões ---------- */
.btn {
  font-family: inherit; border-radius: var(--radius);
  font-weight: 600; font-size: 16px; border: none;
  transition: opacity .18s, background .18s;
  cursor: pointer; padding: 8px 16px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dk); color: #fff; }
.btn-outline-primary { background: transparent; color: var(--brand); border: 1px solid var(--border); }
.btn-outline-primary:hover { background: var(--bg-sect); border-color: var(--brand); color: var(--brand); }
.btn-secondary { background: transparent; color: var(--neutral); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-sect); color: #374151; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .88; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- Badges de status e prioridade ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 12px; font-size: 14px; font-weight: 600;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.badge-disponivel { background: var(--success-bg); color: var(--success-tx); }
.badge-em-uso     { background: var(--info-bg);    color: var(--info-tx); }
.badge-novo       { background: #EDE9FE;           color: #5B21B6; }
.badge-aberto     { background: var(--info-bg);    color: var(--info-tx); }
.badge-andamento  { background: var(--info-bg);    color: var(--info-tx); }
.badge-pendente   { background: var(--warn-bg);    color: var(--warn-tx); }
.badge-resolvido  { background: var(--success-bg); color: var(--success-tx); }
.badge-fechado    { background: #F3F4F6;            color: var(--neutral); }
.badge-urgente    { background: var(--urgente-bg); color: var(--urgente-tx); }
.badge-alta       { background: var(--alta-bg);    color: var(--alta-tx); }
.badge-reaberto   { background: #FEE2E2;           color: #991B1B; }

/* ---------- Histórico de status ---------- */
.historico-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.historico-item:last-child { border-bottom: none; }

.historico-linha {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.historico-icone { color: var(--neutral); font-size: 15px; }
.historico-de    { color: var(--neutral); }
.historico-seta  { color: var(--neutral); }
.historico-autor { color: var(--neutral); margin-left: 4px; }
.historico-data  { color: var(--neutral); margin-left: auto; font-size: 13px; }

.badge-status-inline {
  display: inline-block; padding: 1px 9px;
  border-radius: 10px; font-size: 13px; font-weight: 600;
}
.badge-status-novo      { background: #EDE9FE;           color: #5B21B6; }
.badge-status-andamento { background: var(--info-bg);    color: var(--info-tx); }
.badge-status-pendente  { background: var(--warn-bg);    color: var(--warn-tx); }
.badge-status-resolvido { background: var(--success-bg); color: var(--success-tx); }
.badge-status-fechado   { background: #F3F4F6;           color: var(--neutral); }
.badge-status-reaberto  { background: #FEE2E2;           color: #991B1B; }

.actor-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 14px; font-weight: 600; }

/* ---------- Tabelas ---------- */
.table { margin-bottom: 0; font-size: 16px; border-collapse: separate; border-spacing: 0; }
.table td, .table th { vertical-align: middle; }
.table thead th {
  font-size: 13.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--neutral); background: var(--bg-sect);
  border-bottom: 2px solid var(--border); padding: 12px 14px;
}
.table tbody tr   { border-bottom: 2px solid #D6DDE5; }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:nth-child(even) { background: #EEF2F6; }
.table tbody td   { padding: 13px 14px; border-bottom: 2px solid #D6DDE5; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #E2E9F0; }
.table-empty { text-align: center; color: var(--neutral); font-size: 15px; padding: 22px !important; }

.titulo-cell { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Modais ---------- */
.modal-content {
  border: none; border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-header { background: var(--brand); padding: 16px 24px; border-bottom: none; }
.modal-header .modal-title { color: #fff; font-size: 18px; font-weight: 600; }
.modal-header .btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: .75; }
.modal-header .btn-close:hover { opacity: 1; }
.modal-body { padding: 22px 24px 8px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); background: var(--bg-sect); gap: 10px; }

@media (min-width: 992px) {
  .modal-report { max-width: 90vw; width: 900px; }
}

/* ---------- Comentários ---------- */
.comentarios-section { margin-top: 6px; }
.comentarios-lista {
  max-height: 280px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; background: var(--bg-sect); margin-bottom: 14px;
}
.comentario {
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; font-size: 15px;
}
.comentario:last-child { margin-bottom: 0; }
.comentario-ti   { background: var(--info-bg); border-left: 3px solid var(--brand); }
.comentario-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px; font-size: 13px;
}
.comentario-header strong { color: var(--brand); }
.comentario-header span   { color: var(--neutral); }
.comentario p { margin: 0; color: #374151; line-height: 1.5; }

/* ---------- Prioridade hint (formulário público) ---------- */
.prioridade-hint {
  font-size: 13px; color: var(--neutral); line-height: 1.7;
  padding: 8px 0;
}
.hint-urgente { color: var(--danger); font-weight: 700; }
.hint-alta    { color: var(--warn); font-weight: 700; }
.hint-normal  { color: var(--brand); font-weight: 700; }

/* ---------- Caixa de sucesso ---------- */
.alert-success-box {
  display: flex; gap: 20px; align-items: flex-start;
  background: var(--success-bg); border: 1px solid #86EFAC;
  border-radius: var(--radius); padding: 24px 28px; margin-bottom: 22px;
}
.success-icon {
  width: 48px; height: 48px; flex-shrink: 0;
  background: var(--success); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.success-icon svg { width: 24px; height: 24px; color: #fff; }
.success-title { font-size: 20px; font-weight: 700; color: var(--success-tx); margin: 0 0 4px; }
.success-sub   { font-size: 15px; color: var(--success-tx); margin: 0 0 4px; }

/* ---------- Toast ---------- */
.toast-feedback {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; background: var(--success); color: #fff;
  border-radius: var(--radius); font-size: 16px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  transform: translateY(80px); opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
  z-index: 9999; pointer-events: none;
}
.toast-feedback.visivel { transform: translateY(0); opacity: 1; }
.toast-feedback svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast-feedback.erro-toast { background: var(--danger); }

/* ---------- Navegação ---------- */
.app-nav {
  background: #fff; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.app-nav .nav-link {
  padding: 12px 16px; font-size: 14px; font-weight: 600;
  color: var(--neutral); border-bottom: 2px solid transparent; text-decoration: none;
}
.app-nav .nav-link:hover  { color: var(--brand); }
.app-nav .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Rodapé ---------- */
.app-footer { text-align: center; padding: 20px 16px 28px; color: var(--neutral); font-size: 12px; }

/* ---------- Login ---------- */
.login-body { background: #F1F4F8; min-height: 100vh; }
.login-card {
  max-width: 420px; background: #fff; border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.1); overflow: hidden;
}
.login-card-body { padding: 36px 32px 28px; }
.login-logo-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.login-logo { max-width: 220px; height: auto; }
.login-title { text-align: center; font-size: 19px; font-weight: 600; color: var(--brand); margin: 0 0 22px; }
.login-footer-text { text-align: center; color: var(--neutral); font-size: 12px; margin: 40px 0 0; }

/* ---------- Utilitários ---------- */
.neutral-text { color: var(--neutral); font-size: 13px; }
.min-vh-100   { min-height: 100vh; }
.d-flex       { display: flex; }
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.justify-content-end    { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.w-100 { width: 100%; }
.p-3   { padding: 12px; }
.text-center { text-align: center; }

/* ============================================================
   INDICADORES — KPIs, gráficos e tabela por loja
   ============================================================ */

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,.09);
  padding: 22px 20px 18px;
  text-align: center;
  border-top: 4px solid var(--border);
}

.kpi-card.kpi-abertos   { border-top-color: var(--brand); }
.kpi-card.kpi-resolvidos { border-top-color: var(--success); }
.kpi-card.kpi-urgentes  { border-top-color: var(--danger); }
.kpi-card.kpi-tempo     { border-top-color: var(--warn); }

.kpi-number {
  font-size: 36px;
  font-weight: 700;
  color: #1F2937;
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--neutral);
  text-transform: uppercase;
  letter-spacing: .5px;
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Layout de gráficos ---------- */
.charts-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}

@media (max-width: 768px) {
  .charts-grid-2 { grid-template-columns: 1fr; }
}

.chart-body {
  position: relative;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-body canvas {
  max-height: 280px;
}

.chart-body-wide {
  position: relative;
  min-height: 220px;
}

.chart-body-wide canvas {
  max-height: 240px;
}

/* ---------- Tabela por loja — barra inline ---------- */
.pct-badge {
  font-size: 14px;
  font-weight: 700;
}

.mini-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 140px;
}

.mini-bar {
  height: 7px;
  border-radius: 4px;
  min-width: 2px;
  transition: width .4s ease;
}

.mini-bar-aberto  { background: var(--brand); opacity: .7; }
.mini-bar-resolve { background: var(--success); }