/* ═══════════════════════════════════════════════════════════════
   BASE — box-sizing + sem overflow horizontal global
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

#ranking-lista { overflow: visible; }

/* ─── Tela de login: cobre a tela sem position:fixed (iOS PWA keyboard fix) ─ */
#tela-login {
  position: absolute !important;
  inset: 0 !important;
  z-index: 9999 !important;
  min-height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── Touch: remove delay de 300ms em botões e inputs ─ */
button, input, select, textarea, a, label {
  touch-action: manipulation;
}


/* ─── Previne zoom em inputs no iOS (font-size < 16px dispara zoom) ─── */
@media (max-width: 767px) {
  input, select, textarea, [contenteditable] {
    font-size: 16px !important;
  }
}

/* ─── Scrollbar ─────────────────────────────────────── */
.custom-scroll::-webkit-scrollbar        { width: 5px; }
.custom-scroll::-webkit-scrollbar-track  { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb  { background: #334155; border-radius: 4px; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ─── Nav links ─────────────────────────────────────── */
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  user-select: none;
}
.nav-link:hover           { background: rgba(51,65,85,.55); color: #e2e8f0; }
.nav-link.active-nav      { background: rgba(99,102,241,.18); color: #a5b4fc; }
.nav-link.active-nav svg  { color: #a5b4fc; }

/* ─── Page visibility ───────────────────────────────── */
.page          { display: block; }
.page.hidden   { display: none !important; }

/* ─── Progress bar fill animation ──────────────────── */
@keyframes fill {
  from { width: 0%; }
  to   { width: var(--w); }
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  animation: fill .75s cubic-bezier(.4,0,.2,1) forwards;
}

/* ─── Table row hover ───────────────────────────────── */
.tr-row { transition: background 100ms ease; }
.tr-row:hover { background: rgba(51,65,85,.3); }

/* ─── Card hover ────────────────────────────────────── */
.op-card { transition: border-color 150ms ease, transform 150ms ease; }
.op-card:hover { border-color: rgba(99,102,241,.45); transform: translateY(-1px); }

/* ─── Modal ──────────────────────────────────────────  */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none !important; }

.modal-box {
  background: #131c2e;
  border: 1px solid #1e3050;
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 460px;
  margin: 16px;
}

/* ─── Botão lápis nos cards ──────────────────────────  */
.btn-icon-edit {
  background: none;
  border: none;
  color: #2a3a50;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 120ms ease, color 120ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon-edit:hover { background: #1e3050; color: #94a3b8; }

/* ─── Form ───────────────────────────────────────────  */
.form-group  { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label  { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: #475569; }
.form-input  {
  background: #0d1117;
  border: 1px solid #1e3050;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: #f1f5f9;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 120ms ease;
}
.form-input:focus  { border-color: #3b5998; }
.form-input option { background: #131c2e; }

.btn-primary {
  flex: 1;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
}
.btn-primary:hover { background: #4338ca; }

.btn-secondary {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #1e3050;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
}
.btn-secondary:hover { background: #273548; }

/* ─── Card de ciclo ──────────────────────────────────  */
.ciclo-card {
  background: #131c2e;
  border: 1px solid #1e3050;
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: border-color 150ms ease;
  flex-wrap: wrap;        /* garante wrap em telas pequenas */
}
.ciclo-card:hover { border-color: #2a4a7a; }

/* ─── Tabs de período do ranking ─────────────────────  */
.ranking-tab {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  min-height: 44px;       /* área de toque mínima */
  display: inline-flex;
  align-items: center;
}
.ranking-tab:hover    { color: #94a3b8; }
.ranking-tab.active-tab {
  background: #1e3050;
  color: #f1f5f9;
}

/* ─── Seções do dashboard ────────────────────────────  */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.section-header span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #64748b;
}
.section-divider {
  border: none;
  border-top: 1px solid #1e3050;
  margin: 4px 0;
}

/* ─── Cards estilo financeiro ───────────────────────── */
.stat-card-dark {
  background: #131c2e;
  border: 1px solid #1e3050;
  border-radius: 12px;
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  min-width: 0;           /* evita que flex/grid item transborde */
}
.stat-card-dark:hover {
  border-color: #2a4a7a;
  box-shadow: 0 0 0 1px #1e3050;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #64748b;
}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -.02em;
  margin-top: 4px;
  word-break: break-all;  /* impede valores longos de transbordar */
}
.stat-sub {
  font-size: 11px;
  color: #475569;
  margin-top: 5px;
}
.stat-bar-track {
  height: 4px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
  margin-bottom: 2px;
}

/* ─── Mobile sidebar drawer ─────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 149;
  backdrop-filter: blur(2px);
}

#hamburger { display: none; }


/* ═══════════════════════════════════════════════════════════════
   TABLET  768px – 1023px
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Sidebar um pouco mais estreita */
  #app-sidebar { min-width: 180px !important; max-width: 200px !important; }

  /* Grid de 4 colunas → 2 */
  #mod-resumo,
  [style*="repeat(4,"],
  [style*="repeat(4, 1fr)"] { grid-template-columns: 1fr 1fr !important; }

  /* Cards de operadores wrap em 2 */
  [style*="minmax(200px"] { grid-template-columns: repeat(2, 1fr) !important; }

  /* Tabela de ciclos no modal scroll horizontal */
  #mod-ciclos-wrap { overflow-x: auto !important; }
  #mod-ciclos-wrap table { min-width: 520px; }

  /* Breakdown panel menor em tablets */
  #breakdown-panel { width: 360px !important; }
}


/* ═══════════════════════════════════════════════════════════════
   MOBILE  ≤ 767px  (regras principais)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* ── Layout raiz ── */
  #app-main {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  /* Container de scroll vertical não gera scroll horizontal */
  #app-main > main { overflow-x: hidden !important; }

  /* ── Sidebar drawer ── */
  #app-sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(.4,0,.2,1);
    width: 240px !important;
  }
  body.sidebar-open #app-sidebar  { transform: translateX(0); }
  body.sidebar-open #sidebar-overlay { display: block; }

  #hamburger { display: flex !important; }

  /* ── Topbar: fit em tela pequena SEM overflow:hidden (quebraria dropdown) ── */
  #app-topbar {
    padding-left: 12px !important;
    padding-right: 12px !important;
    gap: 8px !important;
  }
  /* Esquerda pode encolher, direita não empurra pra fora */
  #app-topbar > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;        /* clips title text only, não afeta dropdown */
  }
  #app-topbar > div:last-child {
    flex: 0 0 auto;
    gap: 6px !important;
  }
  /* Esconde bell de notificação para liberar espaço na topbar */
  #app-topbar .relative.p-2 { display: none !important; }
  /* Esconde data e separador */
  #current-date, #app-topbar .h-4 { display: none !important; }
  /* Botão Pagar Salários — só ícone no mobile */
  #btn-pagamento span { display: none; }
  #btn-pagamento { padding: 7px 10px !important; gap: 0 !important; }

  /* ── Páginas: padding menor ── */
  .page.p-6 { padding: 12px !important; }
  .page .space-y-6 > * + * { margin-top: 14px !important; }
  .page .space-y-5 > * + * { margin-top: 12px !important; }

  /* ── Todos os grids Tailwind fixos → 1 ou 2 colunas ── */
  .mobile-1col { grid-template-columns: 1fr !important; }
  .mobile-2col { grid-template-columns: 1fr 1fr !important; }

  /* Meu Dashboard: grids de 3 → 2 colunas */
  #mdb-grid-top,
  #mdb-grid-bot { grid-template-columns: 1fr 1fr !important; }

  /* Grids inline de 4 colunas (relatórios/operadores) → 2 colunas */
  #mod-resumo,
  [style*="repeat(4,"],
  [style*="repeat(4, 1fr)"] { grid-template-columns: 1fr 1fr !important; }

  /* Cards de operadores (minmax 200px) → 1 coluna */
  [style*="minmax(200px"] { grid-template-columns: 1fr !important; }

  /* Grid de dia no relatório (120px 1fr …) → 1 coluna */
  [style*="120px 1fr"] { grid-template-columns: 1fr !important; }

  /* ── Tabelas: scroll horizontal dentro do container ── */
  .mobile-scroll          { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  #mod-ciclos-wrap        { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  #mod-ciclos-wrap table  { min-width: 520px; }

  /* ── Modais: bottom sheet no mobile ── */
  .modal-overlay { align-items: flex-end !important; }
  .modal-box {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 20px !important;
    border-radius: 14px 14px 0 0 !important;
    max-height: 90vh;
    overflow-y: auto;
  }
  /* Grids dentro de modal → 1 coluna */
  .modal-box [style*="grid-template-columns"],
  .modal-box [style*="repeat("],
  .modal-box > div[style*="grid"] { grid-template-columns: 1fr !important; }

  /* ── Stats ── */
  .stat-value { font-size: 18px !important; }
  .stat-sub   { display: none !important; }

  /* ── Banca info bar ── */
  #op-banca-info {
    padding: 10px 14px !important;
    gap: 12px !important;
    flex-wrap: wrap !important;
  }
  #op-banca-info p.stat-value { font-size: 14px !important; }
  #op-banca-info .stat-label  { font-size: 10px !important; }

  /* ── Card "não iniciado" (Operação) ── */
  #op-not-started > div {
    padding: 24px 20px !important;
    max-width: 100% !important;
  }

  /* ── Operação: header de ações empilha quando necessário ── */
  #page-operacao > div:first-child {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  #page-operacao > div:first-child > div:last-child {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  /* Badges de status sem nowrap no mobile */
  #op-dia-finalizado-badge,
  #btn-retomar-dia,
  #btn-finalizar-dia { white-space: normal !important; font-size: 11px !important; padding: 6px 10px !important; }

  /* ── Ciclo card ── */
  .ciclo-card {
    gap: 10px !important;
    padding: 12px 14px !important;
  }

  /* ── Ranking: tabs ── */
  .tr-row td { padding: 8px 10px !important; font-size: 12px !important; }
  .ranking-tab { padding: 6px 10px !important; font-size: 11px !important; min-height: 44px; }

  /* Pódio: 3 colunas compactas */
  #ranking-podio { grid-template-columns: 1fr 1fr 1fr !important; gap: 8px !important; }
  #ranking-podio > div { padding: 12px 6px !important; }
  #ranking-podio p     { font-size: 10px !important; }

  /* ── Configurações ── */
  #page-configuracoes > div { max-width: 100% !important; }

  /* ── Breakdown panel: 100% da tela no mobile ── */
  #breakdown-panel {
    width: 100% !important;
    border-left: none !important;
    border-top: 1px solid #1e3050 !important;
  }
}


/* ═══════════════════════════════════════════════════════════════
   MOBILE PEQUENO  ≤ 480px
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .page.p-6 { padding: 10px !important; }

  /* Meu Dashboard 2 colunas → 1 coluna em telas muito pequenas */
  #mdb-grid-top,
  #mdb-grid-bot { grid-template-columns: 1fr !important; }

  /* Stat value ainda menor */
  .stat-value { font-size: 16px !important; }

  /* Tabs de semana: menores */
  .ranking-tab { padding: 5px 8px !important; font-size: 10px !important; }

  /* Esconde picker da topbar em telas muito pequenas (pickers de página ainda ficam) */
  #topbar-mes-picker { display: none !important; }

  /* Pódio: 1 coluna */
  #ranking-podio { grid-template-columns: 1fr !important; }

  /* Modal padding menor */
  .modal-box { padding: 16px !important; }
}


/* ═══════════════════════════════════════════════════════════════
   MOBILE MÍNIMO  ≤ 360px
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  .stat-card-dark { padding: 14px 12px 12px !important; }
  .stat-value     { font-size: 15px !important; }
  #btn-pagamento  { display: none !important; }
  .ciclo-card     { padding: 10px 12px !important; }
}
