/*
 * Mobile-first companion (/m). Layout vertical, thumb-friendly, swipe
 * horizontal entre as 4 telas (status/activity/cost/spawn).
 *
 * Convenção: TODA cor/timing/radius vem de application.css (--neon-*,
 * --bg-*, --motion-*, --radius-*). Não inventar paleta aqui.
 *
 * Touch targets ≥ 44px (Apple HIG / WCAG). Inputs com font-size ≥ 16px
 * pra evitar zoom automático no iOS Safari.
 */

/* =========================================================
 * Reset/host
 * ========================================================= */

.mbody {
  background: var(--bg-deep, var(--color-bg));
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior-y: contain;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mbody * {
  -webkit-tap-highlight-color: transparent;
}

/* =========================================================
 * Header (sticky top)
 * ========================================================= */

.mheader {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky, 50);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-md);
  background: rgba(6, 6, 15, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  /* safe area iOS notch */
  padding-top: calc(var(--space-md) + env(safe-area-inset-top, 0px));
}

.mheader__brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: var(--color-text);
}

.mheader__brand-dot {
  color: var(--neon-cyan);
  margin: 0 4px;
}

.mheader__brand-suffix {
  color: var(--neon-purple);
  font-weight: 600;
}

.mheader__pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--color-border);
  --pulse-color: var(--neon-green);
}

.mheader__pill--live {
  color: var(--neon-green);
  border-color: rgba(0, 255, 157, 0.4);
  background: rgba(0, 255, 157, 0.08);
}

.mheader__pill--idle {
  color: var(--color-text-faded);
}

/* =========================================================
 * Main + bottom nav
 * ========================================================= */

.mmain {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* deixa espaço pra bottom nav fixa */
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
}

.mnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky, 50);
  display: flex;
  background: rgba(6, 6, 15, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  min-height: 60px;
}

.mnav__tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 4px;
  min-height: 56px;
  color: var(--color-text-faded);
  font-size: 0.7rem;
  transition: color var(--motion-fast, 180ms) ease;
}

.mnav__tab:active {
  background: var(--color-bg-hover);
}

.mnav__tab--active {
  color: var(--neon-cyan);
}

.mnav__icon {
  font-size: 1.4rem;
  line-height: 1;
}

.mnav__label {
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

/* =========================================================
 * Screen (1 tela = 1 swipe-page)
 * ========================================================= */

.mscreen {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-lg) var(--space-md);
  width: 100%;
  max-width: 100%;
  animation: bailder-fade-in var(--motion-base, 280ms) ease-out;
}

.mscreen__heading {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.mscreen__subhead {
  margin: var(--space-md) 0 var(--space-sm) 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.mscreen__hint {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* avatar pulsante (status screen) */
.mscreen__avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--space-md) auto var(--space-sm) auto;
  box-shadow: 0 8px 32px rgba(0, 229, 255, 0.25);
  --pulse-color: var(--neon-cyan);
}

.mscreen__avatar-mood {
  font-size: 2.4rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* big number block */
.mscreen__big {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.mscreen__big--secondary .mscreen__big-value {
  font-size: 2.2rem;
  color: var(--color-text-muted);
}

.mscreen__big-value {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.mscreen__big-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* alert (confirmações pendentes) */
.mscreen__alert {
  display: block;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 61, 92, 0.4);
  background: rgba(255, 61, 92, 0.08);
  color: var(--neon-red, var(--color-danger));
  font-weight: 600;
  text-align: center;
  min-height: 44px;
  --glow-color: var(--neon-red);
}

/* grid 2 colunas */
.mscreen__grid {
  display: grid;
  gap: var(--space-md);
}

.mscreen__grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.mscreen__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--space-md);
  background: var(--bg-elevated, var(--color-bg-elevated));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  min-height: 88px;
}

.mscreen__cell-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.mscreen__cell-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
}

.mscreen__cell-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* lista de workers vivos */
.mscreen__workers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.mscreen__worker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-md);
  background: var(--bg-elevated, var(--color-bg-elevated));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-height: 64px;
  color: inherit;
}

.mscreen__worker:active {
  border-color: var(--color-border-strong);
}

.mscreen__worker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.mscreen__worker-proj {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--neon-cyan);
  font-weight: 600;
}

.mscreen__worker-prompt {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* empty state */
.mscreen__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-md);
  color: var(--color-text-muted);
  text-align: center;
}

.mscreen__empty-icon {
  font-size: 2.4rem;
}

/* projeção do dia (cost) */
.mscreen__projection {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: rgba(180, 126, 255, 0.06);
  border: 1px solid rgba(180, 126, 255, 0.2);
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.mscreen__projection strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--neon-purple);
}

/* =========================================================
 * Activity feed
 * ========================================================= */

.mfeed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.mfeed__item {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated, var(--color-bg-elevated));
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-border-strong);
  min-height: 56px;
}

.mfeed__item--green  { border-left-color: var(--neon-green); }
.mfeed__item--yellow { border-left-color: var(--neon-amber); }
.mfeed__item--red    { border-left-color: var(--neon-red); }

.mfeed__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.mfeed__action {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text);
  font-weight: 600;
  word-break: break-word;
}

.mfeed__time {
  font-size: 0.75rem;
  color: var(--color-text-faded);
  flex-shrink: 0;
}

.mfeed__target {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  word-break: break-all;
}

/* lista compacta de workers (activity bottom) */
.mworker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mworker-list__item {
  background: var(--bg-elevated, var(--color-bg-elevated));
  border-radius: var(--radius-sm);
}

.mworker-list__link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  min-height: 44px;
  font-size: 0.9rem;
  color: var(--color-text);
}

.mworker-list__id {
  font-family: var(--font-mono);
  color: var(--color-text-faded);
  flex-shrink: 0;
}

.mworker-list__proj {
  flex: 1;
  font-family: var(--font-mono);
  color: var(--neon-cyan);
  font-size: 0.85rem;
}

/* =========================================================
 * Cost list
 * ========================================================= */

.mlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-elevated, var(--color-bg-elevated));
  border-radius: var(--radius-md);
  overflow: hidden;
}

.mlist__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  min-height: 44px;
  border-bottom: 1px solid var(--color-border);
}

.mlist__item:last-child {
  border-bottom: none;
}

.mlist__name {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  word-break: break-all;
}

.mlist__value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--neon-amber);
  flex-shrink: 0;
}

/* =========================================================
 * Form (spawn)
 * ========================================================= */

.mform {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.mform__label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mform__label-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mform__select,
.mform__textarea {
  width: 100%;
  padding: 12px var(--space-md);
  background: var(--bg-elevated, var(--color-bg-elevated));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: inherit;
  /* 16px+ obrigatório pra evitar zoom no iOS Safari */
  font-size: 16px;
  line-height: 1.4;
  min-height: 48px;
  transition: border-color var(--motion-fast, 180ms) ease;
}

.mform__textarea {
  min-height: 144px;
  resize: vertical;
  font-family: var(--font-mono);
}

.mform__select:focus,
.mform__textarea:focus {
  outline: none;
  border-color: var(--neon-cyan);
}

.mform__templates {
  background: var(--bg-elevated, var(--color-bg-elevated));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}

.mform__templates summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding: 8px 0;
  min-height: 32px;
  user-select: none;
}

.mform__templates-list {
  list-style: none;
  margin: var(--space-sm) 0 var(--space-xs) 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.mform__template-btn {
  width: 100%;
  text-align: left;
  padding: 10px var(--space-md);
  min-height: 44px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.9rem;
}

.mform__template-btn:active {
  border-color: var(--neon-cyan);
}

.mform__submit {
  width: 100%;
  padding: var(--space-md);
  min-height: 52px;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  border: none;
  border-radius: var(--radius-md);
  color: #06060f;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: var(--space-sm);
  box-shadow: 0 4px 20px rgba(0, 229, 255, 0.25);
  transition: transform var(--motion-fast, 180ms) ease;
}

.mform__submit:active {
  transform: scale(0.98);
}
