/* ==========================================================================
   Gerador de Orçamentos — estilos específicos
   Depende de ../../styles.css e ../lab.css
   ========================================================================== */

.app-hero .grad {
  background: linear-gradient(100deg, #93C5FD 0%, #3B82F6 55%, #1E90FF 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ------------------------------------------------------ Aviso de segurança */
.security-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin-top: 1.5rem;
  padding: 0.9rem 1.05rem;
  border: 1px solid rgba(134, 239, 172, 0.38);
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(134, 239, 172, 0.12), rgba(134, 239, 172, 0.04));
  color: #DCFCE7;
  font-size: 0.86rem;
  line-height: 1.55;
}

.security-banner svg {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  margin-top: 0.1rem;
  color: var(--success);
}

.security-banner p {
  margin: 0;
}

/* ------------------------------------------------------------ Grade do app */
.app-grid {
  display: grid;
  gap: 1.15rem;
  align-items: start;
}

.app-main {
  display: grid;
  gap: 1.15rem;
  min-width: 0;
}

.app-side {
  display: grid;
  gap: 1.15rem;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.panel-head .panel-title {
  margin: 0;
}

.panel-chip {
  padding: 0.2rem 0.6rem;
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: var(--radius-pill);
  background: rgba(59, 130, 246, 0.14);
  color: #BFDBFE;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.panel-chip--soft {
  border-color: var(--line);
  background: rgba(147, 197, 253, 0.07);
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 0 1rem;
}

.form-grid .field {
  margin-bottom: 1rem;
}

.field select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--heading);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  cursor: pointer;
}

.field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.req {
  color: #FCA5A5;
}

.opt {
  color: var(--muted);
  font-weight: 500;
}

/* ---------------------------------------------------------------- Itens */
.items-head {
  display: none;
}

.items {
  display: grid;
  gap: 0.6rem;
}

.item-row {
  display: grid;
  gap: 0.6rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(10, 25, 41, 0.45);
  transition: border-color var(--dur) var(--ease);
}

.item-row:focus-within {
  border-color: rgba(59, 130, 246, 0.55);
}

.item-field {
  position: relative;
  min-width: 0;
}

.item-field label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.item-field input {
  width: 100%;
  padding: 0.58rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(10, 25, 41, 0.6);
  color: var(--heading);
  font-family: inherit;
  font-size: 0.9rem;
}

.item-field input::placeholder {
  color: rgba(147, 197, 253, 0.45);
}

.item-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.item-total {
  align-self: end;
  padding: 0.58rem 0.7rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: #DBEAFE;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.item-remove {
  align-self: end;
  justify-self: end;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.08);
  color: #FCA5A5;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.item-remove:hover {
  background: rgba(248, 113, 113, 0.2);
  color: #FEE2E2;
}

.items-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin-top: 1rem;
}

.items-actions .hint {
  margin: 0;
}

.autosave {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.autosave svg {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--success);
  flex: none;
}

/* --------------------------------------------------------------- Resumo */
.summary-panel {
  background: linear-gradient(165deg, rgba(59, 130, 246, 0.16), rgba(15, 34, 55, 0.5) 45%),
    var(--surface);
}

.summary-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-total {
  margin: 0.15rem 0 0;
  font-size: clamp(1.9rem, 5vw, 2.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.summary-sub {
  margin: 0.2rem 0 1.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.summary-list {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.summary-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.summary-list dt,
.summary-list dd {
  margin: 0;
  font-size: 0.88rem;
}

.summary-list dt {
  color: var(--muted);
}

.summary-list dd {
  color: var(--body-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.summary-list-total {
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line-strong);
}

.summary-list-total dt,
.summary-list-total dd {
  font-size: 1rem;
  font-weight: 750;
  color: var(--heading);
}

.summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 1.1rem;
}

.summary-badges li {
  padding: 0.16rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.tips-panel .check-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tips-panel .check-list li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.87rem;
  line-height: 1.55;
}

.tips-panel .check-list li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.5em;
  width: 0.6rem;
  height: 0.32rem;
  border-left: 2px solid var(--success);
  border-bottom: 2px solid var(--success);
  transform: rotate(-45deg);
}

/* Mensagens de status */
#status {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

#status.is-error {
  color: #FCA5A5;
}

#status.is-success {
  color: var(--success);
}

#status.is-working {
  color: #BFDBFE;
}

/* ---------------------------------------------------- Pré-visualização A4 */
.preview-section {
  padding-top: 0;
}

.preview-shell {
  padding: clamp(0.75rem, 2.5vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse at top, rgba(59, 130, 246, 0.16), transparent 60%),
    rgba(10, 25, 41, 0.7);
  overflow: hidden;
}

.paper-stage {
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
}

/* Documento A4 — 794px de largura (96 dpi) */
.paper {
  width: 794px;
  min-height: 1123px;
  padding: 46px 48px 34px;
  background: #FFFFFF;
  color: #0F2237;
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.5;
  transform-origin: top left;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.9);
}

.paper-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 3px solid #0A2540;
}

.paper-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.paper-brand img {
  flex: none;
  border-radius: 50%;
  background: #FFFFFF;
}

.paper-brand strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0A2540;
  line-height: 1.1;
}

.paper-brand span {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5B7796;
}

.paper-doc {
  text-align: right;
}

.paper-doc-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #3B82F6;
}

.paper-doc strong {
  display: block;
  margin: 2px 0;
  font-size: 16px;
  font-weight: 800;
  color: #0A2540;
}

.paper-doc > span:last-child {
  font-size: 11px;
  color: #5B7796;
}

.paper-client {
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.8fr;
  gap: 18px;
  margin: 22px 0 20px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #F1F5FB;
  border: 1px solid #DBE6F5;
}

.paper-client span {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5B7796;
}

.paper-client strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: #0A2540;
  overflow-wrap: anywhere;
}

.paper-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.paper-table th {
  padding: 8px 8px;
  border-bottom: 2px solid #0A2540;
  background: #0A2540;
  color: #F8FAFC;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
}

.paper-table th.num,
.paper-table td.num {
  text-align: right;
  white-space: nowrap;
}

.paper-table th:first-child {
  border-radius: 5px 0 0 5px;
}

.paper-table th:last-child {
  border-radius: 0 5px 5px 0;
}

.paper-table td {
  padding: 9px 8px;
  border-bottom: 1px solid #E2EAF4;
  color: #1E3A5F;
  vertical-align: top;
}

.paper-table tbody tr:nth-child(even) td {
  background: #F8FAFD;
}

.paper-table td:first-child {
  color: #7A90A9;
  font-weight: 700;
}

.paper-empty td {
  padding: 26px 8px;
  text-align: center;
  color: #7A90A9;
  font-style: italic;
}

.paper-bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-top: 22px;
}

.paper-pay {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 300px;
  padding: 12px;
  border: 1px solid #DBE6F5;
  border-radius: 10px;
  background: #F8FAFD;
}

.paper-qr {
  width: 96px;
  height: 96px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 4px;
  border-radius: 8px;
  background: #FFFFFF;
  border: 1px solid #DBE6F5;
}

.paper-qr canvas {
  width: 88px !important;
  height: 88px !important;
  display: block;
}

.paper-qr img {
  display: none !important;
}

.paper-pay-text strong {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: #0A2540;
}

.paper-pay-text span {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  font-weight: 600;
  color: #1E3A5F;
  overflow-wrap: anywhere;
}

.paper-pay-text small {
  display: block;
  margin-top: 4px;
  font-size: 8px;
  line-height: 1.4;
  color: #7A90A9;
}

.paper-totals {
  width: 260px;
  margin: 0 0 0 auto;
}

.paper-totals > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0;
}

.paper-totals dt {
  margin: 0;
  font-size: 10px;
  color: #5B7796;
}

.paper-totals dd {
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  color: #1E3A5F;
  font-variant-numeric: tabular-nums;
}

.paper-total {
  margin-top: 6px;
  padding: 10px 12px !important;
  border-radius: 8px;
  background: #0A2540;
}

.paper-total dt {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #93C5FD;
}

.paper-total dd {
  font-size: 18px;
  font-weight: 800;
  color: #FFFFFF;
}

.paper-notes {
  margin-top: 20px;
  padding: 12px 14px;
  border-left: 3px solid #3B82F6;
  border-radius: 0 8px 8px 0;
  background: #F1F5FB;
}

.paper-notes strong {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0A2540;
}

.paper-notes p {
  margin: 3px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: #1E3A5F;
  white-space: pre-line;
}

.paper-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 16px;
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid #DBE6F5;
  font-size: 9px;
  color: #7A90A9;
}

/* --------------------------------------------------------- Responsivo */
@media (min-width: 40em) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 64em) {
  .app-grid {
    grid-template-columns: minmax(0, 1.42fr) minmax(0, 0.58fr);
    gap: 1.35rem;
  }

  .app-side {
    position: sticky;
    top: 5.75rem;
  }

  .items-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 78px 116px 106px 40px;
    gap: 0.5rem;
    padding: 0 0.85rem 0.35rem;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .items-head span:nth-child(2),
  .items-head span:nth-child(3),
  .items-head span:nth-child(4) {
    text-align: right;
  }

  .item-row {
    grid-template-columns: minmax(0, 1fr) 78px 116px 106px 40px;
    align-items: end;
    padding: 0.55rem 0.85rem;
  }

  .item-field label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .item-field input {
    padding: 0.5rem 0.6rem;
  }

  .item-row .item-field input[data-field="qtd"],
  .item-row .item-field input[data-field="unitario"] {
    text-align: right;
  }

  .item-total {
    padding: 0.5rem 0;
    border: 0;
    background: none;
    text-align: right;
  }

  .item-remove {
    width: 2.1rem;
    height: 2.1rem;
    align-self: center;
  }
}

/* Exportação: documento sem escala e sem recorte */
body.is-exporting .paper-stage {
  overflow: visible;
  height: auto !important;
}

body.is-exporting .paper {
  transform: none !important;
}

@media print {
  .site-header,
  .breadcrumb,
  .lab-hero,
  .app-grid,
  .preview-section .section-head,
  .privacy-note,
  .site-footer,
  #contato,
  .section-alt {
    display: none !important;
  }

  .paper {
    transform: none !important;
    box-shadow: none;
  }
}
