/* ===== CSAT web — paleta fiel ao app MAUI (Colors.xaml) ===== */
:root {
  --survey-blue-dark: #0A1A33;
  --survey-blue: #1559C4;
  --card-white: #FDFDFD;
  --face-red: #E8455A;
  --face-orange: #F0803C;
  --face-yellow: #F2C230;
  --face-lightgreen: #9BC24E;
  --face-green: #7CC24E;
  --report-accent: #3EABFE;
  --report-accent-light: #D8EDFF;
  --gray-900: #212121;
  --gray-600: #404040;
  --gray-500: #6E6E6E;
  --gray-200: #C8C8C8;
  --gray-100: #E1E1E1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, "Open Sans", sans-serif;
  background: var(--survey-blue-dark);
  color: var(--gray-900);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

/* garante que o atributo hidden sempre esconda (vence regras de display do autor) */
[hidden] { display: none !important; }

.view { display: none; height: 100vh; height: 100dvh; }
.view.is-active { display: block; }
#view-survey.is-active { display: flex; flex-direction: column; }

/* ============ PESQUISA ============ */
#view-survey {
  padding: 14px;
  background: var(--survey-blue-dark);
  position: relative;
  height: 100vh; height: 100dvh;
}
#hidden-gesture {
  position: absolute; top: 0; right: 0;
  width: 80px; height: 80px; z-index: 30;
}
.survey-frame {
  flex: 1; min-height: 0;
  width: 100%; max-width: 820px; margin: 0 auto;
  background: var(--survey-blue);
  border-radius: 28px;
  padding: clamp(16px, 3vh, 28px) clamp(16px, 2.5vw, 24px);
  display: flex; flex-direction: column; gap: clamp(12px, 2.4vh, 22px);
}
.survey-header { text-align: center; color: #fff; flex: none; }
.survey-header h1 { margin: 0 0 6px; font-size: clamp(22px, 3.4vh, 38px); font-weight: 700; }
.survey-header p { margin: 0; font-size: clamp(13px, 2vh, 21px); opacity: .96; }

.survey-card {
  flex: 1; min-height: 0; background: var(--card-white); border-radius: 24px;
  padding: clamp(14px, 2.5vh, 24px); overflow-y: auto;
  display: flex; flex-direction: column; justify-content: safe center;
  gap: clamp(14px, 3.2vh, 28px);
}
.question { text-align: center; }
.question h2 { margin: 0 0 clamp(8px, 1.6vh, 14px); font-size: clamp(16px, 2.2vh, 24px); font-weight: 700; color: var(--gray-900); }

.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: clamp(4px, 1vw, 8px); }
.face-btn {
  border: 3px solid transparent; background: transparent; border-radius: 16px;
  padding: clamp(4px, 1vh, 8px) 4px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: clamp(3px, 0.8vh, 6px);
  transition: transform .08s, border-color .12s, background .12s;
}
.face-btn:active { transform: scale(.94); }
.face-btn svg { width: clamp(38px, 8.5vmin, 68px); height: clamp(38px, 8.5vmin, 68px); }
.face-btn .num { font-weight: 700; font-size: clamp(13px, 1.6vh, 15px); color: var(--gray-600); }
.face-btn .lbl { font-size: clamp(9px, 1.3vh, 11px); line-height: 1.15; color: var(--gray-500); white-space: pre-line; }
.face-btn.selected { border-color: var(--survey-blue); background: var(--report-accent-light); }
.face-btn.selected .num { color: var(--survey-blue); }

.btn-finish {
  flex: none; align-self: center;
  margin-top: clamp(20px, 4vh, 40px);
  padding: 0; width: 360px; max-width: 90vw;
  height: clamp(60px, 9vh, 76px);
  border: none; border-radius: 18px;
  background: var(--survey-blue); color: #fff; font-size: clamp(21px, 3vh, 28px);
  font-weight: 700; cursor: pointer;
}
.btn-finish:disabled { opacity: .45; }

.thankyou {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: var(--survey-blue); z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.thankyou-check { color: var(--face-green); font-size: 90px; line-height: 1; }
.thankyou-text { color: #fff; font-size: clamp(30px, 5vw, 44px); font-weight: 700; text-align: center; }

#view-done { background: var(--survey-blue); color: #fff; display: none; }
#view-done.is-active { display: flex; align-items: center; justify-content: center; padding: 24px; }
.done-box { text-align: center; max-width: 480px; }
.done-box h1 { font-size: clamp(26px, 5vw, 40px); margin: 12px 0 8px; }
.done-box p { font-size: clamp(15px, 2.4vw, 20px); opacity: .95; }

/* Gerador de QR (admin) */
.qr-form { max-width: 520px; margin: 0 auto; }
.qr-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--gray-600); margin-bottom: 12px; }
.qr-form input { padding: 11px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 16px; }
.qr-preview { text-align: center; background: #fff; border: 1px solid var(--gray-100); border-radius: 12px; padding: 20px; margin-top: 16px; }
.qr-preview img { width: 260px; height: 260px; image-rendering: pixelated; }
.qr-preview .qr-name { font-size: 20px; font-weight: 700; margin-top: 10px; color: var(--gray-900); }
.qr-preview .qr-url { font-size: 12px; color: var(--gray-500); word-break: break-all; margin-top: 4px; }

.config-gate {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 55;
  background: var(--survey-blue-dark); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 24px;
}
.config-gate-title { font-size: clamp(24px, 4vw, 36px); font-weight: 700; }
.config-gate p { margin: 0; font-size: clamp(15px, 2.4vw, 20px); opacity: .9; max-width: 420px; }
.config-gate .btn-secondary { background: #fff; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(33,33,33,.9); color: #fff; padding: 16px 24px; border-radius: 12px;
  font-size: 18px; z-index: 60; max-width: 90%; text-align: center;
}

/* ============ AJUSTES SÓ DO QUIOSQUE (index.html) ============
   A página do QR (avaliar.html) não tem a classe .kiosk no body,
   portanto mantém os tamanhos originais. */
body.kiosk .survey-frame {
  padding: clamp(22px, 4vh, 40px) clamp(20px, 3vw, 32px);
  gap: clamp(20px, 3.6vh, 34px);
}
body.kiosk .survey-header h1 { margin: 0 0 10px; font-size: clamp(26px, 4.2vh, 46px); }
body.kiosk .survey-header p  { font-size: clamp(15px, 2.6vh, 26px); }

body.kiosk .survey-card {
  padding: clamp(22px, 4vh, 40px);
  gap: clamp(44px, 9vh, 88px);
}
body.kiosk .question h2 {
  margin: 0 0 clamp(16px, 3vh, 28px);
  font-size: clamp(21px, 3.2vh, 34px);
}
body.kiosk .face-btn .num { font-size: clamp(17px, 2.1vh, 21px); }
body.kiosk .face-btn .lbl { font-size: clamp(14px, 2.3vh, 19px); line-height: 1.2; }

/* ============ ÁREA ADMIN (pin/relatório/config) ============ */
.view-admin { background: #f4f6f8; color: var(--gray-900); overflow: hidden; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--gray-100);
  position: sticky; top: 0; z-index: 10;
}
.admin-topbar strong { font-size: 17px; }
.btn-ghost { background: transparent; border: none; color: var(--survey-blue); font-size: 15px; padding: 8px; cursor: pointer; }
.btn-primary {
  background: var(--survey-blue); color: #fff; border: none; border-radius: 10px;
  padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary:active { opacity: .85; }
.btn-secondary {
  background: #fff; color: var(--survey-blue); border: 1.5px solid var(--survey-blue);
  border-radius: 10px; padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-secondary:active { background: var(--report-accent-light); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row button { flex: 1; min-width: 150px; }

.report-scroll { height: calc(100vh - 49px); height: calc(100dvh - 49px); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; }

/* PIN */
.view-admin#view-pin { display: none; }
.view-admin#view-pin.is-active, .view-admin.is-active { display: block; }
.admin-box { max-width: 360px; margin: 8vh auto; background: #fff; border-radius: 16px; padding: 28px; text-align: center; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.pin-box h2 { margin: 0 0 4px; }
.muted { color: var(--gray-500); margin: 0 0 18px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin-bottom: 14px; height: 18px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gray-200); }
.pin-dots span.filled { background: var(--survey-blue); border-color: var(--survey-blue); }
.pin-error { color: var(--face-red); font-weight: 600; margin-bottom: 10px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 8px 0 16px; }
.pin-pad button {
  height: 62px; font-size: 24px; border: 1px solid var(--gray-100); background: #fff;
  border-radius: 12px; cursor: pointer;
}
.pin-pad button:active { background: var(--report-accent-light); }
.pin-pad button.empty { visibility: hidden; }

/* Relatório */
.report-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.report-filters label { display: flex; flex-direction: column; font-size: 13px; color: var(--gray-500); gap: 4px; }
.report-filters input, .report-filters select { padding: 9px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 15px; }
.report-status { color: var(--gray-500); padding: 6px 0; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border-radius: 12px; padding: 16px; border-left: 4px solid var(--report-accent); }
.kpi .val { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.kpi .lbl { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

.report-block { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.report-block h3 { margin: 0 0 14px; font-size: 16px; }
.dist-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dist-grid h4 { margin: 0 0 10px; font-size: 14px; color: var(--gray-600); }
@media (max-width: 640px) { .dist-grid { grid-template-columns: 1fr; } }

.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.dist-row { display: grid; grid-template-columns: 110px 1fr 84px; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.dist-row .bar-track { display: block; background: var(--gray-100); border-radius: 6px; height: 20px; overflow: hidden; }
.dist-row .bar-fill { display: block; height: 100%; border-radius: 6px; transition: width .3s ease; }
.dist-row .dist-val { text-align: right; color: var(--gray-600); }

.timeline { overflow-x: auto; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 18px; }
.summary-table caption { text-align: left; font-weight: 700; padding: 4px 0 8px; }
.summary-table th, .summary-table td { border: 1px solid var(--gray-100); padding: 8px; text-align: center; }
.summary-table th { background: var(--report-accent-light); }
.summary-table td.left, .summary-table th.left { text-align: left; }
.summary-table .sat { font-weight: 700; color: var(--survey-blue); }

.report-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 40px; }

/* Configurações */
.settings-form { max-width: 560px; margin: 0 auto; }
.settings-form fieldset { border: 1px solid var(--gray-100); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; background: #fff; }
.settings-form legend { font-weight: 700; padding: 0 6px; font-size: 14px; }
.settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--gray-600); margin-bottom: 12px; }
.settings-form input, .settings-form textarea, .settings-form select {
  padding: 11px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 15px; font-family: inherit;
}
.req { color: var(--face-red); font-weight: 700; }
.field-error { color: var(--face-red); font-size: 12px; margin: -6px 0 12px; }
.settings-form input.invalid, .settings-form textarea.invalid { border-color: var(--face-red); background: #fff6f7; }
.switch-row { flex-direction: row !important; align-items: center; gap: 10px !important; }
.switch-row input { width: 20px; height: 20px; }
.btn-save { width: 100%; margin-bottom: 40px; }
.btn-danger {
  background: var(--face-red); color: #fff; border: none; border-radius: 10px;
  padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn-danger:active { opacity: .85; }
.sync-status { font-size: 13px; margin-top: 8px; color: var(--gray-500); }
.sync-status.ok { color: #2e7d32; }
.sync-status.err { color: var(--face-red); }
.saved-msg { color: #2e7d32; text-align: center; }

@media print {
  @page { size: A4; margin: 12mm; }
  /* imprime as cores de fundo (barras, swatches, cabeçalhos) */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html, body { background: #fff !important; }
  .view { display: none !important; }
  #view-report.is-active { display: block !important; height: auto; }
  .admin-topbar, .report-filters, .report-actions, .report-status, .btn-ghost { display: none !important; }
  .report-scroll { height: auto; overflow: visible; padding: 0; }
  .report-block, .kpi { box-shadow: none; border: 1px solid #ddd; }
  /* mantém inteiros: KPIs, cada tabela, linhas, colunas de distribuição, gráfico
     (o bloco "Resumo" pode quebrar ENTRE as tabelas, mas cada tabela fica inteira) */
  .kpi, .summary-table, .dist-row, .dist-grid > div, .timeline, tr {
    break-inside: avoid; page-break-inside: avoid;
  }
  /* título não fica órfão no fim da página */
  .report-block h3, .report-block h4, .summary-table caption {
    break-after: avoid; page-break-after: avoid;
  }
  /* gráfico de evolução cabe na largura da folha */
  .timeline svg { max-width: 100%; height: auto; }
}
