/* ========== MOBILE POLISH — Touch, Contrast, Typography (v1.5.68) ==========
 *
 * Consolidação de fixes mobile vindos de 5 reviews UI/UX:
 *   1. Touch targets ≥44×44 (refresh, period chips, tabs, calendar, modal close)
 *   2. <select> font-size 16px (evita zoom forçado iOS Safari)
 *   3. :active feedback states (substituem hover-only)
 *   4. Contrastes WCAG AA (qa-muted, pill-neutral, event-time, loading)
 *   5. Scorecards mobile: NÃO encolher value (manter ou subir)
 *   6. Calendar mobile fullwidth + 40px tap day
 *   7. Adjust scorecard auto-fit (sem órfãos)
 *   8. Tabs Quiz Analytics scroll-snap + fade + sticky
 *   9. Funnel mobile: label permite quebrar em 2 linhas (sem truncar)
 */

/* ====== 1. Selects: font 16px no mobile (anti-zoom iOS) ====== */
@media (max-width: 768px) {
  select,
  .qa-period-input,
  .qa-utm-select select,
  .qa-funnel-header select,
  .qa-period-input-mobile select {
    font-size: 16px !important;
    min-height: var(--tap-target);
    padding: 10px 14px;
  }
}

/* ====== 2. Touch targets ≥44×44 ====== */

/* Dashboard refresh button (era 36×36) */
.dash2-refresh-btn {
  min-width: var(--tap-target) !important;
  min-height: var(--tap-target) !important;
  padding: 10px;
  border-radius: 12px;
}

/* Dashboard period chips (era 28px alto) */
.dash2-period-btn {
  min-height: var(--tap-target);
  padding: 10px 16px;
  font-size: var(--font-base, 14px);
}
.dash2-period-selector {
  gap: 6px;
}

/* Quiz Analytics tabs (era 32px alto) */
.qa-tab {
  min-height: var(--tap-target);
  padding: 12px 18px;
  font-size: var(--font-base, 14px);
  display: inline-flex;
  align-items: center;
}

/* Mostrar mais buttons */
.dash2-btn-link,
.qa-btn-link {
  min-height: var(--tap-target);
  padding: 12px 16px;
}

/* Modal close (era 28px font sem padding) */
.qa-modal-close,
.modal-close {
  width: var(--tap-target) !important;
  height: var(--tap-target) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.qa-modal-close:active,
.modal-close:active {
  background: var(--bg);
}

/* Calendar nav buttons + days */
.qa-cal-nav-btn {
  width: 40px !important;
  height: 40px !important;
}
.qa-cal-day {
  min-height: 40px;
  padding: 10px 0 !important;
  font-size: var(--font-base, 14px);
}

/* Ad link (qa-ad-link) — tap-friendly */
.qa-ad-link {
  display: inline-block;
  padding: 6px 4px;
  min-height: 32px;
  line-height: 1.4;
}

/* ====== 3. :active feedback (mobile não tem hover) ====== */
.dash2-period-btn:active,
.qa-tab:active,
.dash2-refresh-btn:active,
.dash2-btn-link:active,
.qa-btn-link:active,
.qa-cal-day:active:not(.qa-cal-disabled):not(.qa-cal-future) {
  transform: scale(0.97);
  transition: transform 0.08s ease-out;
}
.dash2-period-btn:active,
.qa-tab:active {
  background: rgba(232, 80, 91, 0.12);
}

/* Focus visible (keyboard a11y) */
.dash2-period-btn:focus-visible,
.qa-tab:focus-visible,
.dash2-refresh-btn:focus-visible,
.dash2-btn-link:focus-visible,
.qa-btn-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ====== 4. Contrastes WCAG AA ====== */

/* qa-muted: era #94a3b8 sobre #f8fafc → 3.6:1 (REPROVA pra texto pequeno).
   #64748b → 5.7:1, AA aprovado. */
.qa-muted {
  color: #64748b !important;
}

/* dash2-pill-neutral: era #495057 sobre #e9ecef → 4.36:1 (borderline).
   #343a40 → 7.5:1 AAA. */
.dash2-pill-neutral {
  color: #343a40 !important;
}

/* dash2-loading: era #868e96 sobre #fff → 3.95:1 (REPROVA).
   #495057 → 8.8:1 AAA. */
.dash2-loading,
.dash2-empty {
  color: #495057 !important;
}

/* qa-event-time: pequeno (12px), precisa contraste alto.
   var(--text-muted)=#94a3b8 → reprova. var(--text-secondary)=#64748b → aprova. */
.qa-event-time {
  color: var(--text-secondary) !important;
}

/* dash2-chart-axis: SVG axis labels em 10px — escurecer. */
.dash2-chart-axis {
  fill: #495057;
}

/* ====== 5. Scorecards mobile: hero number GRANDE, não encolher ====== */
@media (max-width: 768px) {
  /* Era 18-20px no mobile (anti-padrão — hero number deve ser maior pra ler de longe) */
  .dash2-sc-value {
    font-size: clamp(22px, 6vw, 28px) !important;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
  }
  .qa-card-value {
    font-size: clamp(22px, 6vw, 32px) !important;
    line-height: 1.15;
  }
}

/* ====== 6. Calendar mobile fullwidth ====== */
@media (max-width: 480px) {
  .qa-period-menu.open {
    min-width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    left: 12px;
    right: auto;
  }
  .qa-period-calendar {
    padding: 12px;
    min-width: 0;
  }
  .qa-cal-grid {
    gap: 4px;
  }
}

/* ====== 7. Adjust scorecard auto-fit ====== */
.dash2-adjust-scorecard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

/* ====== 8. Tabs Quiz Analytics: scroll-snap + fade + sticky ====== */
@media (max-width: 768px) {
  .qa-toolbar {
    /* Mantém visível ao rolar a tabela longa */
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--bg);
    margin-left: -16px;
    margin-right: -16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  .qa-tabs {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Fade nas pontas indica overflow */
    mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
    padding: 4px 8px;
  }
  .qa-tabs::-webkit-scrollbar {
    display: none;
  }
  .qa-tab {
    flex-shrink: 0;
    scroll-snap-align: start;
  }
}

/* ====== 9. Funnel mobile: label quebra em 2 linhas ====== */
@media (max-width: 600px) {
  .qa-funnel-row {
    grid-template-columns: 1fr 80px 50px;
    gap: 8px;
    padding: 8px 0;
  }
  .qa-funnel-label {
    white-space: normal;
    overflow: visible;
    line-height: 1.25;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    font-size: var(--font-sm, 12px);
  }
  .qa-funnel {
    padding: 14px;
  }
}

/* ====== 10. Status pills mobile compactas ====== */
@media (max-width: 480px) {
  .dash2-purchase-status-row {
    gap: 4px;
  }
  .dash2-pill {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* ====== 11. Main content padding mobile (respira nas bordas) ====== */
@media (max-width: 480px) {
  .main-content {
    padding: 16px 12px !important; /* era 12px 8px (claustrofóbico) */
  }
}

/* ====== 12. Reduced motion: respeitar preferência do user ====== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ====== 13. Card values: tabular numbers (alinhamento de colunas) ====== */
.dash2-sc-value,
.qa-card-value,
.dash2-pill strong {
  font-variant-numeric: tabular-nums;
}

/* ====== 14. Cards Hotmart scorecards stack 1 col em mobile small ====== */
@media (max-width: 480px) {
  .dash2-purchase-scorecard {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
}

/* ====== 15. Sub-titulos de tabela: respiro mobile ====== */
@media (max-width: 768px) {
  .dash2-sub-title {
    font-size: var(--font-md, 15px);
    margin: 18px 0 10px;
  }
}

/* ====== 16. Top 10 Campanhas: rank badge ====== */
.dash2-rank {
  display: inline-block;
  background: var(--primary-light, #FFF0F1);
  color: var(--primary, #E8505B);
  font-weight: 700;
  font-size: 0.85em;
  padding: 1px 7px;
  border-radius: 6px;
  margin-right: 6px;
  letter-spacing: -0.01em;
}

/* ====== 17. Mobile card mode polish: 1ª cell mais legível ======
 * No mobile o card-stack faz a 1ª cell virar título do card. Garante que
 * spans/strong dentro dela tenham hierarquia visual clara, sem empilhar
 * tudo grudado. */
@media (max-width: 767px) {
  .dash2-table tr td:first-child,
  .qa-table tr td:first-child {
    line-height: 1.4;
    font-size: 15px;
  }
  /* Quando a 1ª cell tem badge de rank + nome, espaça */
  .dash2-table tr td:first-child .dash2-rank {
    vertical-align: middle;
  }
  /* Ações (botões "Ver funil →" etc) com tap target full-width,
   * fora do grid label/valor (ocupam linha inteira). */
  .qa-table tr td[data-label=""] {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border-light, #f1f5f9);
    padding-top: 8px;
    margin-top: 4px;
  }
  .qa-table tr td[data-label=""]::before {
    display: none;
  }
}

/* ====== 18. Forçar QA muted e variantes visíveis no card stack ====== */
@media (max-width: 767px) {
  .dash2-table td .qa-muted,
  .qa-table td .qa-muted {
    font-size: 11px;
    margin-left: 4px;
  }
}
