/* =========================================================
   Indicadores · Assembleia · mobile-first
   ========================================================= */

:root {
  /* Paleta JW.org — roxo + branco */
  --roxo:         #5e2a91;
  --roxo-claro:   #8b5cf6;
  --roxo-escuro:  #3d1a64;
  --roxo-acento:  #a855f7;
  --bg:           #f8f5fc;
  --bg-card:      #ffffff;
  --texto:        #1a1029;
  --texto-suave:  #4c3a66;
  --texto-fraco:  #9b8bae;
  --borda:        #e9e1f3;
  --borda-forte:  #d4c4ea;
  --sucesso:      #16a34a;
  --destaque:     #fef3c7;
  --destaque-borda: #f59e0b;
  /* Aliases (compatibilidade com código existente) */
  --azul:         var(--roxo);
  --azul-claro:   var(--roxo-claro);
  --azul-escuro:  var(--roxo-escuro);
  --sombra-sm: 0 1px 2px rgba(61,26,100,.06);
  --sombra-md: 0 4px 12px rgba(61,26,100,.10);
  --sombra-lg: 0 12px 28px rgba(61,26,100,.14);
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bot: env(safe-area-inset-bottom, 0);
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--texto);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(40px + var(--safe-bot));
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

input { font-family: inherit; }

.hidden { display: none !important; }

/* =========================================================
   TOPBAR
   ========================================================= */
.topbar {
  background: linear-gradient(135deg, var(--azul-escuro), var(--azul));
  color: #fff;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--sombra-md);
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }

.jw-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #ffffff;
  color: var(--roxo-escuro);
  text-decoration: none;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  transition: transform .12s, box-shadow .12s;
}

.jw-link:active { transform: scale(.92); }
.jw-link:hover  { box-shadow: 0 4px 12px rgba(0,0,0,.25); }

.jw-link-mark {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.02em;
  line-height: 1;
  color: var(--roxo-escuro);
}

.brand-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.18);
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px;
  backdrop-filter: blur(8px);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; font-weight: 700; }
.brand-text span { font-size: 12px; opacity: .85; margin-top: 2px; }

/* =========================================================
   CONTAINER
   ========================================================= */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 24px;
}

/* =========================================================
   SEARCH
   ========================================================= */
.search-section {
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--sombra-sm);
  margin-bottom: 16px;
  border: 1px solid var(--borda);
}

.search-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--texto-suave);
  margin-bottom: 8px;
  letter-spacing: .02em;
}

.search-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;  /* >=16px evita zoom iOS */
  border: 2px solid var(--borda);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--texto);
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
}

.search-input:focus {
  outline: none;
  border-color: var(--azul);
  background: #fff;
}

.search-input::placeholder { color: var(--texto-fraco); }

.search-results { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }

.search-result-card {
  background: linear-gradient(135deg, #fff, #f0f9ff);
  border: 2px solid var(--azul-claro);
  border-radius: var(--r-sm);
  padding: 14px;
  box-shadow: var(--sombra-sm);
}

.search-result-card .nome { font-weight: 700; font-size: 16px; color: var(--azul-escuro); }
.search-result-card .congregacao { font-size: 13px; color: var(--texto-suave); margin-top: 2px; }

.search-result-card .designacao-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--borda-forte);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.search-result-card .dia-badge {
  background: var(--azul);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

.search-result-card .setor-info { font-size: 14px; flex: 1; min-width: 0; }
.search-result-card .setor-info strong { display: block; color: var(--texto); }
.search-result-card .setor-info small { color: var(--texto-suave); }

.pin-btn {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--roxo-escuro), var(--roxo));
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 18px;
  box-shadow: var(--sombra-sm);
  transition: transform .12s, filter .12s;
  flex-shrink: 0;
}

.pin-btn:active { transform: scale(.92); filter: brightness(.95); }

.search-empty {
  text-align: center;
  padding: 16px;
  color: var(--texto-fraco);
  font-size: 14px;
}

/* =========================================================
   TABS
   ========================================================= */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--bg-card);
  padding: 6px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  border: 1px solid var(--borda);
  box-shadow: var(--sombra-sm);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--texto-suave);
  font-weight: 600;
  font-size: 12px;
  min-height: 56px;
  transition: all .15s;
}

.tab .tab-day { font-size: 13px; line-height: 1.2; }
.tab .tab-date { font-size: 11px; opacity: .7; margin-top: 2px; }

.tab.active {
  background: var(--azul);
  color: #fff;
  box-shadow: var(--sombra-sm);
}

.tab.active .tab-date { opacity: .9; }

.tab:active { transform: scale(.96); }

/* =========================================================
   COORD BANNER
   ========================================================= */
.coord-banner {
  background: linear-gradient(135deg, var(--destaque), #fde68a);
  border-left: 4px solid var(--destaque-borda);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  font-size: 14px;
}

.coord-banner strong { color: #7c2d12; }

/* =========================================================
   TURNOS
   ========================================================= */
.turnos-container { display: flex; flex-direction: column; gap: 14px; }

.turno-card {
  background: var(--bg-card);
  border-radius: var(--r-md);
  border: 1px solid var(--borda);
  overflow: hidden;
  box-shadow: var(--sombra-sm);
}

.turno-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--azul-escuro), var(--azul));
  color: #fff;
  cursor: pointer;
  user-select: none;
}

.turno-header h3 { font-size: 15px; font-weight: 700; }
.turno-header .horario { font-size: 13px; opacity: .9; font-variant-numeric: tabular-nums; }
.turno-header .chevron { transition: transform .2s; }
.turno-card.collapsed .turno-header .chevron { transform: rotate(-90deg); }

.turno-list {
  display: flex;
  flex-direction: column;
  max-height: 5000px;
  transition: max-height .25s;
}

.turno-card.collapsed .turno-list { max-height: 0; overflow: hidden; }

.designacao-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--borda);
  align-items: center;
}

.designacao-item:first-child { border-top: none; }

.designacao-item .setor {
  font-size: 12px;
  font-weight: 700;
  color: var(--roxo-escuro);
  background: #f3ebff;
  padding: 6px 8px;
  border-radius: 6px;
  text-align: center;
  line-height: 1.2;
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}

button.designacao-item-setor {
  border-color: var(--roxo-claro);
  background: linear-gradient(135deg, #f3ebff, #ede4ff);
  box-shadow: 0 1px 2px rgba(94,42,145,.10);
  position: relative;
}

button.designacao-item-setor::after {
  content: '📍';
  font-size: 10px;
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--roxo);
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: var(--sombra-sm);
}

button.designacao-item-setor:active { transform: scale(.94); }

button.designacao-item-setor:hover {
  background: linear-gradient(135deg, #ede4ff, #ddd0fa);
  border-color: var(--roxo);
}

.designacao-item .pessoa { display: flex; flex-direction: column; min-width: 0; }
.designacao-item .pessoa .nome { font-weight: 600; font-size: 14px; word-break: break-word; }
.designacao-item .pessoa .congregacao { font-size: 12px; color: var(--texto-suave); margin-top: 2px; }

.designacao-item.tbd .pessoa .nome { color: var(--texto-fraco); font-style: italic; }

/* =========================================================
   MAPA
   ========================================================= */
.mapa-view { padding: 4px 0 8px; }

.mapa-info {
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--borda);
}

.mapa-info h2 { font-size: 17px; margin-bottom: 4px; }
.mapa-info p { font-size: 13px; color: var(--texto-suave); }

.mapa-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.setor-tile {
  background: var(--bg-card);
  border: 2px solid var(--borda);
  border-radius: var(--r-md);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 88px;
  transition: all .15s;
  text-align: center;
}

.setor-tile:active { transform: scale(.97); }

.setor-tile .icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--azul-escuro), var(--azul));
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 14px;
}

.setor-tile.porta .icon { background: linear-gradient(135deg, #4338ca, #6366f1); }
.setor-tile.externa .icon { background: linear-gradient(135deg, #b45309, #f59e0b); }

.setor-tile .label { font-size: 12px; font-weight: 600; line-height: 1.2; color: var(--texto); }

.setor-tile .tile-pin {
  font-size: 10px;
  font-weight: 700;
  color: var(--roxo);
  background: #f3ebff;
  padding: 3px 7px;
  border-radius: 999px;
  margin-top: 2px;
}

/* =========================================================
   SETOR DETAIL
   ========================================================= */
.setor-detail { padding: 4px 0 8px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--borda);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--azul);
  margin-bottom: 14px;
  box-shadow: var(--sombra-sm);
}

.back-btn:active { transform: scale(.97); }

#setorTitle {
  font-size: 22px;
  margin-bottom: 14px;
  color: var(--azul-escuro);
}

.setor-day-block {
  background: var(--bg-card);
  border-radius: var(--r-md);
  border: 1px solid var(--borda);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--sombra-sm);
}

.setor-day-block h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--azul);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--borda);
}

.setor-turno-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px dashed var(--borda);
  align-items: center;
}

.setor-turno-row:first-of-type { border-top: none; padding-top: 0; }

.setor-turno-row .horario {
  font-size: 12px;
  font-weight: 700;
  color: var(--texto-suave);
  font-variant-numeric: tabular-nums;
  background: #f8fafc;
  padding: 6px 8px;
  border-radius: 6px;
  text-align: center;
}

.setor-turno-row .pessoa .nome { font-size: 14px; font-weight: 600; }
.setor-turno-row .pessoa .congregacao { font-size: 12px; color: var(--texto-suave); margin-top: 2px; }

/* =========================================================
   LOCALIZAÇÃO NO MAPA (botão + modal)
   ========================================================= */
.btn-localizar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--roxo-escuro), var(--roxo));
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--sombra-md);
  margin: 4px 0 16px;
  transition: transform .12s, filter .12s;
}

.btn-localizar:active { transform: scale(.96); filter: brightness(.95); }

.btn-localizar .pin-icon { font-size: 16px; }

/* Modal/Overlay do mapa */
.mapa-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26,16,41,.92);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bot));
  animation: fadeIn .2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.mapa-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  color: #fff;
}

.mapa-modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.mapa-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.25);
}

.mapa-close:active { transform: scale(.92); }

.mapa-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  padding: 4px;
}

/* Wrapper com aspect-ratio igual ao da imagem (1654x2339) — garante que % do
   marcador batam exatamente com a posição na imagem, sem deslocamento por
   espaço vazio do object-fit. */
.mapa-img {
  position: relative;
  aspect-ratio: 1654 / 2339;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Quando o container é mais estreito que alto, a largura limita */
@supports not (aspect-ratio: 1 / 1) {
  .mapa-img { height: 100%; width: calc(100% * 1654 / 2339); }
}

.mapa-img img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
}

/* Marcador retangular (highlight tipo caneta) */
.mapa-marker {
  position: absolute;
  border: 4px solid #dc2626;
  border-radius: 14px;
  background: rgba(254, 240, 138, .35);
  box-sizing: border-box;
  pointer-events: none;
  animation: markerIn .4s cubic-bezier(.34, 1.56, .64, 1) backwards,
             markerPulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(220,38,38, .5);
}

@keyframes markerIn {
  0%   { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

@keyframes markerPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38, .5); }
  50%      { box-shadow: 0 0 0 14px rgba(220,38,38, 0); }
}

.mapa-marker .marker-label {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #dc2626;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(220,38,38, .5);
}

.mapa-marker .marker-label::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px; height: 8px;
  background: #dc2626;
  margin-top: -4px;
}

/* Quando o marcador está perto do topo, exibir label EMBAIXO */
.mapa-marker.label-below .marker-label {
  bottom: auto;
  top: calc(100% + 8px);
}

.mapa-marker.label-below .marker-label::after {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: -4px;
}

.mapa-modal-foot {
  margin-top: 12px;
  color: #fff;
  font-size: 13px;
  text-align: center;
  opacity: .85;
}

.mapa-modal-foot strong { color: #fff; }

/* =========================================================
   FOOTER
   ========================================================= */
.footer {
  text-align: center;
  padding: 30px 16px 16px;
  color: var(--texto-suave);
  font-size: 12px;
  line-height: 1.6;
}

.footer-coord { font-size: 11px; opacity: .8; margin-top: 4px; }

/* =========================================================
   HIGHLIGHT (busca)
   ========================================================= */
mark {
  background: #fef08a;
  color: var(--texto);
  padding: 0 2px;
  border-radius: 3px;
}

/* =========================================================
   DESKTOP / TABLET
   ========================================================= */
@media (min-width: 600px) {
  .container { padding: 20px 20px 32px; }
  .topbar { padding: 18px 24px; }
  .brand-icon { width: 48px; height: 48px; font-size: 24px; }
  .brand-text strong { font-size: 19px; }
  .brand-text span { font-size: 13px; }

  .search-input { font-size: 17px; padding: 16px 18px; }
  .tab { min-height: 64px; font-size: 13px; }
  .tab .tab-day { font-size: 14px; }
  .tab .tab-date { font-size: 12px; }

  .mapa-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .designacao-item {
    grid-template-columns: 130px 1fr;
    padding: 14px 18px;
  }

  .designacao-item .setor { font-size: 13px; }
  .designacao-item .pessoa .nome { font-size: 15px; }
}

@media (min-width: 900px) {
  .mapa-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* =========================================================
   PRINT
   ========================================================= */
@media print {
  .topbar, .tabs, .search-section, .footer, .back-btn { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .turno-card { break-inside: avoid; box-shadow: none; border: 1px solid #000; }
  .turno-header { background: #1e40af !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .coord-banner { background: #fef3c7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; padding: 0; }
}
