/*
 * Componentes do design system GODEL PQA.
 * Portado de design_system/design_system.html. Os seletores abaixo sao os
 * mesmos do arquivo de referencia (mesmos nomes de classe), reformatados
 * para legibilidade -- os valores nao foram alterados.
 *
 * Omitido deliberadamente: `.page`/`.page.active`/`@keyframes fade`. No
 * design_system.html essas classes implementam troca de "pagina" via JS
 * (SPA de arquivo unico). Aqui cada pagina e uma view/template Django
 * real, renderizada no servidor -- a navegacao e feita por requisicoes
 * HTTP normais, entao esse mecanismo nao se aplica. Ver docs/design-system.md.
 */

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--side);
  background: var(--navy);
  color: #c8d8e4;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: .22s;
}

.brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 17px;
  border-bottom: 1px solid #ffffff13;
  color: white;
  text-decoration: none;
}
.brand i { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--blue); font-size: 19px; font-style: normal; }
.brand b { display: block; font-size: 16px; }
.brand small { color: #8da7ba; letter-spacing: .08em; text-transform: uppercase; font-size: 10px; }

.side-scroll { padding: 12px; overflow: auto; }
.side-label { padding: 12px 10px 6px; color: #718da2; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.navq {
  width: 100%;
  border: 0;
  background: transparent;
  color: #b9cbd8;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  margin: 2px 0;
  border-radius: 8px;
  text-align: left;
  text-decoration: none;
}
.navq i { width: 20px; text-align: center; }
.navq:hover { background: #ffffff0e; color: white; }
.navq.active { background: #0b69ad36; color: white; box-shadow: inset 3px 0 #49a7e8; }
.navq.disabled { color: #6d8497; cursor: default; pointer-events: none; }
.navq .count { margin-left: auto; border-radius: 99px; background: #ffffff12; padding: 1px 7px; font-size: 10px; }
.navq .soon { margin-left: auto; border-radius: 99px; background: #ffffff0c; padding: 1px 7px; font-size: 9px; letter-spacing: .04em; text-transform: uppercase; }

.side-health { margin: auto 13px 13px; padding: 11px; border: 1px solid #ffffff13; border-radius: 9px; background: #ffffff08; }
.dot { display: inline-block; width: 8px; height: 8px; background: #2fc38a; border-radius: 50%; box-shadow: 0 0 0 4px #2fc38a22; }

/* Topbar */
.top {
  position: fixed;
  left: var(--side);
  right: 0;
  top: 0;
  height: 64px;
  background: #fffffff7;
  border-bottom: 1px solid var(--line);
  z-index: 1030;
  display: flex;
  align-items: center;
  padding: 0 18px;
  backdrop-filter: blur(8px);
}
.topsearch { max-width: 520px; flex: 1; }
.topsearch .form-control, .topsearch .input-group-text { background: #f7f9fb; border-color: var(--line); }
.iconbtn {
  width: 38px; height: 38px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: #52697b; display: grid; place-items: center; position: relative;
}
.iconbtn:hover { background: #edf2f6; border-color: var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: white; background: var(--navy2); font-weight: 800; }
.notify {
  position: absolute; right: 0; top: 1px; background: var(--bad); color: white;
  border: 2px solid white; border-radius: 99px; font-size: 9px; min-width: 17px; height: 17px;
  display: grid; place-items: center;
}

/* Layout principal */
.main { margin-left: var(--side); padding-top: 64px; min-height: 100vh; }
.wrap { padding: 20px 22px 30px; }
.breadcrumb { --bs-breadcrumb-divider: '›'; font-size: 12px; margin-bottom: 7px; }
.breadcrumb a { color: var(--blue); text-decoration: none; }
.pagehead { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; margin-bottom: 15px; }
.pagehead h1 { font-size: 23px; font-weight: 800; margin: 0; color: var(--navy2); }
.pagehead p { margin: 4px 0 0; color: var(--muted); }

/* Cards */
.cardq { background: white; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 4px 15px #0c253a0a; }
.cardh { padding: 13px 15px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cardh h2 { font-size: 14px; font-weight: 800; margin: 0; color: var(--navy2); }
.cardh small { color: var(--muted); }
.cardb { padding: 15px; }

/* Card colapsavel (ex.: cards de arquivos no detalhe da instalacao, Sprint 9) --
   botao com data-bs-toggle="collapse" (Bootstrap) alterna a classe .collapsed
   nele mesmo; o icone gira para indicar o estado sem precisar de JS proprio. */
.collapse-toggle .bi-chevron-up { transition: transform .15s ease; }
.collapse-toggle.collapsed .bi-chevron-up { transform: rotate(180deg); }

/* Painel atualizado via fetch, sem reload (ex.: tabelas de arquivos no
   detalhe da instalacao, Sprint 11 -- app.js::initAjaxFilesTables). Dimming
   sutil so durante a busca, sem bloquear a leitura do conteudo anterior. */
[data-ajax-panel].is-loading { opacity: .55; pointer-events: none; transition: opacity .1s ease; }

/* Metricas */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { background: white; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-height: 116px; position: relative; overflow: hidden; }
.metric:after { content: ""; position: absolute; width: 80px; height: 80px; border-radius: 50%; right: -18px; bottom: -36px; background: var(--t, #e8f3fb); }
.mi { width: 37px; height: 37px; border-radius: 9px; background: var(--t, #e8f3fb); color: var(--c, var(--blue)); display: grid; place-items: center; font-size: 17px; }
.ml { margin-top: 10px; color: var(--muted); font-size: 11px; font-weight: 700; }
.mv { font-size: 24px; line-height: 1.1; font-weight: 850; color: var(--navy2); }
.mn { font-size: 10px; color: var(--muted); margin-top: 5px; }

/* Botoes e formularios */
.btn { --bs-btn-border-radius: 7px; --bs-btn-font-size: 12px; --bs-btn-font-weight: 700; }
.btn-primary { --bs-btn-bg: var(--blue); --bs-btn-border-color: var(--blue); --bs-btn-hover-bg: #07568f; --bs-btn-hover-border-color: #07568f; }
.form-label { font-size: 11px; font-weight: 800; color: #385166; margin-bottom: 4px; }
.form-control, .form-select { min-height: 39px; border-color: #cbd6df; border-radius: 7px; font-size: 13px; }
.required:after { content: " *"; color: var(--bad); }
.form-text { font-size: 10px; color: var(--muted); }

/* Filtros */
.filter { background: white; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 12px; }
.filtergrid { display: grid; grid-template-columns: minmax(230px, 2fr) repeat(3, minmax(130px, 1fr)) auto; gap: 9px; align-items: end; }

/* Tabelas */
.table { margin: 0; vertical-align: middle; }
.table > :not(caption) > * > * { padding: 10px 11px; border-bottom-color: #e7edf1; }
.table thead th { background: #f7f9fb; color: #4b6173; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.table tbody td { font-size: 12px; color: #294153; }
.table tbody tr:hover { background: #fafcfd; }
.maincell { font-weight: 750; color: var(--navy2); }
.subcell { font-size: 10px; color: var(--muted); margin-top: 1px; }
.actions { display: flex; justify-content: flex-end; gap: 4px; }
.ibtn { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; }

/* Badges de status */
.badgeq {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; border: 1px solid transparent;
  padding: 4px 7px; font-size: 10px; font-weight: 800; white-space: nowrap;
}
.badgeq:before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badgeq.ok { color: #116847; background: #e7f5ee; border-color: #c1e5d5; }
.badgeq.info { color: #17648c; background: #e8f4fa; border-color: #c4e2f1; }
.badgeq.warn { color: #8d5005; background: #fff2dc; border-color: #eed2a4; }
.badgeq.bad { color: #9e2d35; background: #fdebed; border-color: #f0c5ca; }
.badgeq.neutral { color: #566b7b; background: #eef2f5; border-color: #d9e1e7; }

/* Acoes rapidas */
.quick { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px; border: 1px solid var(--line); background: white; border-radius: 8px; }
.quick:hover { border-color: #8fbddd; }
.qicon { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 8px; background: var(--blue2); color: var(--blue); }
.quick small { display: block; color: var(--muted); font-size: 10px; }

/* Distribuicao / donut */
.donut {
  width: 125px; height: 125px; border-radius: 50%;
  background: conic-gradient(var(--ok) 0 72%, #cdd7df 72% 91%, var(--bad) 91%);
  display: grid; place-items: center; position: relative;
}
.donut:after { content: ""; position: absolute; width: 75px; height: 75px; border-radius: 50%; background: white; }
.donut div { z-index: 1; text-align: center; }
.donut b { font-size: 21px; display: block; }
.dist { display: grid; grid-template-columns: 145px 1fr; align-items: center; gap: 20px; }
.legendrow { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #edf1f4; }
.legendrow span:first-child { display: flex; align-items: center; gap: 7px; }
.leg { width: 9px; height: 9px; border-radius: 2px; }

/* Hero (cabecalho de detalhe) */
.hero { background: white; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 4px 15px #0c253a0a; overflow: hidden; }
.herotop { padding: 15px; display: flex; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.herocode { font-size: 11px; color: var(--blue); font-weight: 850; letter-spacing: .05em; }
.heroname { font-size: 19px; font-weight: 850; color: var(--navy2); margin: 2px 0; }
.metagrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 11px; padding: 14px 15px; }
.k { font-size: 10px; text-transform: uppercase; letter-spacing: .035em; color: var(--muted); font-weight: 800; }
.v { font-size: 12px; font-weight: 700; margin-top: 2px; color: #294153; }

/* Abas internas de uma pagina de detalhe */
.tabsq { display: flex; overflow: auto; gap: 3px; background: white; border: 1px solid var(--line); border-radius: var(--r); padding: 4px; margin: 12px 0; }
.tabq { border: 0; background: transparent; white-space: nowrap; padding: 8px 10px; border-radius: 7px; color: #5b6e7d; font-size: 11px; font-weight: 750; }
.tabq:hover { background: #f0f4f7; }
.tabq.active { background: var(--blue2); color: var(--blue); }
.detail { display: none; }
.detail.active { display: block; }
.infolist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 15px; }
.infoitem { padding-bottom: 8px; border-bottom: 1px solid #edf1f4; }

/* Upload */
.upload { border: 1.5px dashed #9cb3c5; border-radius: 10px; padding: 18px; text-align: center; background: #fbfdff; cursor: pointer; }
.upload:hover, .upload.drag { border-color: var(--blue); background: var(--blue2); }
.upload .upicon { width: 47px; height: 47px; border: 1px solid var(--line); background: white; color: var(--blue); border-radius: 11px; display: grid; place-items: center; margin: 0 auto 7px; font-size: 20px; }
.upload b { display: block; }
.upload small { color: var(--muted); }
.upProgress, .upMsg { display: none; max-width: 500px; margin: 10px auto 0; text-align: left; }

/* Estatisticas RMS / graficos */
.rmsstats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px; }
.rmsstat { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 11px; }
.rmsstat b { display: block; font-size: 16px; }
.chart { min-height: 355px; width: 100%; overflow: hidden; }
.note { font-size: 11px; background: #eef8fc; border-left: 3px solid #2b7da9; padding: 10px; border-radius: 0 7px 7px 0; color: #456679; }

/* Linha do tempo */
.timeline { position: relative; padding-left: 24px; }
.timeline:before { content: ""; position: absolute; left: 7px; top: 5px; bottom: 5px; width: 2px; background: var(--line); }
.tl { position: relative; display: grid; grid-template-columns: 155px 1fr; gap: 12px; padding: 0 0 15px; }
.tl:before { content: ""; position: absolute; left: -22px; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px white, 0 0 0 5px #cbd7e0; }
.tl time { font-size: 10px; color: var(--muted); }
.tl b { font-size: 12px; }
.tl p { font-size: 11px; color: #52697b; margin: 2px 0; }

/* Estados vazio / carregando */
.empty { text-align: center; padding: 38px 12px; color: var(--muted); }
.empty i { font-size: 28px; }
.sk {
  height: 13px; border-radius: 5px; margin: 9px 0;
  background: linear-gradient(90deg, #edf1f4 25%, #fafcfd 37%, #edf1f4 63%);
  background-size: 400% 100%; animation: sk 1.2s infinite;
}
@keyframes sk { to { background-position: -100% 0; } }
.eventbar { width: 8px; height: 32px; border-radius: 4px; display: block; }
.mini { height: 160px; display: flex; align-items: end; gap: 3px; border: 1px solid var(--line); border-radius: 8px; background: #f8fbfd; padding: 10px; }
.mini span { flex: 1; background: var(--blue); border-radius: 2px 2px 0 0; }

/* Rodape e overlay do menu mobile */
.footer { margin-top: 25px; padding: 14px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; display: flex; justify-content: space-between; }
.backdropq { display: none; position: fixed; inset: 0; background: #06131f88; z-index: 1035; }

/* Responsividade -- breakpoints identicos ao design_system.html */
@media (max-width: 1199px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metagrid { grid-template-columns: repeat(3, 1fr); }
  .rmsstats { grid-template-columns: repeat(3, 1fr); }
  .filtergrid { grid-template-columns: repeat(2, 1fr); }
  .filtergrid > :first-child { grid-column: span 2; }
}
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .backdropq.show { display: block; }
  .top { left: 0; }
  .main { margin-left: 0; }
  .topsearch { display: none; }
  .wrap { padding: 16px 12px; }
  .dist { grid-template-columns: 1fr; justify-items: center; }
  .dist > div:last-child { width: 100%; }
}
@media (max-width: 767px) {
  .pagehead, .herotop { flex-direction: column; }
  .metrics, .metagrid, .rmsstats, .infolist, .filtergrid { grid-template-columns: 1fr; }
  .filtergrid > :first-child { grid-column: auto; }
  .tl { grid-template-columns: 1fr; gap: 2px; }
  .footer { flex-direction: column; gap: 4px; }
}
