/* ============================================================
   RELATÓRIO DE ALOJAMENTOS — MSE ENGENHARIA
   style.css — Estilos principais (Mobile First)
============================================================ */

/* ============================================================
   1. VARIÁVEIS CSS
============================================================ */
:root {
  /* Cores MSE */
  --mse-red:          #C8102E;
  --mse-red-dark:     #9E0B23;
  --mse-red-hover:    #E01232;
  --mse-red-light:    #FDECEA;

  /* Neutros */
  --color-white:      #FFFFFF;
  --color-bg:         #F2F4F7;
  --color-surface:    #FFFFFF;
  --color-border:     #DDE3EC;
  --color-border-focus: #C8102E;

  /* Texto */
  --color-text:       #1A2332;
  --color-text-sec:   #4A5568;
  --color-text-muted: #8896AB;

  /* Status */
  --color-ok:         #0B6B35;
  --color-ok-bg:      #D1FAE5;
  --color-ok-border:  #6EE7B7;
  --color-nok:        #991B1B;
  --color-nok-bg:     #FEE2E2;
  --color-nok-border: #FECACA;

  /* Sombras */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:  0 2px 6px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.10);
  --shadow-card: 0 2px 8px rgba(26,35,50,0.07), 0 0 1px rgba(26,35,50,0.06);

  /* Bordas arredondadas */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transições */
  --t-fast: 0.15s ease;
  --t-base: 0.25s ease;
  --t-slow: 0.35s ease;

  /* Tipografia */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

/* ============================================================
   2. RESET
============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================================
   3. UTILITÁRIOS
============================================================ */
.d-none { display: none !important; }

.pdf-field {
  font-size: 15px;
  color: var(--color-text);
  padding: 2px 0;
}

/* ============================================================
   4. LOADING OVERLAY
============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loading-box {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: 40px 48px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  width: 90%;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--mse-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ============================================================
   5. TOAST
============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--color-text);
  color: var(--color-white);
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: var(--color-ok); }
.toast-error   { background: var(--color-nok); }
.toast-warning { background: #92400E; }

/* ============================================================
   6. HEADER MSE
============================================================ */
.header-mse {
  background: linear-gradient(135deg, var(--mse-red) 0%, var(--mse-red-dark) 100%);
  color: var(--color-white);
  width: 100%;
  page-break-inside: avoid;
  break-inside: avoid;
  position: relative;
  overflow: hidden;
}

.header-mse::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  pointer-events: none;
}

.header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 20px 40px;
  max-width: 1280px;
  margin: 0 auto;
  position: relative;
}

.header-logo {
  flex-shrink: 0;
}

.logo_header {
  height: 64px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.header-text {
  text-align: center;
}

.header-text h1 {
  font-size: clamp(18px, 2.5vw, 28px);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  line-height: 1.2;
  margin-bottom: 4px;
}

.header-subtitle {
  font-size: 13px;
  opacity: 0.85;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.header-cnpj {
  font-size: 11px;
  opacity: 0.80;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* ============================================================
   7. MAIN CONTAINER
============================================================ */
.main-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.form-alojamento {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ============================================================
   8. SECTION CARDS (dados + items header)
============================================================ */
.form-section,
.items-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.section-header,
.items-section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 28px;
  background: linear-gradient(135deg, #1A2332 0%, #2D3A50 100%);
  color: var(--color-white);
}

.section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  color: var(--color-white);
}

.section-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.section-desc {
  font-size: 13px;
  opacity: 0.75;
  margin-top: 2px;
}

.section-body {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   9. CAMPOS DO FORMULÁRIO
============================================================ */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-sec);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.required {
  color: var(--mse-red);
  margin-left: 2px;
}

.field-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

.field-input::placeholder {
  color: var(--color-text-muted);
  font-size: 14px;
}

.field-input:hover {
  border-color: #b0bbcc;
}

.field-input:focus {
  border-color: var(--mse-red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

.field-input[type="date"] {
  cursor: pointer;
}

/* Grids de campos */
.field-row {
  display: grid;
  gap: 16px;
}

.field-row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.field-row-2 {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.field-grow { flex: 1; }

.field-date .field-input {
  min-width: 160px;
}

/* Validação */
.field-input.input-error {
  border-color: var(--color-nok);
  box-shadow: 0 0 0 3px rgba(153, 27, 27, 0.12);
}

.error-message {
  font-size: 12px;
  color: var(--color-nok);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   10. ITEMS SECTION
============================================================ */
.items-section {
  display: flex;
  flex-direction: column;
}

.items-section-header {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ============================================================
   11. QUESTION CARD
============================================================ */
.question {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
  border-top: 1px solid var(--color-border);
}

.question:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.question-card {
  background: var(--color-surface);
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

.question-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  background: #F8FAFB;
  border-bottom: 1px solid var(--color-border);
  cursor: default;
}

.question-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--mse-red);
  color: var(--color-white);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
}

.question-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.2px;
}

.question-body {
  padding: 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ============================================================
   12. TEXTO NORMATIVO
============================================================ */
.regulatory-text {
  background: #F8FAFB;
  border-left: 3px solid var(--mse-red);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
}

.regulatory-text p {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--color-text-sec);
  margin: 0;
}

.regulatory-text strong {
  color: var(--mse-red-dark);
  font-weight: 600;
}

/* ============================================================
   13. RADIOS DE CONFORMIDADE
============================================================ */
.conformity-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border: 2px solid var(--color-border);
  border-radius: 50px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-sec);
  transition: all var(--t-fast);
  user-select: none;
  -webkit-user-select: none;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-white);
  flex-shrink: 0;
  transition: all var(--t-fast);
  position: relative;
}

/* Estado marcado — Conforme */
.conforme-option:has(input:checked) {
  background: var(--color-ok-bg);
  border-color: var(--color-ok);
  color: var(--color-ok);
}

.conforme-option:has(input:checked) .radio-check {
  border-color: var(--color-ok);
  background: var(--color-ok);
}

.conforme-option:has(input:checked) .radio-check::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--color-white);
  border-radius: 50%;
}

/* Estado marcado — Não Conforme */
.nao-conforme-option:has(input:checked) {
  background: var(--color-nok-bg);
  border-color: var(--color-nok);
  color: var(--color-nok);
}

.nao-conforme-option:has(input:checked) .radio-check {
  border-color: var(--color-nok);
  background: var(--color-nok);
}

.nao-conforme-option:has(input:checked) .radio-check::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--color-white);
  border-radius: 50%;
}

/* Hover */
.conforme-option:hover {
  border-color: var(--color-ok);
  color: var(--color-ok);
}

.nao-conforme-option:hover {
  border-color: var(--color-nok);
  color: var(--color-nok);
}

/* ============================================================
   14. UPLOAD DE FOTOS
============================================================ */
.upload-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
  -webkit-user-select: none;
  min-height: 44px;
}

.btn-camera {
  background: var(--color-white);
  color: var(--mse-red);
  border: 1.5px solid var(--mse-red);
}

.btn-camera:hover {
  background: var(--mse-red-light);
  border-color: var(--mse-red-hover);
}

.btn-gallery {
  background: var(--color-white);
  color: var(--color-text-sec);
  border: 1.5px solid var(--color-border);
}

.btn-gallery:hover {
  background: #F1F4F8;
  border-color: #b0bbcc;
  color: var(--color-text);
}

/* ============================================================
   15. PREVIEW DE FOTOS
============================================================ */
.portraits {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  page-break-inside: avoid;
  break-inside: avoid;
}

.photo-wrapper {
  position: relative;
  display: inline-block;
  border-radius: var(--radius-md);
  overflow: visible;
}

.photo-wrapper img {
  width: 200px;
  height: auto;
  max-height: 600px;
  object-fit: contain;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #F8FAFB;
  display: block;
  page-break-inside: avoid;
  break-inside: avoid;
}

.btn-remove-photo {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--mse-red);
  color: var(--color-white);
  border: 2px solid var(--color-white);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
  z-index: 1;
}

.btn-remove-photo:hover {
  background: var(--mse-red-dark);
}

/* ============================================================
   16. TEXTAREA DE OBSERVAÇÕES
============================================================ */
.obs-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.obs-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-sec);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.observacoes-textarea {
  width: 100%;
  min-height: 90px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  resize: vertical;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  line-height: 1.6;
}

.observacoes-textarea::placeholder {
  color: var(--color-text-muted);
  font-size: 14px;
}

.observacoes-textarea:hover {
  border-color: #b0bbcc;
}

.observacoes-textarea:focus {
  border-color: var(--mse-red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.10);
}

.caracteres-limit {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   17. BOTÃO SUBMIT
============================================================ */
.form-footer {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
  flex: 1;
}

.footer-note svg {
  flex-shrink: 0;
  color: var(--mse-red);
}

.btn-submit {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--color-white);
  background: linear-gradient(135deg, var(--mse-red) 0%, var(--mse-red-dark) 100%);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--t-base);
  box-shadow: 0 4px 14px rgba(200, 16, 46, 0.35);
  white-space: nowrap;
  min-height: 52px;
}

.btn-submit:hover {
  background: linear-gradient(135deg, var(--mse-red-hover) 0%, var(--mse-red) 100%);
  box-shadow: 0 6px 20px rgba(200, 16, 46, 0.45);
  transform: translateY(-1px);
}

.btn-submit:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.35);
}

.btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   18. QUEBRA DE PÁGINA (PDF)
============================================================ */
.pagebreak {
  page-break-after: always;
  break-after: page;
  height: 0;
  overflow: hidden;
}

/* ============================================================
   19. STATUS PDF (gerado dinamicamente)
============================================================ */
.pdf-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  margin: 8px 0 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
}

.pdf-status.ok {
  background: var(--color-ok-bg);
  color: var(--color-ok);
  border: 1px solid var(--color-ok-border);
}

.pdf-status.nok {
  background: var(--color-nok-bg);
  color: var(--color-nok);
  border: 1px solid var(--color-nok-border);
}

/* ============================================================
   20. OBSERVAÇÕES NO PDF (gerado dinamicamente)
============================================================ */
.pdf-observacoes {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #FAFBFC;
  min-height: 50px;
  padding: 10px 14px;
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--color-text);
  display: none;
}

/* ============================================================
   21. MODO PDF — oculta UI e exibe dados copiados
============================================================ */
.modo-pdf .field-input,
.modo-pdf .observacoes-textarea,
.modo-pdf .btn-submit,
.modo-pdf .btn-upload,
.modo-pdf .btn-remove-photo,
.modo-pdf .upload-actions,
.modo-pdf .caracteres-limit,
.modo-pdf .conformity-row,
.modo-pdf .obs-label,
.modo-pdf .footer-note,
.modo-pdf .form-footer,
.modo-pdf .required {
  display: none !important;
}

.modo-pdf .pdf-observacoes,
.modo-pdf .pdf-responsavel-relatorio,
.modo-pdf .pdf-data,
.modo-pdf .pdf-nome-obra,
.modo-pdf .pdf-endereco,
.modo-pdf .pdf-empresa,
.modo-pdf .pdf-num-quartos,
.modo-pdf .pdf-num-banheiros,
.modo-pdf .pdf-num-alojados,
.modo-pdf .pdf-capacidade-maxima,
.modo-pdf .pdf-resp-compra,
.modo-pdf .pdf-resp-alojamento {
  display: block !important;
}

.modo-pdf .portraits img {
  display: block !important;
}

.modo-pdf .btn-remove-photo {
  display: none !important;
}

/* Espaçamento do campo no PDF */
.modo-pdf .field-group {
  margin-bottom: 8px;
}

/* ============================================================
   22. PRINT
============================================================ */
@media print {
  .header-mse { padding: 16px 32px; }
  .logo_header { max-height: 56px; }

  .question {
    margin-bottom: 20px;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .portraits {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .portraits img {
    page-break-inside: avoid;
    break-inside: avoid;
    display: block;
    max-width: 100%;
  }
}
