/* Modo_Celular — componentes (tarefa 6.3; Requisitos 16.3, 16.5, 16.6, 16.8).
   Carregado depois de mobile.css. Tudo escopado em html.mobile: o desktop não muda.
   Só usa as variáveis de cor de style.css (temas claro e noturno) e as --m-* de mobile.css.
   Seções: 1 alvos de toque | 2 formulários | 3 calendário em lista | 4 tabelas em cartões |
           5 cartões/painéis/barras | 6 disponibilidade, trocas e escala | 7 janela Gerar imagem. */

/* ---------- 1. Alvos de toque de pelo menos 44 px ---------- */
html.mobile button,
html.mobile .primary,
html.mobile .secondary,
html.mobile .danger-button,
html.mobile .icon-button,
html.mobile .link,
html.mobile .toolbar input,
html.mobile .toolbar select,
html.mobile .field input:not([type=checkbox]):not([type=radio]),
html.mobile .field select,
html.mobile .login-card input:not([type=checkbox]):not([type=radio]) { min-height: var(--m-toque); }
html.mobile .primary,
html.mobile .secondary,
html.mobile .danger-button,
html.mobile .icon-button { min-width: var(--m-toque); padding-top: 8px; padding-bottom: 8px; }
html.mobile .link { display: inline-flex; align-items: center; justify-content: center; min-width: var(--m-toque); }
html.mobile .field textarea { min-height: 96px; }
html.mobile nav button,
html.mobile .sidebar nav button { min-height: var(--m-toque); font-size: 14px; }
html.mobile .actions-row button { font-size: 13px; padding: 8px 12px; }
html.mobile .badge { font-size: 11px; }
/* Caixas e botões de opção: a linha inteira é o alvo */
html.mobile .field > span:has(> input[type=checkbox]),
html.mobile fieldset.field > label,
html.mobile .role-choice,
html.mobile .availability .date-check,
html.mobile label.check-line { min-height: var(--m-toque); align-items: center; }
html.mobile .field > span:has(> input[type=checkbox]) { display: flex; gap: 10px; padding: 4px 0; }
html.mobile .field input[type=checkbox],
html.mobile .field input[type=radio],
html.mobile .role-choice input,
html.mobile .availability .date-check input { width: 22px; height: 22px; flex: none; }
html.mobile fieldset.field > label { gap: 12px; }
html.mobile .role-choice { font-size: 13px; padding: 8px 10px; gap: 10px; }
html.mobile .role-picker { grid-template-columns: minmax(0, 1fr); max-height: 50vh; }
html.mobile .field-order-actions button { width: var(--m-toque); height: var(--m-toque); }
html.mobile .order-row { min-height: var(--m-toque); }
html.mobile .badge,
html.mobile .nav-badge { min-height: 0; }

/* ---------- 2. Formulários em uma coluna ---------- */
html.mobile .form-grid,
html.mobile .stats { grid-template-columns: minmax(0, 1fr); }
html.mobile .field { margin: 10px 0; font-size: 13px; }
html.mobile .field input,
html.mobile .field select,
html.mobile .field textarea { min-width: 0; max-width: 100%; }
html.mobile .cal-regra,
html.mobile .cal-diasem { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
html.mobile .cal-regra .field,
html.mobile .cal-diasem .field { width: 100%; }
html.mobile .toolbar { gap: 8px; }
html.mobile .toolbar > * { flex: 1 1 100%; min-width: 0; }
html.mobile .toolbar > strong { flex: 1 1 auto; text-align: center; }
html.mobile .toolbar > .icon-button { flex: 0 0 var(--m-toque); }
html.mobile .toolbar input,
html.mobile .toolbar select { width: 100%; }
html.mobile .heading { gap: 10px; }
html.mobile .heading h1 { font-size: 21px; overflow-wrap: anywhere; }
html.mobile .heading .actions,
html.mobile .actions { width: 100%; }
html.mobile .actions > button { flex: 1 1 140px; }
html.mobile .dialog-actions { flex-direction: column-reverse; align-items: stretch; }
html.mobile .dialog-actions > button { width: 100%; flex: 0 0 auto; }
html.mobile dialog .dialog-actions { flex-wrap: nowrap; }
html.mobile dialog .dialog-actions > button { flex: 0 0 auto; }
html.mobile .actions-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; width: 100%; }
html.mobile .actions-row > button { width: 100%; }
html.mobile .notice { overflow-wrap: anywhere; }
html.mobile .toast { max-width: calc(100vw - 24px); bottom: max(22px, env(safe-area-inset-bottom)); text-align: center; }

/* ---------- 3. Calendário em lista ---------- */
/* adm-calendario.js já alterna .cal-lista / .cal-grade; aqui só o acabamento da lista. */
html.mobile .cal-lista { display: grid; gap: 8px; margin: 0 0 18px; }
html.mobile .cal-grade { display: none; }
html.mobile .cal-lista > .card {
  display: block; width: 100%; min-height: var(--m-toque); text-align: left; font: inherit; color: var(--ink);
  padding: 12px var(--m-pad); cursor: pointer; overflow-wrap: anywhere;
}
html.mobile .cal-lista > .card.selected { border-color: var(--brand); background: var(--brand-soft); }
html.mobile .cal-lista .cal-chip { white-space: normal; font-size: 13px; line-height: 1.4; margin-top: 4px; color: var(--muted); }
html.mobile .cal-lista .empty { margin: 0; }
html.mobile .calendar-toolbar { gap: 8px; flex-wrap: wrap; }
html.mobile .calendar-toolbar > strong { flex: 1 1 auto; text-align: center; min-width: 0; }
html.mobile .calendar-toolbar button { min-width: var(--m-toque); }
/* Calendário em grade do portal do usuário (portal.js): fica compacto e cada dia mantém 44 px */
html.mobile .calendar-grid:not(.cal-grade) { gap: 3px; }
html.mobile .calendar-grid:not(.cal-grade) .calendar-day { min-height: var(--m-toque); padding: 4px 2px; align-items: center; }
html.mobile .calendar-grid:not(.cal-grade) .calendar-day strong { font-size: 14px; }
html.mobile .calendar-grid:not(.cal-grade) .calendar-day small { font-size: 9px; margin-top: 2px; }
html.mobile .calendar-grid:not(.cal-grade) .calendar-weekday { font-size: 10px; padding: 3px 0; overflow: hidden; }
html.mobile .month-label { min-width: 0; }
/* Detalhes do dia */
html.mobile .day-details .panel-head,
html.mobile .card-head { flex-wrap: wrap; align-items: flex-start; }
html.mobile .day-details .panel-head > button { width: 100%; }
html.mobile .mass-detail { overflow-wrap: anywhere; }

/* ---------- 4. Tabelas em cartões ---------- */
html.mobile .table-wrap { overflow: visible; max-width: 100%; }
html.mobile .table-wrap.panel { padding: 0; background: transparent; border: 0; box-shadow: none; }
html.mobile table.table,
html.mobile table.data-table { display: block; width: 100%; border: 0; }
html.mobile table.table > thead,
html.mobile table.data-table > thead {
  /* cabeçalhos viram rótulos de cada célula; a linha de títulos some só visualmente */
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
html.mobile table.table > tbody,
html.mobile table.data-table > tbody { display: grid; gap: 10px; }
html.mobile table.table tr,
html.mobile table.data-table tr {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 12px var(--m-pad);
}
html.mobile table.table td,
html.mobile table.data-table td {
  display: block; min-width: 0; padding: 4px 0; border: 0; white-space: normal !important; overflow-wrap: anywhere; font-size: 14px; text-align: left;
}
html.mobile table.table td:empty,
html.mobile table.data-table td:empty { display: none; }
/* Linha de aviso ("Nenhuma data neste ano.") ocupa o cartão inteiro */
html.mobile table.table td[colspan],
html.mobile table.data-table td[colspan] { color: var(--muted); text-align: center; padding: 14px 0; }
/* Datas comemorativas: data em destaque, tipo em tom discreto e ações no rodapé do cartão */
html.mobile table.data-table td:nth-child(1) { font-weight: 700; color: var(--brand); font-size: 13px; }
html.mobile table.data-table td:nth-child(2) { font-size: 15px; font-weight: 600; }
html.mobile table.data-table td:nth-child(3) { color: var(--muted); font-size: 13px; }
html.mobile table.data-table td:nth-child(4) { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
html.mobile table.data-table td:nth-child(4) .actions { display: flex; gap: 8px; flex-wrap: wrap; }
html.mobile table.data-table td:nth-child(4) .actions > button { flex: 1 1 120px; }
/* Cartões de Funções/Anotações: título ocupa o espaço e as ações ficam do lado, sem largura total */
html.mobile .card-top .actions { width: auto; flex: none; flex-wrap: nowrap; }
html.mobile .card-top > h2, html.mobile .role-heading { flex: 1 1 0; min-width: 0; }
/* Botões só com ícone mantêm a área de toque mínima */
html.mobile #content .icon-button { width: var(--m-toque, 44px); min-width: var(--m-toque, 44px); height: var(--m-toque, 44px); }
/* Cabeçalho de mês (tr.mes): vira um título entre os cartões, não um cartão */
html.mobile table.data-table tr.mes { display: block; background: transparent; border: 0; border-radius: 0; box-shadow: none; padding: 8px 2px 0; }
html.mobile table.data-table tr.mes th { display: block; padding: 0 0 6px; background: transparent; border: 0; border-bottom: 2px solid var(--brand); color: var(--brand); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; text-align: left; }
/* Tabelas genéricas (.table): célula com ações vira rodapé em grade */
html.mobile table.table td .actions-row { margin-top: 4px; }
html.mobile table.table .person { min-width: 0; }
html.mobile table.table .person > div { min-width: 0; overflow-wrap: anywhere; }

/* ---------- 5. Cartões, painéis e barras ---------- */
html.mobile .grid { grid-template-columns: minmax(0, 1fr); }
html.mobile .panel { padding: var(--m-pad); }
html.mobile .card { padding: var(--m-pad); overflow-wrap: anywhere; }
html.mobile .card p,
html.mobile .panel p { overflow-wrap: anywhere; }
html.mobile .panel-head { flex-wrap: wrap; align-items: flex-start; }
html.mobile .panel-head > button { flex: 0 0 auto; }
html.mobile .event-row { gap: 8px; padding: 10px 0; }
html.mobile .event-row > button,
html.mobile .event-row > .badge { margin-left: 0; }
html.mobile .event-row > button { flex: 1 1 100%; }
html.mobile .role-assignment { font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
html.mobile .person { min-width: 0; }
html.mobile .stat strong { font-size: 22px; }
html.mobile .top-actions #user-label { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.mobile .eyebrow,
html.mobile .top-sub { overflow: hidden; text-overflow: ellipsis; max-width: 55vw; white-space: nowrap; }
html.mobile .muted-small { font-size: 12px; }

/* ---------- 6. Disponibilidade, trocas e montagem de escala ---------- */
html.mobile .availability,
html.mobile .availability-months .availability { grid-template-columns: minmax(0, 1fr); max-height: none; overflow: visible; }
html.mobile .availability-months { max-height: none; overflow: visible; }
html.mobile .availability .date-check { white-space: normal; font-size: 14px; padding: 8px 12px; gap: 12px; }
html.mobile .availability-month h3 { font-size: 14px; }
html.mobile .swap-preview { flex-direction: column; align-items: stretch; gap: 8px; }
html.mobile .swap-arrows { text-align: center; transform: rotate(90deg); align-self: center; }
html.mobile .roster-symbols { min-width: 0; }
html.mobile select[multiple] { min-height: 140px; }

/* ---------- 7. Janela Gerar imagem (#editor-dialog) e demais janelas com imagem ---------- */
html.mobile #editor-dialog img,
html.mobile #editor-dialog canvas,
html.mobile #editor-dialog svg,
html.mobile dialog .dialog-body img,
html.mobile dialog .dialog-body canvas { max-width: 100%; height: auto; }
html.mobile #editor-dialog .dialog-body { overflow-x: hidden; }
html.mobile #editor-dialog .form-grid,
html.mobile #editor-dialog .actions-row,
html.mobile #editor-dialog .toolbar { grid-template-columns: minmax(0, 1fr); }
html.mobile #editor-dialog .toolbar { flex-direction: column; align-items: stretch; }
html.mobile #editor-dialog button { min-height: var(--m-toque); }
html.mobile #editor-dialog .dialog-actions { flex-direction: column-reverse; }
html.mobile #editor-dialog .dialog-actions > button { width: 100%; }
html.mobile dialog pre,
html.mobile dialog code { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 8. Ajustes medidos em 320–430 px (Edge, portal local com dados fictícios) ---------- */
/* "Opções avançadas" (adm-calendario.js) e demais <details>: a linha do resumo é o alvo */
html.mobile details > summary { display: flex; align-items: center; gap: 8px; min-height: var(--m-toque); }
/* Rótulos simples dentro de .form-grid (exportar.js no Gerar imagem não usa .field): campo em linha própria, largura total */
html.mobile .form-grid > label:not(.field):not(.check-label) { display: grid; gap: 6px; min-width: 0; font-size: 13px; }
html.mobile .form-grid > label:not(.check-label) > input:not([type=checkbox]):not([type=radio]),
html.mobile .form-grid > label:not(.check-label) > select,
html.mobile dialog label > input:not([type=checkbox]):not([type=radio]),
html.mobile dialog label > select { width: 100%; min-height: var(--m-toque); min-width: 0; box-sizing: border-box; }
/* Caixas de marcação com .check-label (Datas "Repetir todos os anos", Gerar imagem "Incluir anotações") */
html.mobile label.check-label { display: flex; align-items: center; gap: 12px; min-height: var(--m-toque); padding: 4px 0; }
html.mobile label.check-label > input[type=checkbox],
html.mobile label.check-label > input[type=radio] { width: 22px; height: 22px; flex: none; margin: 0; }
/* Link WhatsApp nos cartões de Acólitos (adm-acolitos.js): alvo de 44 px sem quebrar o texto do telefone */
html.mobile .card p > a[href] { display: inline-flex; align-items: center; min-height: var(--m-toque); padding: 0 10px; margin-left: 4px; }
