/* Tela venda: estilos próprios desta tela, para não disputar o styles.css com outras rodadas. */
/* Nova venda: medidas tiradas da referência de 1440 × 900 (escala 2), em px de CSS. */

#sale-form.saleform {
  --sf-line: #dfe2e6;
  --sf-input-line: #cfd4d9;
  --sf-head: #f7f7f7;
  --sf-disabled: #eaecef;
  --sf-addon: #fafafa;
  --sf-ink: #0f1b24;
  --sf-text: #4a5056;
  --sf-soft: #6e757c;
  --sf-th: #222529;
  --sf-req: #ec4335;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-family: 'Source Sans Pro', system-ui, sans-serif;
}

#sale-form .saleform-block {
  border: 1px solid var(--sf-line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

#sale-form .saleform-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 73px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--sf-line);
  background: var(--sf-head);
}
#sale-form .saleform-head h2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--sf-ink);
  font-size: 19.5px;
  font-weight: 400;
  line-height: 26px;
  letter-spacing: 0;
}
#sale-form .saleform-head h2 strong { font-weight: 600; }
#sale-form .saleform-head p { margin: 6px 0 0; color: var(--sf-soft); font-size: 11px; line-height: 14px; }
#sale-form .saleform-icon { width: 16px; height: 16px; flex: none; fill: currentColor; }
#sale-form .saleform-head h2 .saleform-icon { color: var(--sf-soft); margin-right: -3px; }
#sale-form .saleform-menu { display: inline-flex; color: var(--sf-soft); opacity: .8; background: transparent; border: 0; padding: 0; font: inherit; cursor: not-allowed; }
#sale-form .saleform-menu .saleform-icon { width: 18px; height: 18px; }

#sale-form .saleform-body { padding: 23px 20px 20px; }
#sale-form .saleform-block-table .saleform-body { padding: 0; }
#sale-form .saleform-body > .form-grid,
#sale-form .saleform-totals { column-gap: 30px; row-gap: 19px; }

#sale-form .field { gap: 0; }
#sale-form .field label {
  color: var(--sf-soft);
  font-size: 14px;
  font-weight: 400;
  line-height: 19px;
}
#sale-form .field label.required::after { content: ' *'; color: var(--sf-req); }
#sale-form input:not([type="checkbox"]):not([type="radio"]),
#sale-form select,
#sale-form textarea {
  width: 100%;
  min-height: 37px;
  padding: 6px 12px;
  border: 1px solid var(--sf-input-line);
  border-radius: 3px;
  background: #fff;
  color: var(--sf-text);
  font: inherit;
  font-size: 16px;
  line-height: 23px;
  box-shadow: none;
}
#sale-form input:not([type="checkbox"]):not([type="radio"]), #sale-form select { height: 37px; }
#sale-form textarea { min-height: 96px; resize: vertical; }
#sale-form input::placeholder, #sale-form textarea::placeholder { color: var(--sf-soft); opacity: 1; }
#sale-form input:not([type="checkbox"]):not([type="radio"]):disabled, #sale-form select:disabled, #sale-form textarea:disabled {
  background: var(--sf-disabled);
  color: var(--sf-text);
  cursor: not-allowed;
  opacity: 1;
}
#sale-form .saleform-pending label { color: #8a9096; }
#sale-form .field:has(> .saleform-link) { position: relative; }
#sale-form .saleform-link { position: absolute; top: 2px; right: 0; color: #1f6fb2; font-size: 12px; line-height: 16px; text-decoration: none; }
#sale-form .saleform-link:hover { text-decoration: underline; }

#sale-form .saleform-group { display: flex; align-items: stretch; }
#sale-form .saleform-group > input, #sale-form .saleform-group > select { flex: 1; min-width: 0; }
#sale-form .saleform-group.has-prefix > input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
#sale-form .saleform-addon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 41px;
  padding: 0 10px;
  border: 1px solid var(--sf-input-line);
  border-right: 0;
  border-radius: 3px 0 0 3px;
  background: var(--sf-addon);
  color: var(--sf-soft);
  font-size: 14px;
}
#sale-form .saleform-addon.is-after { border-right: 1px solid var(--sf-input-line); border-left: 0; border-radius: 0 3px 3px 0; }
#sale-form .saleform-group:has(.is-after) > input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
#sale-form .saleform-addon .saleform-icon { width: 18px; height: 18px; }

/* Tabela de produtos e serviços: cabeçalho de 45 px e linha de 63 px, como na referência. */
#sale-form .saleform-table-wrap { overflow-x: auto; }
#sale-form .saleform-table { width: 100%; min-width: 900px; border-collapse: collapse; table-layout: fixed; }
#sale-form .saleform-table[hidden] { display: none; }
#sale-form .saleform-table th {
  height: 45px;
  padding: 8px 12px;
  border: 1px solid var(--sf-line);
  border-top: 0;
  background: var(--sf-head);
  color: var(--sf-th);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}
#sale-form .saleform-table td { height: 63px; padding: 12px; border: 1px solid var(--sf-line); vertical-align: middle; }
#sale-form .saleform-table th:first-child, #sale-form .saleform-table td:first-child { border-left: 0; }
#sale-form .saleform-table th:last-child, #sale-form .saleform-table td:last-child { border-right: 0; }
#sale-form .saleform-table .col-item { width: 25.5%; }
#sale-form .saleform-table .col-details { width: 13%; }
#sale-form .saleform-table .col-qty { width: 10.4%; }
#sale-form .saleform-table .col-type { width: 11.8%; }
#sale-form .saleform-table .col-price { width: 10.4%; }
#sale-form .saleform-table .col-discount { width: 11.1%; }
#sale-form .saleform-table .col-subtotal { width: 10.4%; }
#sale-form .saleform-table .col-actions { width: 7.4%; text-align: center; }
/* Tabela de serviços (sem a coluna Tipo), nas larguras da captura. */
#sale-form .saleform-table-service .col-item { width: 25%; }
#sale-form .saleform-table-service .col-details { width: 14%; }
#sale-form .saleform-table-service .col-qty { width: 13.3%; }
#sale-form .saleform-table-service .col-price { width: 13.1%; }
#sale-form .saleform-table-service .col-discount { width: 14.9%; }
#sale-form .saleform-table-service .col-subtotal { width: 13.2%; }
#sale-form .saleform-table-service .col-actions { width: 6.5%; }
#sale-form .saleform-table .saleform-addon { min-width: 34px; padding: 0 6px; font-size: 13px; }
#sale-form .saleform-req { color: var(--sf-req); }
#sale-form .saleform-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--sf-line);
  border-radius: 3px;
  background: #fff;
  color: var(--sf-soft);
  cursor: pointer;
}
#sale-form .saleform-icon-button.danger { color: #d9534f; }
#sale-form .saleform-icon-button:hover { background: #f4f5f6; }
#sale-form .saleform-empty { margin: 0; padding: 18px 20px 4px; color: var(--sf-soft); font-size: 14px; }
#sale-form .saleform-lines-foot { padding: 16px 16px 20px; }

#sale-form .button.saleform-add,
#sale-form .saleform-body > .form-grid .button.secondary {
  gap: 8px;
  box-sizing: border-box;
  height: 32px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--sf-ink);
  border-radius: 3px;
  background: #fff;
  color: var(--sf-ink);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
}
#sale-form .button.saleform-add:disabled, #sale-form .saleform-body > .form-grid .button.secondary:disabled { border-color: var(--sf-input-line); color: #8a9096; cursor: not-allowed; }
#sale-form .button.saleform-add .saleform-icon { width: 14px; height: 14px; }

#sale-form .saleform-toggle { display: flex; }
#sale-form .saleform-toggle label { display: flex; margin: 0; cursor: pointer; }
#sale-form .saleform-toggle input { position: absolute; opacity: 0; pointer-events: none; }
#sale-form .saleform-toggle span {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--sf-input-line);
  border-left: 0;
  background: var(--sf-addon);
  color: var(--sf-soft);
  font-size: 14px;
}
#sale-form .saleform-toggle label:last-child span { border-radius: 0 3px 3px 0; }
#sale-form .saleform-toggle input:checked + span { background: var(--sf-ink); border-color: var(--sf-ink); color: #fff; }
#sale-form .saleform-toggle input:focus-visible + span { outline: 2px solid #1f6fb2; outline-offset: 1px; }
#sale-form .saleform-group:has(.saleform-toggle) > input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
#sale-form .saleform-total-note { display: block; min-height: 16px; color: var(--sf-soft); font-size: 12px; }

#sale-form .saleform-payment { display: flex; flex-direction: column; gap: 14px; }
#sale-form .saleform-radios { display: flex; flex-wrap: wrap; gap: 16px; }
#sale-form .saleform-check, #sale-form .saleform-radio { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--sf-text); cursor: not-allowed; }
#sale-form .saleform-radio { min-width: 260px; padding: 12px 14px; border: 1px solid var(--sf-input-line); border-radius: 3px; background: #fff; }
#sale-form .saleform-check b, #sale-form .saleform-radio b { display: block; font-size: 14px; font-weight: 600; }
#sale-form .saleform-check small, #sale-form .saleform-radio small { display: block; color: var(--sf-soft); font-size: 12px; }
#sale-form .saleform-check input, #sale-form .saleform-radio input { margin-top: 3px; }
#sale-form .saleform-body > .form-grid > .span-3:has(.saleform-check) { display: flex; align-items: flex-end; padding-bottom: 6px; }

#sale-form .saleform-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 4px 0 24px; }
#sale-form .saleform-cancel { color: var(--sf-soft); font-size: 14px; text-decoration: none; }
#sale-form .saleform-cancel:hover { color: var(--sf-ink); text-decoration: underline; }
#sale-form .saleform-actions .button { min-height: 37px; padding: 7px 18px; border-radius: 3px; font-size: 15px; }

@media (max-width: 760px) {
  #sale-form .saleform-head { min-height: 0; }
  #sale-form .saleform-head h2 { flex-wrap: wrap; font-size: 18px; }
  #sale-form .saleform-body { padding: 16px; }
  #sale-form .saleform-radio { min-width: 0; flex: 1 1 100%; }
}

/* Segunda passada: Valor total no alto, campos de busca, data com calendário e linha de produto. */
#sale-form { position: relative; }
#sale-form .saleform-top-total {
  /* Fica na faixa do título, à esquerda do caminho, como o Valor total do original; não empurra o primeiro bloco. */
  position: absolute;
  top: -58px;
  right: 340px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  color: var(--sf-soft);
  font-size: 16px;
}
#sale-form .saleform-top-total-money { color: var(--sf-ink); font-size: 20px; font-weight: 600; }
#sale-form .saleform-top-total-money small { margin-right: 4px; color: var(--sf-soft); font-size: 14px; font-weight: 400; }
#sale-form .saleform-top-total-value { font: inherit; }
#sale-form .saleform-date-button { cursor: pointer; border-radius: 0 3px 3px 0; }
#sale-form .saleform-date-button:hover { background: #f1f2f4; }
#sale-form .saleform-group > input[type='date'] { padding-right: 8px; }
#sale-form .saleform-group > input[type='date']::-webkit-calendar-picker-indicator { display: none; }
#sale-form .saleform-table input:disabled, #sale-form .saleform-table select:disabled { background: var(--sf-disabled); }
#sale-form .saleform-table .col-actions { white-space: nowrap; }
#sale-form .saleform-table .col-actions .saleform-icon-button + .saleform-icon-button { margin-left: 4px; }
#sale-form .saleform-table .col-actions .saleform-icon-button:disabled { cursor: not-allowed; }

/* Botão "Tipo de desconto" da linha (R$ ou %), nos formulários de venda e de orçamento. */
#sale-form .saleform-table .col-discount .saleform-group,
#quote-form .saleform-table .col-discount .saleform-group { position: relative; }
#sale-form .saleform-table button.saleform-discount-type,
#quote-form .saleform-table button.saleform-discount-type { cursor: pointer; font: inherit; font-size: 13px; }
#sale-form .saleform-table button.saleform-discount-type:disabled,
#quote-form .saleform-table button.saleform-discount-type:disabled { cursor: not-allowed; }
#sale-form .saleform-discount-menu,
#quote-form .saleform-discount-menu {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  min-width: 64px;
  margin: 2px 0 0;
  padding: 4px 0;
  list-style: none;
  border: 1px solid var(--sf-input-line);
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
}
#sale-form .saleform-discount-menu li,
#quote-form .saleform-discount-menu li { padding: 4px 12px; cursor: pointer; font-size: 13px; }
#sale-form .saleform-discount-menu li:hover,
#sale-form .saleform-discount-menu li:focus,
#quote-form .saleform-discount-menu li:hover,
#quote-form .saleform-discount-menu li:focus { background: #f2f4f5; outline: 0; }
#sale-form .saleform-discount-menu li[aria-selected='true'],
#quote-form .saleform-discount-menu li[aria-selected='true'] { font-weight: 700; }

/* Campos extras obrigatórios: o asterisco vem colado ao nome, como no original ("IMEI*"). */
#sale-form .field label.g3-extra-required::after { content: '*'; }

/* Terceira passada (leva 3): setas de cima e de baixo nas listas, como a lista pesquisável do original, e o Valor
   total do alto só aparece depois de rolar a página (no original ele não aparece com a tela no alto). */
#sale-form select:not([multiple]), #quote-form select:not([multiple]) {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 14'%3E%3Cpath d='M5 1 9 6H1zM5 13 1 8h8z' fill='%23222529'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 9px 13px;
}
#sale-form select:not([multiple]):disabled, #quote-form select:not([multiple]):disabled { background-size: 9px 13px; opacity: 1; }
#sale-form .saleform-top-total { opacity: 0; pointer-events: none; transition: opacity .15s; }
#sale-form .saleform-top-total.is-visible { opacity: 1; pointer-events: auto; }

/* Lista Tipo desabilitada da linha: mantém as setas para cima e para baixo do original. */
#sale-form .saleform-table select:disabled {
  appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 14'%3E%3Cpath d='M5 1 9 6H1zM5 13 1 8h8z' fill='%23222529'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 9px 13px;
}
