/* Folha de Rosto — SGA Sistemas */

/* ========================================================
   1. CONFIGURAÇÃO FÍSICA DA FOLHA A4
   ======================================================== */
@page {
  size: A4 portrait;
  margin: 0;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background-color: #475569;
  color: #0f172a;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ========================================================
   2. FOLHA A4 (210mm x 297mm)
   ======================================================== */
.a4-page {
  position: relative;
  width: 210mm;
  height: 297mm;
  min-width: 210mm;
  min-height: 297mm;
  max-width: 210mm;
  max-height: 297mm;
  margin: 0;
  padding: 0;
  background-color: #ffffff;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.35), 0 8px 10px -6px rgba(15, 23, 42, 0.20);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* ========================================================
   3. METADE SUPERIOR (EXATOS 148.5mm = 50%)
   ======================================================== */
[data-purpose="form-wrapper"] {
  width: 100% !important;
  height: 148.5mm !important;
  min-height: 148.5mm !important;
  max-height: 148.5mm !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  flex: 0 0 148.5mm !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
}

/* ========================================================
   4. METADE INFERIOR (EXATOS 148.5mm = 50%)
   ======================================================== */
[data-purpose="bottom-page-half-guidance"] {
  width: calc(100% - 12mm) !important;
  height: calc(148.5mm - 6mm) !important;
  min-height: calc(148.5mm - 6mm) !important;
  max-height: calc(148.5mm - 6mm) !important;
  margin: 3mm 6mm 3mm 6mm !important;
  padding: 3mm 4mm !important;
  overflow: hidden !important;
  flex: 0 0 calc(148.5mm - 6mm) !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}

/* ========================================================
   5. CAMPOS ERP
   ======================================================== */
.erp-field {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0;
  transition: all 0.15s ease-in-out;
}

.erp-field:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
  background-color: #f8fafc;
}

.erp-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #64748b;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}

.erp-input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  font-size: 9.5px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  height: 18px !important;
  min-height: 18px !important;
  width: 100%;
  line-height: 1 !important;
}

.erp-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

/* ========================================================
   6. RADIO BUTTONS EM FORMATO DE PÍLULA
   ======================================================== */
.pill-radio input[type="radio"] {
  display: none;
}

.pill-radio label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  color: #475569;
  background-color: #f8fafc;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.1;
}

.pill-radio input[type="radio"]:checked + label {
  background-color: #1e293b;
  color: #ffffff;
  border-color: #1e293b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ========================================================
   7. COMPACTAÇÃO DE ALTURA INTERNA
   ======================================================== */
[data-purpose="main-title"] {
  padding-top: 2px !important;
  padding-bottom: 2px !important;
}

[data-purpose="form-wrapper"] .erp-field {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

[data-purpose="form-wrapper"] .erp-input,
[data-purpose="form-wrapper"] input,
[data-purpose="form-wrapper"] select,
[data-purpose="form-wrapper"] textarea {
  min-height: 18px !important;
  height: 18px !important;
  line-height: 1 !important;
}

[data-purpose="form-wrapper"] input[type="radio"] {
  min-height: auto !important;
  height: auto !important;
}

[data-purpose="form-wrapper"] .gap-2 {
  gap: 3px !important;
}

[data-purpose="form-wrapper"] .gap-1\.5 {
  gap: 2px !important;
}

[data-purpose="form-wrapper"] .space-y-1\.5 > :not([hidden]) ~ :not([hidden]) {
  margin-top: 3px !important;
}

[data-purpose="observacoes-container"] {
  min-height: 18px !important;
  height: 18px !important;
}

#lista-segmentos {
  z-index: 1000;
  max-height: 192px;
  overflow-y: auto;
}

/* ========================================================
   8. MODAL DE MÓDULOS
   ======================================================== */
.modal-modulos {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  background-color: rgba(15, 23, 42, 0.65); /* Fundo preto/slate escuro com transparência */
  backdrop-filter: blur(4px); /* Efeito suave de desfoque no fundo */
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-modulos.aberto {
  display: flex !important; /* Centraliza a caixa na tela */
}

/* Janela/Cartão flutuante */
.modal-modulos-conteudo {
  width: 92vw;
  max-width: 1200px; /* Mais largo que a folha A4 para visualização confortável */
  height: 88vh;
  max-height: 850px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalEntrada 0.2s ease-out;
}

/* Animação suave de surgimento */
@keyframes modalEntrada {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-modulos-body {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  overflow: hidden;
  position: relative;
  background: #f8fafc;
}

#iframeModulos {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

/* ========================================================
   9. REGRAS DE IMPRESSÃO
   ======================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    width: 210mm !important;
    height: 297mm !important;
    min-width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  body {
    display: block !important;
  }

  .a4-page {
    width: 210mm !important;
    height: 297mm !important;
    box-shadow: none !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  [data-purpose="form-wrapper"] {
    width: 100% !important;
    height: 148.5mm !important;
    min-height: 148.5mm !important;
    max-height: 148.5mm !important;
    flex: 0 0 148.5mm !important;
    overflow: hidden !important;
  }

  [data-purpose="bottom-page-half-guidance"] {
    width: calc(100% - 12mm) !important;
    height: calc(148.5mm - 6mm) !important;
    min-height: calc(148.5mm - 6mm) !important;
    max-height: calc(148.5mm - 6mm) !important;
    margin: 3mm 6mm 3mm 6mm !important;
    padding: 3mm 4mm !important;
    flex: 0 0 calc(148.5mm - 6mm) !important;
    overflow: hidden !important;
    display: flex !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #modalModulos,
  .modal-modulos,
  #iframeModulos {
    display: none !important;
    visibility: hidden !important;
  }

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

  input,
  select,
  textarea,
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}