/* FOQUE Pesquisas — identidade: roxo #770fb2 + verde-limão #8bff00, fundos neutros */
:root {
  --fq-primary: #770fb2;
  --fq-primary-600: #62099a;
  --fq-primary-50: #f4eafb;
  --fq-accent: #8bff00;
  --fq-accent-600: #6fd100;
  --fq-bg: #f5f4f8;
  --fq-card: #ffffff;
  --fq-border: #e7e2ee;
  --fq-text: #1d1530;
  --fq-muted: #6b6280;
  --fq-sidebar: #ffffff;
  --fq-sidebar-w: 256px;
  --fq-radius: 14px;
  --fq-shadow: 0 1px 2px rgba(29, 21, 48, .05), 0 4px 14px rgba(29, 21, 48, .05);
  --fq-grad: linear-gradient(135deg, var(--fq-primary) 0%, #5b0b8f 55%, #3d0a63 100%);
  --fq-grad-accent: linear-gradient(90deg, var(--fq-primary), var(--fq-accent));
  --bs-primary: var(--fq-primary);
  --bs-primary-rgb: 119, 15, 178;
  --bs-link-color: var(--fq-primary);
  --bs-link-hover-color: var(--fq-primary-600);
  --bs-body-bg: var(--fq-bg);
  --bs-body-color: var(--fq-text);
  --bs-border-color: var(--fq-border);
  --bs-border-radius: 10px;
  --bs-body-font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="dark"] {
  --fq-primary: #b36be0;
  --fq-primary-600: #c68aea;
  --fq-primary-50: #2a1a3a;
  --fq-bg: #120d1b;
  --fq-card: #1b1427;
  --fq-border: #2e2440;
  --fq-text: #efe9f7;
  --fq-muted: #a79bbd;
  --fq-sidebar: #17101f;
  --fq-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --bs-body-bg: var(--fq-bg);
  --bs-body-color: var(--fq-text);
  --bs-border-color: var(--fq-border);
  --bs-primary-rgb: 179, 107, 224;
  --bs-secondary-bg: #241a33;
  --bs-tertiary-bg: #1b1427;
}
body { background: var(--fq-bg); color: var(--fq-text); }
a { text-decoration: none; }
.text-muted, .text-secondary { color: var(--fq-muted) !important; }

.btn-primary { --bs-btn-bg: var(--fq-primary); --bs-btn-border-color: var(--fq-primary); --bs-btn-hover-bg: var(--fq-primary-600); --bs-btn-hover-border-color: var(--fq-primary-600); --bs-btn-active-bg: var(--fq-primary-600); --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-disabled-bg: var(--fq-primary); --bs-btn-disabled-border-color: var(--fq-primary); }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #12081c; --bs-btn-hover-color: #12081c; }
.btn-outline-primary { --bs-btn-color: var(--fq-primary); --bs-btn-border-color: var(--fq-primary); --bs-btn-hover-bg: var(--fq-primary); --bs-btn-hover-border-color: var(--fq-primary); --bs-btn-active-bg: var(--fq-primary); --bs-btn-hover-color: #fff; }
.btn-accent { background: var(--fq-accent); color: #1d1530; border-color: var(--fq-accent); font-weight: 600; }
.btn-accent:hover { background: var(--fq-accent-600); border-color: var(--fq-accent-600); color: #1d1530; }
.form-control:focus, .form-select:focus { border-color: var(--fq-primary); box-shadow: 0 0 0 .2rem rgba(119, 15, 178, .15); }
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
.form-check-input:checked { background-color: var(--fq-primary); border-color: var(--fq-primary); }

/* ---------- Layout ---------- */
.fq-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--fq-sidebar-w); background: var(--fq-sidebar); border-right: 1px solid var(--fq-border); display: flex; flex-direction: column; z-index: 1040; transition: transform .25s, width .25s; }
.fq-brand { display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem; height: 64px; border-bottom: 1px solid var(--fq-border); }
.fq-brand img { height: 34px; width: auto; }
.fq-brand .nm { font-weight: 800; letter-spacing: -.02em; line-height: 1; font-size: 1.15rem; color: var(--fq-text); }
.fq-brand .nm small { display: block; font-weight: 600; font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--fq-primary); margin-top: 3px; }
.fq-nav { padding: .75rem .6rem; overflow-y: auto; flex: 1; }
.fq-nav .grp { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--fq-muted); padding: .9rem .75rem .3rem; font-weight: 700; }
.fq-nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 10px; color: var(--fq-text); font-size: .92rem; font-weight: 500; position: relative; margin-bottom: 2px; }
.fq-nav a i { font-size: 1.1rem; color: var(--fq-muted); width: 1.25rem; text-align: center; }
.fq-nav a:hover { background: var(--fq-primary-50); }
.fq-nav a.active { background: var(--fq-primary-50); color: var(--fq-primary); font-weight: 700; }
.fq-nav a.active i { color: var(--fq-primary); }
.fq-nav a.active::before { content: ""; position: absolute; left: -.6rem; top: 20%; bottom: 20%; width: 4px; border-radius: 0 4px 4px 0; background: var(--fq-accent); }
.fq-side-foot { padding: .75rem 1rem; border-top: 1px solid var(--fq-border); font-size: .72rem; color: var(--fq-muted); }
.fq-main { margin-left: var(--fq-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin .25s; }
body.sb-collapsed .fq-sidebar { width: 72px; }
body.sb-collapsed .fq-main { margin-left: 72px; }
body.sb-collapsed .fq-brand .nm, body.sb-collapsed .fq-nav a span, body.sb-collapsed .fq-nav .grp, body.sb-collapsed .fq-side-foot { display: none; }
body.sb-collapsed .fq-nav a { justify-content: center; }
body.sb-collapsed .fq-nav a.active::before { left: -.6rem; }
.fq-top { height: 64px; background: var(--fq-sidebar); border-bottom: 1px solid var(--fq-border); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 1030; }
.fq-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--fq-grad-accent); opacity: .55; }
.fq-content { padding: 1.5rem; flex: 1; max-width: 1600px; width: 100%; }
.fq-icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--fq-border); background: var(--fq-card); color: var(--fq-text); display: inline-flex; align-items: center; justify-content: center; position: relative; }
.fq-icon-btn:hover { background: var(--fq-primary-50); }
.fq-dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--fq-accent); color: #1d1530; font-size: .68rem; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.fq-conn { font-size: .78rem; font-weight: 600; padding: .3rem .65rem; border-radius: 99px; display: inline-flex; align-items: center; gap: .4rem; background: #e8fbd0; color: #2f6b00; }
.fq-conn.off { background: #ffe9d1; color: #8a4b00; }
.fq-conn .d { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.fq-user { display: flex; align-items: center; gap: .6rem; padding: .2rem .35rem .2rem .2rem; border-radius: 99px; border: 1px solid var(--fq-border); background: var(--fq-card); color: var(--fq-text); }
.fq-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--fq-grad); color: #fff; font-weight: 700; font-size: .8rem; display: flex; align-items: center; justify-content: center; }
.fq-survey-pick { max-width: 260px; font-size: .85rem; }

/* ---------- Cards ---------- */
.fq-card { background: var(--fq-card); border: 1px solid var(--fq-border); border-radius: var(--fq-radius); box-shadow: var(--fq-shadow); }
.fq-card > .hd { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--fq-border); }
.fq-card > .hd h2, .fq-card > .hd h3 { font-size: .95rem; font-weight: 700; margin: 0; }
.fq-card > .bd { padding: 1.1rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.page-head .sub { color: var(--fq-muted); font-size: .9rem; }
.kpi { padding: 1rem 1.1rem; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--fq-grad-accent); }
.kpi .lb { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fq-muted); font-weight: 700; }
.kpi .vl { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.kpi .ft { font-size: .78rem; color: var(--fq-muted); }
.kpi i.bg { position: absolute; right: .8rem; top: .7rem; font-size: 1.6rem; color: var(--fq-primary); opacity: .18; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.progress { height: 8px; background: var(--fq-primary-50); }
.progress-bar { background: var(--fq-grad-accent); }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--fq-muted); font-weight: 700; border-bottom-width: 1px; white-space: nowrap; background: transparent; }
.table-hover > tbody > tr:hover > * { background: var(--fq-primary-50); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--fq-muted); }
.empty i { font-size: 2.4rem; color: var(--fq-primary); opacity: .35; display: block; margin-bottom: .5rem; }
.badge { font-weight: 600; }
.filters .form-select, .filters .form-control { font-size: .85rem; }
.demo-banner { background: #fff7d6; color: #6a5200; border-bottom: 1px solid #f0dc8a; font-size: .8rem; padding: .35rem 1rem; text-align: center; }
.disclaimer { border-left: 4px solid var(--fq-accent-600); background: var(--fq-primary-50); padding: .75rem 1rem; border-radius: 8px; font-size: .85rem; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero { background: var(--fq-grad); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::before { content: ""; position: absolute; width: 520px; height: 520px; right: -160px; bottom: -160px; background: radial-gradient(circle, rgba(139, 255, 0, .35), transparent 65%); }
.auth-hero img.logo { max-width: 320px; width: 70%; }
.auth-hero h2 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; max-width: 440px; }
.auth-hero .pill { display: inline-flex; gap: .5rem; align-items: center; background: rgba(255, 255, 255, .12); padding: .35rem .8rem; border-radius: 99px; font-size: .8rem; margin: .2rem .3rem .2rem 0; }
.auth-hero .pill i { color: var(--fq-accent); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--fq-card); }
.auth-form .box { width: 100%; max-width: 400px; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } .auth-form { min-height: 100vh; } }

/* ---------- Mapa ---------- */
.map-shell { position: relative; border-radius: var(--fq-radius); overflow: hidden; border: 1px solid var(--fq-border); background: #ddd; }
.map-shell .map { height: 100%; width: 100%; }
.map-full .map-shell { height: calc(100vh - 64px - 3rem - 56px); min-height: 420px; }
.map-shell.is-fs { position: fixed; inset: 0; z-index: 2000; border-radius: 0; height: 100vh !important; }
.map-panel { position: absolute; z-index: 800; top: 12px; left: 12px; width: 300px; max-height: calc(100% - 24px); overflow: auto; background: var(--fq-card); border: 1px solid var(--fq-border); border-radius: 12px; box-shadow: var(--fq-shadow); }
.map-panel .sec { padding: .7rem .85rem; border-bottom: 1px solid var(--fq-border); }
.map-panel .sec:last-child { border-bottom: 0; }
.map-panel h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fq-muted); font-weight: 700; margin: 0 0 .4rem; }
.map-legend { position: absolute; z-index: 800; right: 12px; bottom: 28px; background: var(--fq-card); border: 1px solid var(--fq-border); border-radius: 10px; padding: .5rem .75rem; font-size: .78rem; box-shadow: var(--fq-shadow); }
.map-legend .it { display: flex; align-items: center; gap: .45rem; margin: 2px 0; }
.map-legend .sw { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.map-search-box { position: absolute; z-index: 900; top: 10px; left: 56px; width: min(420px, calc(100% - 130px)); }
.map-search-box .list-group { max-height: 260px; overflow: auto; }
.map-toggle { position: absolute; z-index: 801; top: 12px; left: 12px; }
.map-panel.hidden { display: none; }
.fq-pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.45); }
.leaflet-popup-content { font-size: .85rem; margin: .7rem .85rem; min-width: 180px; }
.leaflet-popup-content b { color: var(--fq-primary); }
[data-bs-theme="dark"] .leaflet-popup-content-wrapper, [data-bs-theme="dark"] .leaflet-popup-tip { background: #1b1427; color: #efe9f7; }
@media (max-width: 768px) { .map-panel { width: calc(100% - 24px); max-height: 55%; } .map-legend { display: none; } }

/* ---------- Questionário / construtor ---------- */
.q-item { border: 1px solid var(--fq-border); border-radius: 12px; padding: .8rem 1rem; background: var(--fq-card); margin-bottom: .6rem; display: flex; gap: .8rem; align-items: flex-start; }
.q-item .num { width: 30px; height: 30px; border-radius: 8px; background: var(--fq-primary-50); color: var(--fq-primary); font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.q-item .sec { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--fq-primary); font-weight: 700; }
.q-opts span { display: inline-block; background: var(--fq-primary-50); border-radius: 99px; padding: 1px 9px; font-size: .75rem; margin: 2px 3px 0 0; }

/* ---------- Coleta (mobile-first) ---------- */
body.collector { background: var(--fq-bg); }
.col-top { position: sticky; top: 0; z-index: 50; background: var(--fq-card); border-bottom: 1px solid var(--fq-border); padding: .6rem 1rem; display: flex; align-items: center; gap: .6rem; }
.col-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--fq-grad-accent); }
.col-wrap { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.col-q { font-size: 1.35rem; font-weight: 700; line-height: 1.3; margin-bottom: .4rem; }
.col-help { color: var(--fq-muted); margin-bottom: 1rem; }
.opt { display: flex; align-items: center; gap: .85rem; width: 100%; text-align: left; padding: 1rem 1.1rem; border: 2px solid var(--fq-border); background: var(--fq-card); border-radius: 14px; margin-bottom: .6rem; font-size: 1.05rem; font-weight: 500; color: var(--fq-text); min-height: 60px; }
.opt .mk { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--fq-border); flex: none; display: flex; align-items: center; justify-content: center; font-size: .95rem; color: transparent; }
.opt.multi .mk { border-radius: 8px; }
.opt.on { border-color: var(--fq-primary); background: var(--fq-primary-50); }
.opt.on .mk { background: var(--fq-primary); border-color: var(--fq-primary); color: #fff; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.scale .opt { justify-content: center; padding: 1rem .2rem; font-size: 1.3rem; font-weight: 800; margin: 0; }
.col-foot { position: fixed; left: 0; right: 0; bottom: 0; background: var(--fq-card); border-top: 1px solid var(--fq-border); padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); z-index: 60; }
.col-foot .in { max-width: 720px; margin: 0 auto; display: flex; gap: .6rem; }
.col-foot .btn { min-height: 52px; font-size: 1.05rem; font-weight: 700; }
.btn-xl { min-height: 54px; font-size: 1.05rem; font-weight: 700; border-radius: 14px; }
.survey-tile { display: block; padding: 1rem 1.1rem; color: inherit; }
.survey-tile:hover { border-color: var(--fq-primary); }
.sync-chip { font-size: .75rem; font-weight: 700; padding: .2rem .6rem; border-radius: 99px; white-space: nowrap; flex: none; }
.consent-box { max-height: 38vh; overflow: auto; border: 1px solid var(--fq-border); border-radius: 12px; padding: 1rem; background: var(--fq-card); }

/* Modais com <form> envolvendo cabeçalho/corpo/rodapé: mantém o rodapé (botão Salvar) sempre visível e rola só o corpo */
.modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; max-height: 100%; }
.modal-content > form > .modal-body { overflow-y: auto; }
#cfg-form > .tab-pane { display: none; }
#cfg-form > .tab-pane.active { display: block; }
#cfg-save { display: none; }
#cfg-form:has(> .tab-pane.active) #cfg-save { display: block; }
/* ---------- Toast ---------- */
.fq-toasts { position: fixed; top: 76px; right: 16px; z-index: 3000; display: flex; flex-direction: column; gap: .5rem; }
.fq-toast { min-width: 260px; max-width: 380px; background: var(--fq-card); border: 1px solid var(--fq-border); border-left: 4px solid var(--fq-primary); border-radius: 10px; padding: .7rem .9rem; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: .88rem; animation: fqin .25s ease; }
.fq-toast.success { border-left-color: var(--fq-accent-600); }
.fq-toast.danger, .fq-toast.error { border-left-color: #dc3545; }
.fq-toast.warning { border-left-color: #f0a500; }
@keyframes fqin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.fq-loading { display: flex; align-items: center; justify-content: center; padding: 2rem; color: var(--fq-muted); gap: .6rem; }
.fq-splash { position: fixed; inset: 0; background: var(--fq-grad); display: flex; align-items: center; justify-content: center; z-index: 5000; transition: opacity .4s; }
.fq-splash img { width: 110px; animation: fqpulse 1.2s ease-in-out infinite; }
@keyframes fqpulse { 50% { transform: scale(1.08); } }

@media (max-width: 991px) {
  .fq-sidebar { transform: translateX(-100%); width: var(--fq-sidebar-w) !important; }
  body.sb-open .fq-sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .fq-main, body.sb-collapsed .fq-main { margin-left: 0; }
  body.sb-collapsed .fq-brand .nm, body.sb-collapsed .fq-nav a span, body.sb-collapsed .fq-nav .grp, body.sb-collapsed .fq-side-foot { display: revert; }
  .fq-content { padding: 1rem; }
  .fq-survey-pick, .fq-hide-sm { display: none !important; }
}
@media print { .fq-sidebar, .fq-top, .no-print, .fq-toasts { display: none !important; } .fq-main { margin: 0 !important; } .fq-card { box-shadow: none; break-inside: avoid; } }
