/* Componentes: controles, badges, cartões, tabelas, sheet. */

/* Campos */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--label-2); }
.input, textarea.input {
  height: var(--control-h); padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--separator-strong); background: var(--bg-elev); color: var(--label);
  outline: none; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.4; }
.input:focus, textarea.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--tint-blue); }
.input.mono { font-family: var(--mono); font-size: 12.5px; }
/* Menus de seleção: ver .popup (js/components/select.js) — o <select> nativo não é usado. */
.input.search { padding-left: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%238e8e93' stroke-width='2'%3E%3Ccircle cx='9' cy='9' r='6'/%3E%3Cpath d='m14 14 4 4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 15px; background-position: 9px 50%; border-radius: var(--radius-pill); background-color: var(--bg-inset); border-color: transparent; }
/* Chips de seleção múltipla (o checkbox nativo fica invisível; a caixa é desenhada) */
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 8px; border-radius: var(--radius-sm); border: 1px solid var(--separator); cursor: pointer; font-size: 13px; transition: border-color .12s, background .12s; }
.check:hover { background: var(--bg-hover); }
.check.on { border-color: var(--blue); background: var(--tint-blue); }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.check .check-box { width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--separator-strong); display: grid; place-items: center; flex: none; font-size: 11px; color: #fff; transition: background .12s, border-color .12s; }
.check.on .check-box { background: var(--blue); border-color: var(--blue); }
.check.on .check-box::after { content: "✓"; font-weight: 700; line-height: 1; }
.check input:focus-visible + .check-box { box-shadow: 0 0 0 3px var(--tint-blue); }

/* Pop-up button (substitui o <select> nativo; ver js/components/select.js) */
.popup { position: relative; display: inline-block; max-width: 100%; }
.popup-btn {
  height: var(--control-h); padding: 0 6px 0 11px; border-radius: var(--radius-sm); border: 1px solid var(--separator-strong);
  background: var(--bg-elev); color: var(--label); display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  font-size: 13.5px; font-weight: 500; transition: border-color .15s, box-shadow .15s, background .15s;
}
.popup-btn:hover { background: var(--bg-hover); }
.popup-btn.open, .popup-btn:focus-visible { border-color: var(--blue); box-shadow: 0 0 0 3px var(--tint-blue); outline: none; }
.popup-label { min-width: 0; }
.popup-chevron { flex: none; width: 18px; height: 18px; border-radius: 5px; background: var(--blue-deep); color: #fff; display: grid; place-items: center; }
.popup.sm .popup-btn { height: 28px; padding: 0 5px 0 10px; font-size: 13px; border-radius: 7px; }
.popup.sm .popup-chevron { width: 16px; height: 16px; border-radius: 4px; }
.popup-menu {
  position: absolute; top: calc(100% + 5px); left: 0; min-width: 100%; max-width: min(360px, 92vw); max-height: 340px; overflow: auto; z-index: 60;
  padding: 5px; background: var(--bg-elev); border: 1px solid var(--separator); border-radius: 11px; box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column; gap: 1px; animation: rise .14s ease-out;
}
.popup-menu.right { left: auto; right: 0; }
.popup-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 10px 7px 6px; border: 0; border-radius: 7px;
  background: transparent; color: var(--label); font-size: 13.5px; white-space: nowrap;
}
.popup-item:hover { background: var(--blue-deep); color: #fff; }
.popup-item:hover .popup-hint, .popup-item:hover .popup-check { color: rgba(255,255,255,.85); }
.popup-item.on { font-weight: 600; }
.popup-item.disabled { opacity: .45; cursor: default; }
.popup-check { width: 16px; flex: none; text-align: center; color: var(--label); font-size: 12px; }
.popup-hint { font-size: 11.5px; color: var(--label-2); font-weight: 400; }

/* Diálogos (confirmação / prompt) */
.dialog { width: 100%; max-width: 400px; padding: 22px 22px 18px; background: var(--bg-elev); border-radius: 16px; box-shadow: var(--shadow-sheet); display: flex; flex-direction: column; gap: 12px; animation: rise .18s ease-out; }
.dialog h2 { font-size: 16px; }
.dialog-msg { color: var(--label-2); font-size: 13.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.btn.danger-solid { background: var(--red); color: #fff; }
.btn.danger-solid:hover { background: var(--red); filter: brightness(1.06); }

/* Botões */
.btn {
  height: var(--control-h); padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--bg-inset); color: var(--label); font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; transition: background .15s, transform .05s, opacity .15s; text-decoration: none;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--blue-deep); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); background: var(--blue-deep); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--tint-red); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; justify-content: center; }
.btn.active { background: var(--tint-blue); color: var(--blue); }

/* Segmented control */
.seg { display: inline-flex; padding: 2px; background: var(--bg-inset); border-radius: 9px; gap: 2px; }
.seg button {
  height: 26px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--label-2);
  font-weight: 500; font-size: 13px; transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { color: var(--label); }
.seg button.on { background: var(--bg-elev); color: var(--label); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.sm button { height: 22px; padding: 0 9px; font-size: 12px; }

/* Toggle (switch) */
.toggle { position: relative; width: 40px; height: 24px; border-radius: 12px; background: var(--separator-strong); border: 0; padding: 0; transition: background .2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(16px); }
.toggle:disabled { opacity: .5; cursor: default; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.toggle-row + .toggle-row { border-top: 1px solid var(--separator); }
.toggle-row .t { font-weight: 500; }
.toggle-row .d { font-size: 12px; color: var(--label-2); }

/* Badges / pontos */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 600; letter-spacing: .01em; background: var(--tint-gray); color: var(--label-2); white-space: nowrap; }
.badge.blue { background: var(--tint-blue); color: var(--blue); }
.badge.green { background: var(--tint-green); color: var(--green); }
.badge.orange { background: var(--tint-orange); color: var(--orange); }
.badge.red { background: var(--tint-red); color: var(--red); }
.badge.purple { background: var(--tint-purple); color: var(--purple); }
.badge.teal { background: var(--tint-teal); color: var(--teal); }
.badge.indigo { background: var(--tint-indigo); color: var(--indigo); }
.badge.mono { font-family: var(--mono); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--label-3); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--tint-green); }
.dot.err { background: var(--red); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px transparent; } }

/* Cartões e estatísticas */
.card { background: var(--bg-elev); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.stat { padding: 14px 16px; }
.stat .v { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--label-2); margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.empty { padding: 40px 20px; text-align: center; color: var(--label-2); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* Tabelas */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--label-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--separator); }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--separator); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.mono { word-break: break-all; }

/* Barra de filtros no topo de um cartão */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--separator); position: sticky; top: 0; background: var(--bg-elev); z-index: 5; border-radius: var(--radius) var(--radius) 0 0; }

/* Sheet (modal): coluna flex de altura limitada — cabeçalho e rodapé fixos,
 * só o corpo rola (a barra fica dentro do painel, não na página). */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: grid; place-items: center; padding: 20px; overflow: hidden; animation: fade .15s ease-out; }
.sheet { display: flex; flex-direction: column; width: 100%; max-width: 680px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow: hidden; background: var(--bg-elev); border-radius: 16px; box-shadow: var(--shadow-sheet); animation: rise .18s ease-out; }
.sheet.narrow { max-width: 460px; }
.sheet .sheet-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--separator); }
.sheet .sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.sheet .sheet-foot { flex: none; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--separator); }
