/* Layout mobile — Sistema Financeiro */
html {
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.navbar-toggler {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem;
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-wide {
  min-width: 640px;
}

.chart-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.chart-wrap img {
  max-width: 100%;
  height: auto !important;
}

.action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

@media (max-width: 991.98px) {
  .navbar-brand .brand-text {
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }

  .navbar-collapse {
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    padding-bottom: 0.5rem;
  }

  .navbar .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* Evita zoom automático no iOS ao focar inputs */
@media (max-width: 767.98px) {
  input.form-control,
  select.form-select,
  textarea.form-control,
  .form-control,
  .form-select {
    font-size: 16px !important;
  }

  .container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .page-heading,
  h1.h3 {
    font-size: 1.35rem;
  }

  .card-body {
    padding: 1rem;
  }

  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 38px;
  }

  .navbar .nav-link {
    padding: 0.65rem 0.85rem !important;
  }

  .navbar .btn {
    width: 100%;
  }

  table.table-wide {
    font-size: 0.8125rem;
  }

  .action-btns {
    flex-direction: column;
    align-items: stretch;
  }

  .action-btns .btn {
    width: 100%;
    margin: 0 !important;
  }

  .btn-group-mobile-stack .btn {
    width: 100%;
  }

  /* Calendário ASP.NET no mobile */
  .cal-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.25rem;
  }

  .cal-wrap table {
    max-width: none;
    width: 100%;
    min-width: 320px;
    border-spacing: 2px !important;
    font-size: 0.85rem;
  }

  .cal-wrap table td,
  .cal-wrap table th {
    padding: 0.35rem 0.2rem !important;
    min-width: 2.4rem !important;
    min-height: 2.6rem !important;
  }

  .cal-wrap .cal-pop-target {
    min-height: 1.75rem;
    font-size: 0.9rem;
  }

  .hero {
    padding: 1rem !important;
  }

  .menu-card .btn {
    width: 100%;
    justify-content: center;
  }

  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
}

/* Touch: popover do calendário por toque (além de hover) */
.cal-notepad-popover {
  max-width: min(320px, 92vw);
}

@supports not selector(:has(*)) {
  @media (max-width: 767.98px) {
    .card-body,
    .accordion-body {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
  }
}
