/* =====================================================================
   Super Voluntários — camada de app iOS.
   TUDO escopado em html.ios-app (ativado só no celular pelo app-shell.js).
   No desktop, nada aqui aplica — a versão web continua intacta.
   ===================================================================== */
html.ios-app, html.ios-app body {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
html.ios-app body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  padding-top: calc(env(safe-area-inset-top) + 50px);
  padding-bottom: calc(env(safe-area-inset-bottom) + 60px);
  min-height: 100vh;
}
html.ios-app.no-tabbar body { padding-bottom: env(safe-area-inset-bottom); }
html.ios-app.no-topbar body { padding-top: env(safe-area-inset-top); }

/* esconde a topbar de desktop */
html.ios-app #sv-topbar { display: none !important; }

/* ---- Barra superior do app ---- */
.ios-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  height: calc(env(safe-area-inset-top) + 50px);
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.86);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid rgba(0,0,0,0.12);
}
.ios-topbar img { height: 26px; }
.ios-topbar .it-back {
  position: absolute; left: 6px; bottom: 7px; height: 36px; min-width: 36px;
  display: flex; align-items: center; gap: 2px; padding: 0 8px;
  background: none; border: 0; color: var(--brand-dark); font-size: 16px; font-weight: 600; cursor: pointer;
}
.ios-topbar .it-back svg { width: 22px; height: 22px; }
.ios-topbar .it-refresh {
  position: absolute; right: 6px; bottom: 7px; height: 36px; width: 40px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--brand-dark); cursor: pointer;
}
.ios-topbar .it-refresh svg { width: 22px; height: 22px; }
.ios-topbar .it-refresh:active { opacity: .5; }
/* botão de mandar aviso (só organização) — à esquerda do refresh */
.ios-topbar .it-avisos {
  position: absolute; right: 46px; bottom: 7px; height: 36px; width: 38px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--brand-dark); cursor: pointer;
}
.ios-topbar .it-avisos svg { width: 23px; height: 23px; }
.ios-topbar .it-avisos:active { opacity: .5; }
/* ---- Avisos: card bonito abaixo da logo ---- */
#ios-aviso { position: sticky; top: calc(env(safe-area-inset-top) + 50px); z-index: 85; background: var(--bg); padding: 10px 16px 4px; }
#ios-aviso:empty { display: none; }
.aviso-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: #fff; border-radius: 16px; padding: 13px 15px; margin-bottom: 8px;
  border-left: 4px solid var(--brand);
  box-shadow: 0 1px 3px rgba(0,30,50,0.07), 0 8px 22px rgba(0,30,50,0.08);
}
.aviso-item.imp { border-left-color: #dc2626; background: #fff6f6; }
.aviso-ic { font-size: 20px; line-height: 1.25; flex-shrink: 0; }
.aviso-body { flex: 1; min-width: 0; }
.aviso-eyebrow { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand-dark); margin-bottom: 2px; }
.aviso-item.imp .aviso-eyebrow { color: #dc2626; }
.aviso-msg { font-size: 15px; font-weight: 700; color: var(--navy); line-height: 1.35; letter-spacing: -0.01em; }
.aviso-item.imp .aviso-msg { color: #991b1b; }
.aviso-x { background: none; border: 0; color: #b6c2c2; font-size: 16px; cursor: pointer; flex-shrink: 0; padding: 2px; line-height: 1; }

/* ---- Mini-chat de avisos (sheet da organização) ---- */
.av-bubble { background: #fff; border-radius: 14px; border-left: 3px solid var(--brand); padding: 10px 13px; margin-bottom: 9px; box-shadow: 0 1px 2px rgba(0,30,50,0.05); }
.av-bubble.imp { border-left-color: #dc2626; background: #fff6f6; }
.av-bubble-msg { font-size: 14.5px; color: var(--navy); line-height: 1.35; font-weight: 600; }
.av-bubble.imp .av-bubble-msg { color: #991b1b; }
.av-bubble-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 7px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.av-acts { display: flex; gap: 6px; flex-shrink: 0; }
.av-acts button { background: #eef3f3; border: 0; border-radius: 8px; padding: 4px 9px; font-size: 11.5px; font-weight: 700; color: var(--brand-dark); cursor: pointer; }
.av-acts button.av-del { background: #fde8e8; color: #b91c1c; }
.av-acts button:disabled { opacity: .5; }
/* indicador do pull-to-refresh */
#ios-ptr {
  position: fixed; top: calc(env(safe-area-inset-top) + 52px); left: 0; right: 0; z-index: 80;
  display: flex; justify-content: center; pointer-events: none; transform: translateY(-46px);
}
#ios-ptr span {
  background: #fff; border: 0.5px solid var(--border); border-radius: 999px; padding: 6px 14px;
  box-shadow: 0 3px 12px rgba(0,30,50,.14); color: var(--brand-dark); font-size: 13px; font-weight: 700;
}

/* ---- Barra inferior (tab bar) ---- */
.ios-tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,0.9);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(0,0,0,0.12);
}
.ios-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 7px 2px 5px; min-height: 52px;
  background: none; border: 0; cursor: pointer; text-decoration: none;
  color: #97a3a3; font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
}
.ios-tab svg { width: 25px; height: 25px; }
.ios-tab.active { color: var(--brand); }

/* ---- Conteúdo ---- */
html.ios-app .container,
html.ios-app .container.wide,
html.ios-app .container.narrow { max-width: none !important; width: auto; padding: 0 16px; margin: 0; }

/* Títulos grandes estilo iOS */
html.ios-app .page-header { text-align: left !important; margin: 8px 0 14px; }
html.ios-app .page-header h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--navy); margin: 0; }
html.ios-app .page-header .subtitle { font-size: 14px; color: var(--muted); margin-top: 4px; max-width: none; }

/* Cards mais arredondados, sombra leve */
html.ios-app .card {
  border-radius: 18px; border: 0; box-shadow: 0 1px 3px rgba(0,30,50,0.06), 0 6px 16px rgba(0,30,50,0.05);
  padding: 16px 18px; margin-bottom: 14px;
}

/* Botões iOS: cheios, grandes, redondos */
html.ios-app .btn, html.ios-app button.btn {
  border-radius: 14px; min-height: 50px; font-size: 16px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .08s ease, opacity .15s ease;
}
html.ios-app .btn:active { transform: scale(0.97); opacity: 0.85; }
html.ios-app .btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(0,160,160,0.3); }

/* Campos iOS: altura confortável, cantos suaves, foco fino */
html.ios-app input:not([type=checkbox]):not([type=radio]):not([type=file]),
html.ios-app select, html.ios-app textarea {
  border-radius: 12px; min-height: 50px; font-size: 16px; /* 16px evita zoom no iOS */
  padding: 0 14px; border: 1px solid var(--border); background: #fff;
}
html.ios-app input:not([type=checkbox]):not([type=radio]):not([type=file]),
html.ios-app textarea { -webkit-appearance: none; appearance: none; }
html.ios-app textarea { padding: 12px 14px; min-height: 96px; }
/* select: mantém o seletor nativo do iOS (roda) mas com setinha custom */
html.ios-app select {
  -webkit-appearance: none; appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a7373' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 18px;
}
html.ios-app input:focus, html.ios-app select:focus, html.ios-app textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0,160,160,0.14);
}
html.ios-app label { font-size: 14px; }

/* Listas estilo iOS (grouped inset) — use .ios-list nos itens */
html.ios-app .ios-list { background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,30,50,0.06); }
html.ios-app .ios-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px;
  border-bottom: 0.5px solid var(--border); text-decoration: none; color: inherit;
}
html.ios-app .ios-row:last-child { border-bottom: 0; }
html.ios-app .ios-row:active { background: #f1f5f5; }
html.ios-app .ios-row .chev { margin-left: auto; color: #c0cccc; }

/* Modais viram "sheet" que sobe de baixo */
html.ios-app .modal-bg { align-items: flex-end !important; padding: 0 !important; }
html.ios-app .modal-bg .modal-card,
html.ios-app .modal-bg > div {
  width: 100% !important; max-width: 100% !important;
  border-radius: 20px 20px 0 0 !important; max-height: 92vh;
  padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  animation: iosSheetUp .28s cubic-bezier(.22,.61,.36,1);
}
@keyframes iosSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---- Tabelas SEM conversão: scroll horizontal suave (fallback de segurança) ---- */
html.ios-app table:not(.ios-cards) {
  display: block; width: 100%; max-width: 100%;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  -ms-overflow-style: none; scrollbar-width: thin;
}
/* sem nowrap: células quebram linha em vez de forçar scroll horizontal */

/* ---- Tabela → CARDS no celular (table.ios-cards). SEM scroll horizontal. ---- */
/* O auto-rotulador (app-shell.js) copia o cabeçalho pro data-label de cada célula. */
html.ios-app table.ios-cards,
html.ios-app table.ios-cards tbody,
html.ios-app table.ios-cards tr { display: block; }
html.ios-app table.ios-cards { width: 100%; min-width: 0 !important; border-collapse: separate; }
html.ios-app table.ios-cards thead { display: none; }            /* cabeçalho some; vira rótulo por célula */
html.ios-app table.ios-cards tr {
  background: #fff; border: 0; border-radius: 14px; padding: 4px 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,30,50,0.07), 0 4px 12px rgba(0,30,50,0.04);
}
html.ios-app table.ios-cards td {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 9px 0; border: 0; border-bottom: 0.5px solid var(--border);
  white-space: normal !important; text-align: right; min-width: 0; width: auto;
}
html.ios-app table.ios-cards tr td:last-child { border-bottom: 0; }
html.ios-app table.ios-cards td[data-label]::before {
  content: attr(data-label); flex: 0 0 38%; text-align: left;
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em; white-space: normal; line-height: 1.3;
}
html.ios-app table.ios-cards td:first-child { font-weight: 700; color: var(--navy); font-size: 15px; }
html.ios-app table.ios-cards td:empty { display: none; }         /* célula vazia some do card */

/* NOTA: cada página já tem suas próprias media queries pra grids/tabs/filtros.
   Por isso NÃO sobrepomos esses componentes aqui (evita brigar com o layout
   afinado de cada tela). Só ajustamos o que é universalmente seguro. */

/* ---- Toque iOS: sem hover "grudado" + feedback de pressionar nos cards ---- */
@media (hover: none) {
  html.ios-app .acao-card:hover, html.ios-app .quick-card:hover,
  html.ios-app .insc-row:hover, html.ios-app .qcard:hover,
  html.ios-app .botao-item:hover, html.ios-app .at-card:hover { transform: none !important; }
}
html.ios-app .acao-card:active, html.ios-app .quick-card:active,
html.ios-app .insc-row:active, html.ios-app .qcard:active,
html.ios-app .botao-item:active { transform: scale(0.98); transition: transform .1s ease; }

/* esconde elementos marcados como só-desktop dentro do app */
html.ios-app .desktop-only { display: none !important; }
