/**
 * LifeOS — Sub-abas no mobile
 * ===========================
 * Em telas de celular a barra horizontal de sub-abas deixa de existir:
 * vira uma linha única (sub-aba ativa + seta) que, ao tocar, abre a grade
 * completa de sub-abas SOBRE o conteúdo.
 *
 * Desktop / Electron: nada muda — a barra original continua como sempre foi.
 *
 * Como funciona:
 *  - js/subtabs-mobile.js adiciona a classe .lifeos-subtabs-mobile no <html>
 *    quando detecta celular; este CSS só age sob essa classe.
 *  - A barra original é recolhida (height:0 + overflow:hidden) e não é
 *    display:none, para que o JS ainda consiga medir quais abas estão
 *    visíveis (plano, bio-desktop-only etc.).
 */

/* ── Seletor (padrão escondido; só aparece no mobile) ───────────────────── */
.stm-bar {
  display: none;
}

html.lifeos-subtabs-mobile .stm-bar {
  display: block;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: relative;
  z-index: 21;
}

html.lifeos-subtabs-mobile .stm-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 16px;
  margin: 0;
  border: 0;
  background: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: #0064C8;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

html.lifeos-subtabs-mobile .stm-trigger:active {
  background: #f4f8ff;
}

.stm-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.stm-count {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  color: #8a939e;
}

.stm-chev {
  flex: 0 0 auto;
  font-size: 10px;
  color: #8a939e;
  transition: transform .2s ease;
}

.stm-bar.is-open .stm-chev {
  transform: rotate(180deg);
}

/* ── Barra original recolhida no mobile ─────────────────────────────────── */
html.lifeos-subtabs-mobile .sub-tabs-header,
html.lifeos-subtabs-mobile .fin-subtabs-bar {
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Modos de tela cheia das páginas: o seletor some junto com a barra original */
body.frame-cheio-ativo .stm-bar,
body.metodos-fs .stm-bar {
  display: none !important;
}

/* ── Overlay com a grade de sub-abas ────────────────────────────────────── */
.stm-overlay {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100500;
  display: none;
  /* Cor padrão; cada módulo sobrescreve (mesma paleta do Mapa do Evolution Life) */
  --stm-acc: #64748b;
  --stm-acc-soft: #f1f5f9;
  --stm-acc-strong: #334155;
}

.stm-overlay[data-stm-mod="saude"] {
  --stm-acc: #0ea5e9;
  --stm-acc-soft: #e0f2fe;
  --stm-acc-strong: #0369a1;
}

.stm-overlay[data-stm-mod="financeiro"] {
  --stm-acc: #10b981;
  --stm-acc-soft: #d1fae5;
  --stm-acc-strong: #047857;
}

.stm-overlay[data-stm-mod="produtividade"] {
  --stm-acc: #f59e0b;
  --stm-acc-soft: #fef3c7;
  --stm-acc-strong: #b45309;
}

.stm-overlay[data-stm-mod="recursos"] {
  --stm-acc: #8b5cf6;
  --stm-acc-soft: #ede9fe;
  --stm-acc-strong: #6d28d9;
}

.stm-overlay.is-open {
  display: block;
  animation: stmFade .16s ease;
}

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

.stm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .34);
  overscroll-behavior: contain;
}

.stm-sheet {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 6px;
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 14px);
  padding: 12px 10px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, .26), 0 2px 6px rgba(15, 23, 42, .12);
  transform-origin: top center;
  animation: stmDrop .2s cubic-bezier(.2, .9, .3, 1);
  font-family: inherit;
}

@keyframes stmDrop {
  from { opacity: 0; transform: translateY(-10px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.stm-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 10px;
  flex: 0 0 auto;
}

.stm-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -.1px;
  color: #0f172a;
}

.stm-head-em {
  flex: 0 0 auto;
  font-size: 17px;
  line-height: 1;
}

.stm-head-nome {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stm-badge {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--stm-acc-soft, #f1f5f9);
  color: var(--stm-acc-strong, #475569);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.stm-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Grade no estilo "Mapa do Evolution Life": 3 colunas de quadradinhos,
   um pouco menores que os do mapa (max-width 300px). */
.stm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  padding: 2px 2px 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.stm-item {
  position: relative;
  aspect-ratio: 1 / 1;
  max-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 5px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--stm-acc-soft, #f1f5f9);
  font-family: inherit;
  color: #1e293b;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  transition: border-color .12s ease, box-shadow .12s ease, transform .08s ease;
  -webkit-tap-highlight-color: transparent;
}

.stm-item:active {
  transform: scale(.97);
}

.stm-item.is-active {
  border-color: var(--stm-acc, #64748b);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .10);
  color: var(--stm-acc-strong, #334155);
}

.stm-em {
  flex: 0 0 auto;
  font-size: 24px;
  line-height: 1;
}.stm-txt {
  min-width: 0;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
}

.stm-item.is-active .stm-txt {
  font-weight: 800;
}

.stm-actions {
  display: flex;
  gap: 6px;
  padding: 8px 4px 0;
  flex: 0 0 auto;
}

.stm-actions:empty {
  display: none;
}

.stm-extra {
  flex: 1;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}

/* Telas bem estreitas: quadradinhos um pouco menores, mas sempre 3 por linha */
@media (max-width: 340px) {
  .stm-grid {
    gap: 6px;
  }

  .stm-item {
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
  }

  .stm-em {
    font-size: 21px;
  }

  .stm-txt {
    font-size: 10px;
  }
}

/* ── Pendência ("!") na sub-aba e no seletor ──────────────────────────── */
.stm-pend-dot {
  flex: 0 0 auto;
  margin-left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #F5B301;
  color: #3D2C00;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}

.stm-badge-pend {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #F5B301;
  color: #3D2C00;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  pointer-events: none;
}
