/* Estilos Oficiais do DACTE SEFAZ (Modelo 57) */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', Arial, sans-serif;
  color: #000;
  background-color: #e9ecef;
  font-size: 8pt;
  line-height: 1.25;
}

/* Barra de ferramentas no topo da tela */
.dacte-toolbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #102133;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.toolbar-logo {
  background: #fb8500;
  color: #fff;
  font-weight: 900;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: 1px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: #2e7d32;
  color: #fff;
}
.btn-primary:hover {
  background: #256628;
}

.btn-secondary {
  background: #495057;
  color: #fff;
}
.btn-secondary:hover {
  background: #343a40;
}

.btn-outline {
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}
.btn-outline:hover {
  background: rgba(255,255,255,0.1);
}

/* Folha A4 do DACTE */
.dacte-container {
  width: 210mm;
  min-height: 297mm;
  margin: 15px auto;
  background: #fff;
  padding: 8mm 8mm;
  box-shadow: 0 0 15px rgba(0,0,0,0.15);
  border: 1px solid #ced4da;
}

/* Canhoto de Entrega */
.canhoto-box {
  border: 1px solid #000;
  padding: 4px;
  font-size: 6.5pt;
}

.canhoto-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #000;
  padding-bottom: 3px;
  margin-bottom: 3px;
}

.canhoto-decl {
  font-size: 6.5pt;
  width: 75%;
  line-height: 1.15;
}

.canhoto-info {
  text-align: right;
  font-size: 8pt;
}

.canhoto-bottom {
  display: grid;
  grid-template-columns: 100px 1fr 140px 1fr;
  gap: 6px;
  align-items: flex-end;
}

.canhoto-field {
  display: flex;
  flex-direction: column;
}

.value-placeholder {
  color: #555;
  font-size: 7pt;
  overflow: hidden;
  white-space: nowrap;
}

.picote-line {
  text-align: center;
  font-size: 6pt;
  color: #666;
  margin: 3px 0;
  letter-spacing: 1px;
}

/* Cabeçalho */
.dacte-header {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1.4fr;
  border: 1px solid #000;
  margin-bottom: 3px;
}

.header-col {
  padding: 4px;
}

.emitente-box {
  border-right: 1px solid #000;
}

.emitente-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.emitente-logo-img {
  max-height: 38px;
  max-width: 70px;
  object-fit: contain;
}

.brand-badge {
  background: #102133;
  color: #fff;
  font-weight: 900;
  font-size: 14pt;
  padding: 2px 6px;
  border-radius: 3px;
}

.emit-razao {
  font-size: 8pt;
  font-weight: 900;
  text-transform: uppercase;
}

.emit-fantasia {
  font-size: 6.5pt;
  font-weight: 700;
  color: #333;
}

.emit-details {
  font-size: 6.5pt;
  line-height: 1.2;
}

.dacte-title-box {
  border-right: 1px solid #000;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.dacte-badge {
  font-size: 13pt;
  font-weight: 900;
  letter-spacing: 1.5px;
}

.dacte-sub {
  font-size: 6.5pt;
  margin-bottom: 4px;
}

.dacte-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  padding: 2px 0;
  font-size: 7pt;
}

.dacte-data-emi {
  font-size: 6.5pt;
  margin-top: 2px;
}

.chave-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
}

.barcode-container {
  width: 100%;
  overflow: hidden;
  text-align: center;
}

.barcode-font {
  font-family: 'Libre Barcode 128', cursive;
  font-size: 38pt;
  line-height: 0.9;
  letter-spacing: -1px;
}

.chave-label {
  font-size: 5.5pt;
  font-weight: 700;
  margin-top: 1px;
}

.chave-number {
  font-family: 'Roboto Mono', monospace;
  font-size: 7.5pt;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 1px 0;
}

.consulta-info {
  font-size: 5.5pt;
  color: #444;
}

.protocolo-box {
  border-top: 1px solid #000;
  width: 100%;
  padding-top: 2px;
  margin-top: 2px;
  font-size: 6.5pt;
}

.tarja-cancelado {
  background: #c92a2a;
  color: #fff;
  text-align: center;
  font-weight: 900;
  font-size: 9pt;
  padding: 3px;
  margin-bottom: 3px;
  letter-spacing: 2px;
}

/* Caixas e Grades */
.sec-box {
  border: 1px solid #000;
  padding: 3px 4px;
  font-size: 6.8pt;
}

.sec-header-title {
  font-size: 6.5pt;
  font-weight: 900;
  background: #e9ecef;
  padding: 1px 3px;
  margin: -3px -4px 3px -4px;
  border-bottom: 1px solid #000;
  text-transform: uppercase;
}

.label {
  font-size: 5.5pt;
  color: #444;
  text-transform: uppercase;
  display: block;
}

.sec-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 3px;
  margin-bottom: 3px;
}

.sec-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}

.sec-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.sec-val-row {
  margin-bottom: 1.5px;
}

.carga-metricas {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid #ccc;
  margin-top: 3px;
  padding-top: 2px;
  text-align: center;
}

/* Tabela de Componentes */
.comp-table {
  display: flex;
  flex-direction: column;
}

.comp-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dotted #ccc;
  padding: 1px 0;
}

.total-row {
  border-top: 1px solid #000;
  border-bottom: none;
  padding-top: 2px;
  font-size: 8pt;
  font-weight: 900;
}

.total-highlight {
  font-size: 9pt;
  color: #000;
}

.icms-legal {
  font-size: 6pt;
  font-style: italic;
  margin-top: 2px;
  color: #333;
}

/* Tabela NF-e */
.nfe-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 6.5pt;
}

.nfe-table th, .nfe-table td {
  border: 1px solid #ccc;
  padding: 2px 4px;
  text-align: left;
}

.nfe-table th {
  background: #f1f3f5;
  font-weight: 700;
}

.font-mono {
  font-family: 'Roboto Mono', monospace;
  font-size: 6pt;
}

/* Observações e QR */
.sec-grid-obs {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 3px;
}

.obs-content {
  font-size: 6.5pt;
  line-height: 1.25;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.qr-img {
  width: 85px;
  height: 85px;
  display: block;
}

.loading-state, .error-msg {
  text-align: center;
  padding: 40px;
  font-size: 14px;
  color: #666;
}

.error-msg { color: #c92a2a; }

/* CONFIGURAÇÕES DE IMPRESSÃO */
@media print {
  body {
    background: #fff;
    margin: 0;
  }

  .no-print {
    display: none !important;
  }

  .dacte-container {
    width: 100% !important;
    min-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }

  @page {
    size: A4 portrait;
    margin: 6mm;
  }
}
