/* Componentes reutilizáveis: botões, campos, chaves, abas, pílulas, tabelas, modais, avisos. */

/* ───────── Botões ───────── */
.btn {
  --h: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h);
  padding: 0 14px;
  border-radius: var(--r-s);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.08s, opacity 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-busy='true'] {
  opacity: 0.5;
  pointer-events: none;
}

.btn .i {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--text);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: #fff;
}

.btn-secondary {
  background: var(--surface-3);
  border-color: var(--line-2);
  color: var(--text);
}

.btn-secondary:hover {
  background: #29303a;
  border-color: var(--line-3);
}

.btn-ghost {
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-info {
  background: var(--info-soft);
  border-color: var(--info-line);
  color: var(--info-ink);
}

.btn-info:hover {
  background: rgba(90, 162, 255, 0.2);
}

.btn-danger {
  color: var(--late);
  border-color: rgba(255, 79, 79, 0.35);
}

.btn-danger:hover {
  background: var(--late-soft);
}

.btn-s {
  --h: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 8px;
  gap: 6px;
}

.btn-s .i {
  width: 14px;
  height: 14px;
}

.btn-l {
  --h: 48px;
  padding: 0 20px;
  font-size: 15px;
  border-radius: 12px;
}

.btn-l .i {
  width: 19px;
  height: 19px;
}

.btn-icon {
  width: var(--h);
  padding: 0;
}

.btn-block {
  width: 100%;
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

/* ───────── Campos ───────── */
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  align-content: start;
}

.field > label,
.label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.hint {
  font-size: 12px;
  color: var(--text-3);
}

.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-s);
  background: var(--bg-raised);
  border: 1px solid var(--line-2);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--line-3);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--info);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--info-soft);
}

.input[aria-invalid='true'] {
  border-color: var(--late);
}

.textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a4adb8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.select option {
  background: var(--surface);
  color: var(--text);
}

.input-icon {
  position: relative;
}

.input-icon > .i {
  position: absolute;
  left: 12px;
  top: 50%;
  translate: 0 -50%;
  color: var(--text-3);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.input-icon > .input {
  padding-left: 38px;
}

.input-suffix {
  position: relative;
}

.input-suffix > span {
  position: absolute;
  right: 12px;
  top: 50%;
  translate: 0 -50%;
  color: var(--text-3);
  font-size: 12.5px;
  pointer-events: none;
}

.input-suffix > .input {
  padding-right: 44px;
}

/* ───────── Chave liga/desliga ───────── */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch .track {
  position: relative;
  width: 40px;
  height: 24px;
  flex: none;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line-3);
  transition: background 0.2s, border-color 0.2s;
}

.switch .track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.2s var(--ease), background 0.2s;
}

.switch input:checked + .track {
  background: var(--text);
  border-color: var(--text);
}

.switch input:checked + .track::after {
  transform: translateX(16px);
  background: var(--bg);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.switch input:disabled + .track {
  opacity: 0.4;
}

/* linha de configuração: texto à esquerda, controle à direita */
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.setting:last-child {
  border-bottom: 0;
}

.setting-text strong {
  display: block;
  font-weight: 600;
}

.setting-text span {
  display: block;
  color: var(--text-3);
  font-size: 12.5px;
  margin-top: 2px;
}

/* ───────── Segmentado, abas, chips ───────── */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 11px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.seg button {
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

.seg button:hover {
  color: var(--text);
}

.seg button[aria-pressed='true'] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected='true'] {
  color: var(--text);
}

.tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tab[aria-selected='true'] .count {
  background: var(--text);
  color: var(--bg);
}

.count.is-late {
  background: var(--late);
  color: #fff;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover {
  color: var(--text);
  border-color: var(--line-3);
}

.chip[aria-pressed='true'] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.chip .count {
  height: 18px;
  min-width: 18px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.08);
}

.chip[aria-pressed='true'] .count {
  background: rgba(0, 0, 0, 0.14);
  color: var(--bg);
}

.chip .i {
  width: 14px;
  height: 14px;
}

/* ───────── Pílulas de status e prazo ───────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-novo {
  color: var(--info-ink);
  background: var(--info-soft);
  border-color: var(--info-line);
}

.pill-novo::before {
  background: var(--info);
}

.pill-em_preparo {
  color: var(--text);
}

.pill-pronto {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: var(--ok-line);
}

.pill-despachado {
  color: var(--text-2);
}

.pill-finalizado {
  color: var(--text-3);
  background: transparent;
}

.pill-cancelado {
  color: var(--late);
  background: transparent;
  border-color: rgba(255, 79, 79, 0.35);
}

.sla-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sla-tag::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.sla-ok {
  color: var(--ok);
}

.sla-warn {
  color: var(--warn);
}

.sla-late {
  color: var(--late);
}

/* ───────── Painéis e tabelas ───────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}

.panel-title {
  font-size: 13.5px;
  font-weight: 700;
}

.panel-sub {
  color: var(--text-3);
  font-size: 12px;
  margin-top: 2px;
}

.panel-body {
  padding: 16px 18px 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
}

.table {
  width: 100%;
  font-size: 13.5px;
}

.table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  white-space: nowrap;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr {
  transition: background 0.12s;
}

.table tbody tr.is-clickable {
  cursor: pointer;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table .col-num {
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
}

.table .col-actions {
  text-align: right;
  white-space: nowrap;
}

.table .col-actions .btn + .btn {
  margin-left: 4px;
}

/* ───────── Estados vazios e carregamento ───────── */
.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-2);
}

.empty > .i {
  width: 38px;
  height: 38px;
  color: var(--text-3);
  stroke-width: 1.5;
}

.empty h3 {
  font-size: 16px;
  color: var(--text);
}

.empty p {
  max-width: 440px;
  color: var(--text-3);
}

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* ───────── Avisos (toasts) ───────── */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 95;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: 12px;
  background: #1b2128;
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  animation: toast-in 0.22s var(--ease);
}

.toast > .i {
  margin-top: 2px;
  color: var(--text-2);
  width: 18px;
  height: 18px;
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 650;
}

.toast-msg {
  color: var(--text-2);
  font-size: 13px;
}

.toast-action {
  align-self: center;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toast-action:hover {
  background: #2b323b;
}

.toast-success > .i {
  color: var(--ok);
}

.toast-error > .i {
  color: var(--late);
}

.toast-warn > .i {
  color: var(--warn);
}

.toast-info > .i {
  color: var(--info);
}

.toast.is-leaving {
  animation: toast-out 0.18s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ───────── Modal e painel lateral ─────────
   O próprio container fixo rola e o cabeçalho é sticky: sem camada de rolagem aninhada e sem
   backdrop-filter (combinação que deixa painel em branco em algumas placas de vídeo). */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--overlay);
  animation: fade-in 0.18s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 81;
  width: min(var(--w, 560px), 100vw);
  background: var(--bg-raised);
  border-left: 1px solid var(--line-2);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: drawer-in 0.24s var(--ease);
}

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 81;
  translate: -50% -50%;
  width: min(var(--w, 560px), calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  background: var(--bg-raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-2);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: modal-in 0.2s var(--ease);
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}

.sheet-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.sheet-sub {
  color: var(--text-3);
  font-size: 12.5px;
  margin-top: 3px;
}

.sheet-close {
  margin-left: auto;
  flex: none;
}

.sheet-body {
  padding: 18px 20px 22px;
}

.sheet-foot {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  background: var(--bg-raised);
  border-top: 1px solid var(--line);
}

.sheet-foot .spacer {
  flex: 1;
}

.drawer:focus,
.modal:focus {
  outline: none;
}

@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
}

@media (max-width: 640px) {
  .modal {
    top: auto;
    bottom: 0;
    translate: -50% 0;
    width: 100vw;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
  }
}

/* ───────── Menu suspenso ───────── */
.menu {
  position: fixed;
  z-index: 90;
  min-width: 230px;
  padding: 6px;
  background: #1a1f26;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  animation: modal-in 0.14s var(--ease);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  text-align: left;
  color: var(--text);
  font-size: 13.5px;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-3);
  outline: none;
}

.menu-item small {
  display: block;
  color: var(--text-3);
  font-size: 12px;
}

.menu-item .i {
  color: var(--text-2);
  width: 17px;
  height: 17px;
}

.menu-sep {
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}

.menu-label {
  padding: 8px 10px 4px;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 700;
}

/* ───────── Controle deslizante ───────── */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: var(--surface-3);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 0;
  box-shadow: 0 0 0 4px rgba(236, 239, 243, 0.1);
}

.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 0;
}

/* ───────── Utilitários de layout ───────── */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
  min-width: 0;
}

.stack {
  display: grid;
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-3);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
}

.notice > .i {
  margin-top: 1px;
  width: 18px;
  height: 18px;
  color: var(--text-2);
}

.notice strong {
  color: var(--text);
}

.notice-info > .i {
  color: var(--info);
}

.notice-warn > .i {
  color: var(--warn);
}

.notice-late {
  border-color: rgba(255, 79, 79, 0.35);
}

.notice-late > .i {
  color: var(--late);
}
